C# - An Unhandled Win 32 Exception Occured in exe[Process Id] - c#

My c# windows application is crashing abruptly and following application exception was logged by the DR.watson
Application exception occurred:
App: C:\Program Files\InstalltionFolder\Application.exe (pid=296)
When: 5/24/2012 # 11:13:00.141
Exception number: e0434f4d
()
Your help would be much appreciated.
Rgds
P

You need to debug your application inside Visual Studio. Load it up, build it in Debug mode, and press F5 or select Debug -> Start Debugging from the menu.
Then do what you did before to get the exception. Visual Studio will 'trap' the exception and hopefully display more information to you regarding the problem.
Without knowing the exception code, not much more help can be given.

You can check your register base
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\.NETFramework\DbgManagedDebugger
and you must have permission

Related

Remote debugging throws strange exception

When remote debugging my UWP application, VS always throws the following error after deployment process starts:
Error: Exception has been thrown by the target of an invocation.
Remote machine is a Win10 VM. The application runs fine when I select "Local Machine" from target machines list.
Things that I have ensured:
VM and development machine can see each other.
Remote tools are installed on the VM and Remote debugger is running.
Remote debugger says "[UserX] connected" when I start deployment, so VS is talking to it.
I have tried all 3 modes of authentication (None, Windows, Universal) and neither works.
I have restored NuGet packages, rebuilt all projects in the solution etc.
I have tried "Debug instead of Launch" checkbox and "Uninstall and reinstall my package" options too.
Has anyone else seen this behavior?
(Exception has been thrown by the target of an invocation generally contains a more specific exception inside it that shows what actually went wrong, but in this case I do not have any way to dig into the main exception).
Here's a snapshot of Output window:
Edit
Some more information. The error changes to the following if I choose Universal authentication:
Error: Field not found: 'Microsoft.VisualStudio.ImmersiveProjectServices.BootstrapperOperationPackage.StandardCollectorCpuAgent'.

Inspect dump files from UWP app

First I enabled saving of dump files on a Windows 10 Mobile phone:
Settings > Update & Security > For developers > Save this many crash dumps: 3
Then I debugged an app which throwed an exception. I continued the debugging after stop. After disconnecting and connecting the mobile phone again, I was able to access the dump file stored under Windows phone\Phone\Documents\Debug directory. The file is called
FPCL.WIndows - a736c773-c105-4b30-a799-4bf317872f5e with exception C000027B on 5-03-2016 12.11.dmp
and has about 140 MB!
I copied the file to the bin directory of my UWP app. Afterwards I opened it as file in Visual Studio 2015 (in the same project). Now I can see the Dump Summary and I have the following buttons:
Debug with Managed Only
Debug with Mixed
Debug with Native Only
Set symbol paths
Copy all to clipboard
If I run Debug with Managed Only I get
A fatal exception was caught by the runtime. See $stowedexception in the Watch window to view the original exception information.
and on clicking Break I get
No compatible code running. The selected debug engine does not support any code executing on the current thread (e.g. only native runtime code is executing).
In the Watch 1 window I see the following
Name: {CLR}$stowedexception
Value: {"The method or operation is not implemented."}
Type: System.NotImplementedException
This should be the exception I have thrown in my app. When I open this node and look under StackTrace I can get a line number. On pressing Continue I get
The debugger cannot continue running the process. This operation is not supported when debugging dump files.
So I can only stop it.
If I run Debug with Mixed I get again
A fatal exception was caught by the runtime. See $stowedexception in the Watch window to view the original exception information.
and on clicking Break I get
kernelbase.pdb not loaded
kernelbase.pdb contains the debug information required to find the source for the module KERNELBASE.dll
Module Information: Version: 10.0.10586.218 (th2_release.160401-1800) Original Location: KERNELBASE.dll
Try one of the following options: Change existing PDB and binary search paths and retry: Microsoft Symbol Servers
Here I can either press Load or New. So the kernelbase.pdb isn't found under the given location. Should it exists? Where should I find it?
In the Watch 1 window I see the same as above and I can only stop it.
If I run Debug with Native Only I get
Unhandled exception at 0x76ECDF95 (combase.dll) in FPCL.WIndows - f736c883-f105-4d30-a719-4bf328872f5e with exception C000027B on 5-03-2016 12.11.dmp: 0xC000027B: Anwendungsinterne Ausnahme (parameters: 0x075C6838, 0x00000002).
and on clicking Break I get the same missing kernelbase error as above, but here in the Watch 1 window the Value is Unable to evaluate the expression. So I can only stop it.
According to this post I should be able to inspect the source code and find the cause. But how is such a UWP dump file inspected correctly?
You mention
[...] 0xC000027B [...]
[...] $stowedexception [...]
which are both indicators that there is a Stowed Exception inside the dump.
To analyze such exceptions, first watch Channel 9 Defrag Tools, episode 136 where Andrew Richards explains and then analyzes them (at 3:28).
Then download the PDE extension from the Defrag Tools OnDrive and analyze your dump in windbg instead of Visual Studio.
Regarding the symbols of kernelbase, they should be downloaded from the Microsoft symbol server. To set that up in WinDbg, use .symfix;.reload. If you want to give it another try in Visual Studio, go to Debug / Options and choose Debugging / Symbols, then check "Microsoft Symbol Servers".
Regarding the button to press in Visual Studio, choose "Managed only" when debugging the debug build, because your app will run on CoreCLR and choose "Native Only" when debugging the release build, because your app will use .NET native runtime support. (This applies if you didn't change the default settings; otherwise choose according to your compilation settings)

Unable to run Console Application from Visual Studio: System.AccessViolationException

Description
When launching any Console Application, the code stops running immediately on an AccessViolationException (Additional information: Attempted to read or write protected memory. This is often an indication that other memory is corrupt). More info included in the next section.
Technical Symptoms
The Call Stack only contains external code:
Exception:Thrown: "The message filter indicated that the application is busy. >(Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))" (System.Runtime.InteropServices.COMException)
A System.Runtime.InteropServices.COMException was thrown: "The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))"
Time: 12/10/2015 10:59:55 AM
Thread:vshost.NotifyLoad[15344]
I created a new Console Application, containing only Console.WriteLine("Hello world!");
Running the new Hello world app results in the same exception and an identical
call stack.
Background
I suspect this has nothing to do with the issue, as I will explain, but I feel it is important to answer the obvious question, "what were you doing when the issue happend?" The last change I made was adding an extension to my Selenium Driver to hotkey logout from an application:
public static void logout(this IWebDriver Driver)
{
Driver.FindElement(By.TagName("body")).Click();
new Actions(Driver)
.SendKeys(Keys.Control + Keys.Shift + "x")
.Perform();
}
I also made a change in my App.Config file for one of my projects, but reverting this had no impact either.
Removing this code (the Driver extension and/or the App.Config change) does not resolve this issue. Retrieving a previous check-in does not resolve the issue. I am the only person currently working on this solution.
Discoveries
As mentioned, this is happening for an empty Console Application. Windows Form Applications launch fine. Unit Test Projects launch fine as well.
Research
I've spent hours looking into this. It seems like every similar issue I have looked into is pertinent to debugging only or a .NET version. For me, the issue occurs with a Release as well. Additionally, I have been using .NET 4.5 without any issues or changes on that front. I can't find any articles that seem worth posting, but I might be overlooking something.
Visual Studio Info
Microsoft Visual Studio Ultimate 2013
Version 12.0.30501.00 Update 2
.NET Version 4.6.00081 (just noticed it says 4.5 in my project properties, though)
Running as Administrator
Feedback
When Running from devenv.exe /SafeMode, Visual Studio loaded with:
An exception was encountered while constructing the content of this frame. This information is also logged in "C:\Users\UserName\AppData\Roaming\Microsoft\VisualStudio\12.0\ActivityLog.xml".
Exception details:
System.UnauthorizedAccessException: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
at Microsoft.VisualStudio.Shell.Interop.IVsShell5.LoadPackageWithContext(Guid& packageGuid, Int32 reason, Guid& context)
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.GetPackage()
at Microsoft.VisualStudio.Platform.WindowManagement.WindowFrame.ConstructContent()
Additionally, when trying to run, I get an error message of "Error while trying to run project: Invalid Pointer" (again, VS in devenv.exe /SafeMode - see how to run visual studio without plugin and all third party feature if unfamiliar)
Please let me know if I can provide any additional information.
It may be because when you name the project you can't put spaces, I put them and it gave me a AccessViolationException aswell, try using capitals to separate your words, but only use letters and no spaces to be sure.
I also faced this issue with Visual Studio 2010. More interestingly I had several projects in my solution (Console application, WPF application, Windows Forms application) but it was failing only when, I was setting the project which was of type "Console Application" as start up project. Following change finally helped me nail down the issue: Go to project properties of the console application project -> Go to "Debug" tab -> Go to "Enable Debuggers" section in right pane -> Check the "Enable unmanaged code debugging" check box as shown in the snapshot below. Root cause of why it happened is still not known to me. Only thing which I observed as fishy was that there were lot of windows updates which had got installed on my machine the previous night which mostly constituted of office updates and OS updates (More than a dozen KB articles).

Windows Phone - Debug info lines cause the program to malfunction

Hi I'm developing a windows phone app and I use
System.Diagnostics.Debug.WriteLine()
function to write some debug info and when I run the program in debug mode while my phone is connected to my computer and visual studio there is no problem. but when I run the program without debugger - while installed in each of release and debug mode - those lines of debug info cause the app to encounter an exception!
can anybody explain what's going in there?
You can try to check if debugger is attached, then execute codes specific for debugging purpose only if IsAttached value is true :
if(System.Diagnostics.Debugger.IsAttached)
{
System.Diagnostics.Debug.WriteLine();
}

an unhandled win32 exception occurred in w3wp.exe

I get the following exception when trying to load an ASP.NET MVC website:
Unhandled exception at 0x07070a91 in w3wp.exe: 0xC0000005: Access
violation reading location 0x00000000.
The Visual Studio Just-In-Time Debugger opens and the only information I can see in the debugger is this:
Call stack location:
msvbvm60.dll!06c00a91()
The website uses some COM objects and everything worked fine until last week. This problem appeared out of the blue.
This is the error log from Windows Event Viewer:
Faulting application name: w3wp.exe, version: 7.5.7601.17514, time stamp: 0x4ce7a5f8
Faulting module name: MSVBVM60.DLL, version: 6.0.98.15, time stamp: 0x4a5bda6c
Exception code: 0xc0000005
Fault offset: 0x00030a91
Faulting process id: 0x1a0
Faulting application start time: 0x01cd31fcb47f66d8
Faulting application path: C:\Windows\SysWOW64\inetsrv\w3wp.exe
Faulting module path: C:\Windows\system32\MSVBVM60.DLL
Report Id: f5db0ae3-9def-11e1-ad79-005056c00008
Do you have any suggestions to help troubleshoot this problem?
Edit: I managed to solve the problem and now everything works. The solution involved tweaking some registry settings that the custom dlls need in order to function properly. So the problem didn't actually appear out of the blue, I just didn't realize some registry values were modified, which caused a com dll to crash.
Open the Advanced settings dialog of the Application pool that is serving the application in IIS Manager, and set: Enable 32-Bit Applications to True
The information you provided above is not enough to provide a root cause however if you can provide more info about the exception you might get exact reason for this failure. You asked for suggestion to troubleshoot this problem so here they are:
You can use either any one of the 3 tools to troubleshoot this issue:
IIS Debug Diagnostics Tool v1.2
Here is more info about how to use this tool:
http://support.microsoft.com/kb/919790
DebugDiag
Use the link below to understand how you can hook your w3wp process (it is user mode proces) with DebugDiag and collect more info about the crash:
http://msdn.microsoft.com/en-us/library/ff420662.aspx
WinDBG
Here is a link which will help you to load W3WP process in WinDBG and use some commands to extract more info about the crash:
http://blog.whitesites.com/Debugging-Faulting-Application-w3wp-exe-Crashes__634424707278896484_blog.htm
Once you have more info about the exception, you can add above and will get prompt help.
Do the Following,
1) Give full rights to Temp & %temp% folders
2) Go to application pool properties & Change " Enable 32 bit application " to true
You may start by capturing a crash dump when this issue happens again,
http://support.microsoft.com/kb/2580960
Use Debug Diag 1.2 to set up a crash rule properly is step 1.
Once you have the dump, you can use WinDbg (part of Debugging Tools for Windows) to analyze it if you are familiar with dump analysis.
If you are not capable of analyzing that, my suggestion is that you open a support case via http://support.microsoft.com and share the dumps with Microsoft support engineers.
In my case, a program called "Web Companion" was installed.
After uninstalling it, the problem was fixed.
My Solution is if you want to build it on 64bit:
Debug ==> Options ==> Search for iis ==> enable using of 64bit Version of IIS Express
This was the fix that worked for me while publishing WebAPI 7.0 to IIS on Windows 10 Enterprise Edition:
Open IIS.
Go to your Application Pool.
Right-click on it -> Advanced Settings...
Under Process Model, change Identify from "ApplicationPoolIndentity" to "LocalSystem".
Restart your IIS.
In my case, It was occurring because there was an infinite loop over the code.

Categories