Search code examples
visual-studiodebuggingazurevisual-studio-2012visual-studio-debugging

Visual Studio 2012 Debugger suddenly stops while debugging Azure project


When I'm debugging my Azure project (1 Web + 1 Worker Role instance) locally, the debugger often just stops and the role instances are restarting.

I have no clue why this is happening, there are no uncaught exceptions and if I run the project without setting breakpoint everything works just fine. However when I set breakpoints and move through the code using Step Over / Step into, the debugger just stops at random intervals.

Does anyone know what is causing this / where I can find additional logs that may shed some light on this?

Update:

Either I overlooked this previously or it didn't get logged to the Output window, but I now got the following error:

First-chance exception at 0x000007fde4a4167f in WaWorkerHost.exe: 0xC0000005: Access violation reading location 0xfffffffffffffff8.
The Common Language Runtime cannot stop at this exception. Common causes include: incorrect COM interop marshalling, and memory corruption. To investigate further, using native-only debugging.

I'm pretty sure that's not my application's fault – as I mentioned, the exact code I'm debugging runs fine when I don't set breakpoints and step through manually.

Any ideas?

Update 2:

Frome the Bootstrapper (old) log:

[00012264:00001260, 2013/03/26, 11:37:19.777, 00100000] <- CRuntimeClient::OnRoleStatusCallback(0x0000006BD7718C00) =0x800706be
[00012264:00008432, 2013/03/26, 11:37:19.804, 00100000] <- CRuntimeAgent::RemoveEndpointRegistration(0x0000006BD76F60E0) =0x80070005
[00012264:00001260, 2013/03/26, 11:37:19.811, 00040000] Client process WaWorkerHost.exe is the role host.
[00012264:00008432, 2013/03/26, 11:37:19.830, 00100000] <- CRuntimeAgent::UnregisterEndpoint(0x0000006BD76F60E0) =0x80070005
[00012264:00001260, 2013/03/26, 11:37:19.830, 00080000] Failed to contact the role host process. Treat role as unhealthy.

The file ends with that – in the next bootstrapper log, the startup of role instances is being logged. Can it be that debugging prevents the bootstrapper from contacting roles and thus deciding they are unhealthy and must be restarted?

Last Update:

I wiped my project and did a fresh checkout from the repository. As it turns out, there was a missing reference in one of my class libraries. The missing reference never showed up as compile error, supposedly because there was an older version laying around somewhere.

To all others that find themselves in a similar situation, I can only recommend trying to do the same: completely cleaning their code base and see if the issue disappears. In all the logs I searched I never encountered a "MissingReferenceException" – would have saved me a lot of time today


Solution

  • Enable Diagnostics in Windows Azure

    UPDATE 1

    You could try enabling the logs

    Go to %USERPROFILE%\AppData\Local\DevelopmentStorage directory. You'll see two files enter image description here

    Open file DevelopmentStorage.201210.config and change LoggingEnabled to true.

    enter image description here

    References:

    Windows Azure worker role crashing WaWorkerHost.exe crashes role

    UPDATE 2

    WaHostBootstrapper log is located in C:\Resources\Directory\DeploymentID.Role.DiagnosticStore\WaHostBootstrapper.log

    Other logs:

    WaWebHost C:\Resources\Temp\Guid.Role\RoleTemp\WaWebHost.log

    WaIISHost C:\Resources\Temp\DeploymentID.Role\RoleTemp\WaIISHost.log

    IISConfigurator C:\Resources\Temp\DeploymentID.Role\RoleTemp\IISConfigurator.log

    IIS Logs C:\Resources\Directory\Guid.Role.DiagnosticStore\LogFiles\W3SVC1

    Windows Event Logs D:\Windows\System32\Winevt\Logs

    UPDATE 3

    Defining local storage in Azure Application creates a new folder so path to your Azure Compute Emulator is %USERPROFILE%\AppData\Local\dftmp\