I want to be able to capture intellitrace style calls to a certain method during debugging of my app.
Specifically, each time during debugging when MyLibrary.MyClass.MyMethod is called ideally i'd get a pane of sorts in Visual Studio that would contain the info about the event and the method arguments.
Unfortunately, i need to get it working in Professional edition of Visual Studio (which doesn't have Intellitrace).
I have only tried investigating EnvDTE80 and there doesn't seem anything suitable at the first glance.
What would also work is if i could make some custom code run inside the app's app domain while debugging. I could probably use MS Fakes from Enterprise version, generate a shims assembly, place all of debugging into a ShimsContext and then re-route my calls.
Related
So I'm now using Visual Studio 2019 in C# .Net Framework.
I have been programming in Visual Basic 6.0, and when I pressed F5 the IDE run and if there were errors while debugging if I pressed the X to close the Vb6.0 IDE. a message box prompted saying if I wanted to save the changes since there were errors while debugging I pressed no.
Now in Visual Studio 2019 using C#, that doesn't happen. If I press F5 and an error occurs while debugging, it autosaves the solution with its error. How can I stop it from saving with the error in it?
No, you can't debug code that hasn't been saved with Visual Studio. If you want to see the process it goes through, do this:
Open Tools -> Options
Click "Projects and Solutions", then click "Build and Run"
Change "MSBuild project build output verbosity" to "Normal" (or, if you want to see a lot of stuff, "Detailed" or "Diagnostic"
Rebuild your project
You'll see VS invoking the compiler and passing the paths to each of your file (and to all of your references) to the compiler. It needs to save and to compile and then execute your code.
The VS debugger is a full Windows debugger. Open Windows Explorer, double-click your EXE. Now open VS, in the Debug menu, choose "Attach to process" and choose your running EXE. You are debugging it (you can attach to any process you have rights to, but attaching to a debug build where symbols are handy give you the best experience).
BASIC and pre-.NET VB started their lives as interpreted languages. A pre-processor would take your source and convert it to tokens. Then an interpreter would interpret those tokens as it ran your programs. Though the last few versions of traditional VB could compile your code to an EXE, that interpreter was still there.
In particular, the debugger used it. When you ran the VB6 (and earlier) debugger, the debugger didn't debug your program, it debugged your source - injecting itself into the interpreter, not attaching itself to the EXE. That's why the behavior you are asking about worked.
As I mentioned, getting a Source Code Control system set up (which is always a good idea) will help you get close to what you want. Git's probably the easiest to set up. Visual Studio Team Foundation Services (or whatever it is called this month) is also a possibility.
The Context
We'd like to modify Roslyn and be able to debug it while compiling with it. Pre-VS2015 release, doing this was a painful process that didn't flow very well.
Our goal is to develop a C# variant compiler.
The Dream
Pre-VS2015, executing and debugging your modded Roslyn required the opening of a second VS IDE (experimental) set to use your modded Roslyn. This process wasn't straight forward to setup properly, and oftentimes would break your VS2015 installation.
Post-VS2015, is there a better setup and process possible to modify and debug Roslyn?
I have installed Visual Studio 2015 but it looks like I need more required bits. After that I'm unsure how to run the tests and try the changes in VS2015.
We have our current documented process of testing your own versions of Roslyn here. As long as you're on Visual Studio 2015 Update 1 or later (where we did all the work to support this), everything should work.
The executive summary of those instructions is if you now enlist into Roslyn, you can choose the "VisualStudioSetup" project and just hit F5 to run. That builds to .vsix files in your build directory you can also install. If you want to, there's a CompilerExtension project that produces a compiler you can build with.
The shop where I work is currently using VB6 for development using controls and libraries. Someone once showed me how to use Visual Studio to be able to debug this code by simply creating a console application in C# and then changing a few options. He showed me this in VS2010, but I am now using 2015. When I go into the project properties and go to the Debug tab, the option for "Enable unmanaged debugging" is not there. Did Microsoft remove this option? I have searched the web quite a bit, but have had no luck finding a solution.
Also, for kicks, I also have 2010 installed on my machine. The option is available there, however when I attempt to run and debug I get a LoaderLock failure. After researching it I found that I have to disable the exception in Visual Studio. However, it would appear that my exceptions are locked down and I cannot change them as they are all greyed out. I am an administrator on the machine I am using, but I am unsure of where or what I need to change to enable me to change the exception settings.
Any recommendations on either issue would be greatly appreciated. It's not a show stopper for me, but a HUGE inconvenience.
I've been developing a C# project in Visual Studio Express 2013 and came across Code Contracts for .NET languages. Impressed by their brevity and the static analysis tool that came with them, I started using them in my code base. However, when I attempted to run my program, I was met by an error message similar to the one found in this SO thread, i.e.
...An assembly (probably "<my project>") must be
rewritten using the code contracts binary rewriter (CCRewrite) because
it is calling Contract.Requires and the CONTRACTS_FULL symbol is
defined. Remove any explicit definitions of the CONTRACTS_FULL symbol
from your project and rebuild...
Guides suggest that to fix this, I have to enable Code Contracts from my project's Properties page, but a Code Contracts Properties entry is nowhere to be found in Express.
Some MSDN forum threads seem to indicate that all the tooling for Code Contracts is included in the Express version, but the Code Contracts Properties page is not. This seems to be the case, as I was able to run my project in VSE 2013 only after enabling Code Contracts with a copy of Visual Studio 2012 Ultimate I acquired from my university before graduating.
Is there really no way to work with Code Contracts in Visual Studio Express except by modifying the project files either manually or with a paid version of Visual Studio? If this is the case, I am extremely hesitant to use them at all, since my company is unlikely to purchase VS licenses. Futhermore, it seems extremely odd that Microsoft would attempt to proliferate this new and superior verification paradigm but then restrict it to paying customers only.
You can probably use the new VS Community 2013, as long as you meet the licensing requirements:
http://www.visualstudio.com/en-us/visual-studio-community-vs
Here’s how Visual Studio Community can be used in organizations:
An
unlimited number of users within an organization can use Visual Studio
Community for the following scenarios: in a classroom learning
environment, for academic research, or for contributing to open source
projects.
For all other usage scenarios: In non-enterprise
organizations, up to 5 users can use Visual Studio Community. In
enterprise organizations (meaning those with >250 PCs or > $1 Million
US Dollars in annual revenue), no use is permitted beyond the open
source, academic research, and classroom learning environment
scenarios described above.
It's basically VS 2013 Professional for free so you can install the code contracts extension.
The problem is your edition of Visual Studio. You are running Visual Studio 2013 Express edition, as you stated. In order to use the binary re-writer from within Visual Studio, you need to install the Code Contracts extensions. These you can download from Microsoft's Research in Software Engineering (RiSE) site, which is packaged as a Windows Installer.
The installer installs the binary re-writer that is required, as well as a bunch of Visual Studio extensions. Unfortunately, Code Contracts states in their manual on page 40 that they don't support the various Visual Studio Express editions. You'll need to at least have Visual Studio 2013 Professional edition in order to use the Code Contracts binary re-writer extension from within Visual Studio, and in order to see the Code Contracts tab on the project properties window.
Code Contracts performs assembly re-writing as a post-build step. Meaning, Visual Studio first compiles the .NET code as it normally would. But, when using Code Contracts and enabling the right options on your project (assuming the VS extensions are installed—which you can't do in Express editions), then the binary re-writer is called for you by Visual Studio after the normal compilation process.
Instead, after compiling your program, you'll need to manually run the ccrewrite program installed by Code Contracts on the compiled assembly (and all dependent assemblies) to 're-write' your assemblies, which will add in all the Code Contract checking information. See the Code Contracts documentation (also available on the RiSE website) for information on how to do this.
Contracts are supposed to be useless for Visual Studio Express 2013 (at least Code Contracts come with a plugin for all non-express versions).
So one has to define the symbol CONTRACTS_FULL in project properties -> build -> general -> conditional compilation symbols.
And then add the proper call to ccrewrite.exe to the post-build event command line found under project properties -> build events. The command should be set to something like
"C:\Program Files (x86)\Microsoft\Contracts\Bin\ccrewrite.exe" -throwOnFailure "$(TargetPath)"
I successfully used this tonight with NUnit. Using contracts, my unit tests don't need to check for post conditions explicitly.
This is what I'm looking for: I'd like to be able to get a real time method call listing when I am debugging my program. So for example, say I run my program via the debugger if I press a button or do anything in my program I'd like for it to spit out, say on a visual studio plugin, in real time, all the methods it went through when I pressed this button or did some kind of user action with my program.
I actually once wrote a visual studio plugin that does that by using the visual studio profiler api (I had to write a c++ com server dll that receives this information and pipes it back into my c# plugin). I did this a few years back and I have no idea where I put it. But I'm wondering if Microsoft did something like this in visual studio 2010 or if you know of any third party plugins like this because it is a very handy debugging utility.
Thanks
Check out Visual Studio 2010's Intellitrace feature - it might get you what you need: http://msdn.microsoft.com/en-us/library/dd264915.aspx
You should check IntelliTrace debugging in Visual Studio 2010. It works only with x86 though
It's not free, it's not even cheap, but RedGate's ANTS Performance Profiler can provide that data and more.
I think you could achieve that using AOP, e.g. PostSharp and an implementation of it's OnMethodBoundaryAspect and a MultiCastAttribute to apply your aspect to every method of your program. They even have an example for something quite similar to what you want on their site.
Updated link as of 8/15/2018: IntelliTrace
Note that this feature is in Enterprise edition only
From the linked page:
You can spend less time debugging your application when you use
IntelliTrace to record and trace your code's execution history. You
can find bugs easily because IntelliTrace lets you:
Record specific events
Examine related code, data that appears in the Locals window during debugger events, and function call information
Debug errors that are hard to reproduce or that happen in deployment
You can use IntelliTrace in Visual Studio Enterprise edition (but not
the Professional or Community editions).
My Runtime Flow extension shows method call listing when you press a button or do anything in a program. It works outside Visual Studio debugger.