My F# code doesn't run, how can I investigate further? - visual-studio

I downloaded Visual Studio Community 2015 to try and lean F#. My F# projects compiles without any issues but when I try to launch the console project (even the default console project) Visual Studio just hangs and then freezes. The only way I have to shut it down is to go to the task manager.
Same thing if I try to directly launch the generated .exe file: explorer freezes and I have to go to the task manager to restart it.
All my C# projects work fine...

I have seen a similar behavior before on a machine that had an anti-virus installed. The anti-virus was blocking Visual Studio from running F# code with debugger and disabling the anti-virus resolved the issue.
In general, there are a few ways to run F# code in Visual Studio:
Using F5 to start the program with a debugger (this is the one that the anti-virus was blocking); F11 which steps into the debugger was also not working
Using Ctrl+F5 which starts the program without a debugger - this should work!
By creating an F# script file (Script.fsx), selecting code and using Alt+Enter to run code using F# interactive - this should work too.
Many people do quite a lot of work with F# using F# Interactive, so learning how to use that is a good skill, but to use the debugger, disabling anti-virus should do the trick.

Related

Visual Studio JIT Debugger hangs

I've always used System.Diagnostics.Debugger.Launch() as a quick way to debug web services. I get a dialog asking me to choose a debugger, I pick "New instance of Visual Studio" and it fires up VS and lets me step through the code.
That has suddenly stopped working. Now I get the dialog, and choose Visual Studio, and the VS splash screen appears, and then it just hangs. The dialog window says "Not Responding" and I have to force it to close. Even then, a VS instance is left hanging around in Task Manager and I have to kill it manually.
I've tried repairing Visual Studio, and uninstalling and reinstalling Visual Studio, and nothing fixes it.
In desperation, I completely flattened my PC and reinstalled everything from scratch. It lasted about a day and then JIT debugging started hanging again. I was on Windows 10 and Visual Studio 17.4.1 before, and I'm on Windows 11 and Visual Studio 17.4.2 now.
To make sure that it's not a problem with some particular code, I created a one-line console app System.Diagnostics.Debugger.Launch(); and that crashes just the same.
Has anybody experienced anything similar, or have any idea what could be going wrong?
I don't know why that fails, but I suggest to attach to a running instance of Visual Studio instead. Start Visual Studio first, and then when the "launch debugger" window appears, select the running VS instance. Preferably, you should even open the correct solution/project first. If you attach to that instance, all your source code and the project structure is available for debugging.
Another alternative: Instead of using Debugger.Launch(), use a code snipped such as
while (!Debugger.IsAttached)
{
Thread.Sleep(100);
}
at the beginning of your program and attach the debugger from within Visual Studio (using the menu option Debug->Attach to process)
I had the same exact problem and after updated to VS version 17.4.4 the issue disappeared. All good now.

Visual Studio doesn't run programs

I downloaded visual studio for C# and now my problem is that when I run a program the very first time it runs without issues but the second time after exiting the program it shows this (pressing f5 also does nothing):
I have tried repairing Visual Studio and uninstalling and reinstalling it but that also doesn't work. It happens to other files too like Python files or asp.net files. Anyone know what's going on?
Try setting your project as a StartUp Project.
See this answer for details.

Custom Visual Studio Debug Engine for Simulator

I have a requirement for developing a debugger extension for Visual Studio. The code is in C++, however, it is run in a simulator environment. The application is capable of receiving break points and displaying variable information.
I have looked into the Concord API, but it seems rather complex. Do I have to develop an Expression Evaluator, even though the code is in C++?
Basically I just want the program to run and hit the breakpoints that the user has created for starters.
Should I try and write a visual studio extension instead? Although I don't see any way of halting execution of a program in debug mode?
Thanks
Ah the joy of writing a custom debugger! I'm writing one now. See the visual studio custom debug engine sample to start with. Python Tools for Visual Studio, MIDebugEngine are more complex but also more complete and production code. Much easier to write the debugger in C#.
Some blogs that helped me a lot.
https://limbioliong.wordpress.com/2011/08/30/creating-a-com-server-using-c/
https://blogs.msdn.microsoft.com/jmstall/2009/07/09/icustomqueryinterface-and-clr-v4/
VS2005 SDK PDF has more detailed debugger documentation.
VS2015/17 C# Extension projects has a custom project type package which comes with a script debugger launcher to start with.

F# compilation hangs in Visual Studio

I've got a solution containing a mixture of C# and F# projects (it's a Silverlight app). When I attempt to compile it in Visual Studio 2010 SP1, the build process hangs on one of the F# projects. If I remove that project, it hangs on a different F# project.
The F# compiler (fsc.exe) isn't running, and I can't find any likely-looking process to kill (other than devenv.exe).
It compiles fine on the command line, using MSBuild. It compiles fine in VS11 beta. We can't (yet) migrate the solution to VS11.
This occurs on my PC, and one other PC. None of the other team members have this problem.
Has anyone seen this behaviour before? How do I go about debugging this?
It may be useful to go to Tools\Options\Projects&Solutions\Build&Run and change MSBuild output verbosity to 'diagnostic' and then check the output window to see exactly where things are getting hung, that may help diagnose.

Visual Studio 2010 hangs on attach to process / debugging

Whenever I try to debug a Visual Studio 2010 web project, VS hangs, and ultimately crashes. This happens if I try to start the project using F5, or through Attach to Process, before the process list even appears.
Hitting F5 in, for example, a Windows Form project works fine, but attach to process fails here too.
Any ideas on what can be causing this? Obviously attaching to the devenv.exe process won't work as I can't get the Attach to Process dialog to appear...
Oh, running W7 (x64), VS2010 SP1 (had same problems without SP1)
In Solution Explorer there is a Show All Files icon (highlighted in the photo below):
Make sure it's turned off,
When It's turned on, Visual Studio tries to index all the files in the solution and if you have a giant Solution it could take forever!
I hope this has helped someone :)
Have you recently installed Mono and/or Mono Tools for VS2010?
I found that to be the problem it my case. Not sure why, but it somehow got in the way.
Matthew
In my case hangs when executable type was not correctly set, ex. Managed v4.0 and trying to attach to Native.

Resources