Application only crashes when debugger is attached - c#

Currently I am developing a global exception handling in a .NET C# application. I get some strange behavior:
If I debug the application from Visual Studio (F5), an unhandled exception causes the main thread to be terminated.
If I start the application without Visual Studio (click on the .EXE) with the exact same compile output (DEBUG-Build), the App doesnt crash after an unhandled exception occured.
This is kind of weird behavior...Does anyone know what's going on here?
EDIT:
It seems as if something changes within the running code as soon as a debugger attaches to the process... If I start the App without Debugging from within VS, the App doesnt crash.

I’ve been doing some work with ASP.NET MVC but was having periodic issues with Visual Studio 2008 hanging (freezing / becoming unresponsive) when I tried to run my web application with debugging. The problem only occurred with a specific web project.
I tried deleting the Temporary ASP.NET Files (%userprofile%\AppData\Local\Temp\Temporary ASP.NET Files) but that did not solve the problem.
I tried deleting the obj folder. No luck.
I tried waiting it out one evening. I eventually feel asleep and when I awoke sometime in the middle of the night, my web app was happily waiting for input and Visual Studio debugging was completely responsive. That proved to be a temporary salve.
showallfiles The problem resurfaced again a few days later and I finally figured out the problem with my uncooperative debugger. I have a folder containing approximately 20,000 images that are not included in the Visual Studio web project but are sitting in a directory in the web site. I had turned on "Show All Files" in Solution Explorer to add some script files into the project. When "Show All Files" is off, F5 (Start Debugging) works like champ. When "Show All Files" is on, Visual Studio becomes unresponsive. In reality it is not "frozen" but simply taking a very long time to process those 20,000 image files.
Mystery solved.

Related

Program only runs from Visual Studio

I've written a basic program using Xamarin.Forms. I can run the UWP version of the program completely fine in both debug and release mode from Visual Studio 2017 with no crashes. However, if I try to run either the release or debug .exe directly from the file explorer, the program loads, but crashes almost immediately afterwards. There's no window that pops up for a split second; the program crashes without a trace. The same situation occurs on different computers. What's strange is that I could run either .exe directly about a week ago, and that everything stopped working only recently.
If I check the event viewer, I get a .NET Runtime error that states this:
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
I'm assuming this has to do with a blocked DLL or something auto injected by Visual Studio that isn't included in the build directories. However, I am unsure where I'm supposed to go from here and I've pretty much hit a brick wall in terms of research. How can I get the .EXE's running from the file explorer again?

Program doesn't work outside Visual Studio

I use unmanaged dll with P/Invoke in this app, and I always tested it inside Visual Studio (with debug mode on x86 CPU because the dlls are only x86), and it works just fine. But when I just start the exe manually after some time (probably at the first operation with those dlls, but I don't know exactly) it says the exe has stopped working, and it starts checking for solution (I use Visual Studio 2013 on Windows 8.1, if that matters). I tried to add the dlls to the project as existing item, but that doesn't help. Also I know, that it's not because it can't find those dlls, cause if I delete them, it doesn't crash, just freeze without any error message. Shouldn't it work the same from Visual Studio as manually started?
There is also a weird bug when I run from Visual Studio: everything's work fine, but sometimes Visual Studio just suddenly stops debugging, as if the program were closed and the GUI of my app freezes, and I can only close it by closing Visual Studio (as I close it, the GUI disappears). Maybe it's a totally different problem, but it can be connected.
Edit:
Here's the project on github, if somebody could check it:
https://github.com/geiszla/CycriptGUI
Some news: If I run it with Ctrl+F5 it also crashes. What's the difference between F5 and Ctrl+F5, that can cause this problem?
Searched all over Google with no real simple answers. Here it is folks(at least it worked for me and is simple):
When you run the console app in Visual Studio, look at the output window at the bottom, get the location of the ..\bin\Debug\*.exe
Copy the *.exe and the *.config to your desired folder, run it, it should work the same way in Visual Studio.
Thanks for every help, my problem was solved: I called an unmanaged function with only 2 parameters, while it had 3. However I still don't understand why it worked with debugging mode, and not without debugging.

VSHost.exe keeps starting in VS2010

I'm working in VS2010 with a solution with lots of projects and it is constantly becoming unresponsive.
One thing I've noticed which may be a clue is that MyApplicationName.vshost.exe is constantly popping up in the process list despite the fact that I have not started any debugging. It could be happening whenever a build takes place perhaps?
I'm not launching the application from within VS at all. I'm just executing it from within the bin directory.
Killing the vshost.exe process seems to often cause VS2010 to become responsive again.
Any ideas why this process could keep getting spawned?
Thanks!
In your project properties, try unchecking the following box in the Debug tab:
Enable the Visual Studio hosting process

Visual Studio custom control dll access denied error

This is one of those, "was working 15 minutes ago" problems. I've been running my app without a problem and then all of the sudden I'm receiving this error when trying to load the design view:
Access to the path '[my-local-path]\Application Data\Microsoft\VisualStudio\10.0\ProjectAssemblies\waswbeet01\Interop.EModelView.dll' is denied.
As far as I can tell I didn't make any significant changes to the app to trigger this. I can go to the specific file location and see the dll there and it's permissions for SYSTEM are full control.
My head hurts from banging it against my desk.
Sounds like something has that file open / locked - there are a few things you can try:
Get Visual Studio to Clean and then rebuild the solution (it might be Visual Studio that has the lock)
Close and re-open Visual Studio
Use a tool like Process Explorer to check to see what processes have a handle to that file (and also optionally forcibly close the handles)
Restart your PC
I've seen problems in the past where Visual Studio keeps handles / locks on files that it shouldn't which can cause problems building - this is why I suggested restarting Visual Studio / doing a clean build as the first options.
Are you running under Widows 7?
If so, you must start Visual Studio under Administrator to get full access for the dlls.
Also, are you trying to modify and build your application during the execution?
If so, you should stop your application before you can change the dlls.

Debug Techniques: Visual Studio 2008 Process fatal crash after debug of WPF application

I have a relatively large C#/WPF Visual Studio 2008 solution that I am trying to test and synchronize across 2 developer's computers. On my computer, I am able to build and debug (run) the project successfully without errors.
On the second computer, I am able to build the solution without any errors. When I attempt to run the solution, Visual Studio starts the process but about 3 seconds later the entire development platform exits. Before it exits I briefly see one of our .xaml files opened by visual studio with a yellow 'unhandled exception' box pop-up on a certain line number. I'm currently contacting the part of my company who is responsible for implementing the functionality of that xaml file.
This raised a bigger issue in my mind: How can you troubleshoot an issue when Visual Studio is immediately exiting after attempting to run a program?
The Visual Studio 2008 crashes when starting to debug post may also be helpful. I'm trying those solutions now.
We found that executing the three following commands helped to fix our problem:
devenv.exe /ResetSettings
devenv.exe /ResetSkipPkgs
devenv.exe /Setup
This was suggested in another stackoverflow post here helped us to determine that it was a plugin, AccuRev's Visual Studio plugin, that was causing the issue.
The issue also appears to be a "known issue" with a hotfix from Microsoft, documented here.
VS2008 SP1: In Visual Studio 2008 SP1, having windows in non-default locations, for example after docking and undocking windows, when switching between debugging and designing or switching to/from full screen, can result in a crash of the Visual Studio IDE.
Thanks for your help!
Run devenv/debugexe to debug your exe. When an unhandled exception occurs, in the debug menu, select "save as dump", then visit http://connect.microsoft.com/visualstudio to open a bug report and attach the dump file after creating the report.

Categories