While debugging through the code, I am getting following error.
A debugger is attached to w3wp.exe but not configured to debug this unhandled exception. To debug this exception, detach the current
debugger.
I tried the fix from the following link, but it won't work for me.
http://social.msdn.microsoft.com/Forums/vstudio/en-US/373e738f-1bc7-4dcb-88b4-ee8e78d72dc1/an-unhandled-exception-was-raised-from-microsoft-net-framework-v-10-11-or-20-but-the-current?forum=vsdebug
It works fine when I use Visual Studio 2012, but it fails when using Visual Studio 2013. I tried repairing Visual Studio 2013, but It never worked.
Do anybody know the fix for it?
Thanks.
Try This
Go to Project Properties
Debug
Change Debug type to Mixed(managed and native) from managed only for both Application and Background process.
You may be encountering this issue if you have native C code (unmanaged) and C# (managed) code in the same project.
Changing the debug type to mixed makes debugging significantly slow.
I've just had this issue and it was solved by enabling 32 bit applications on the website's App Pool, as detailed here (thanks Colm!):
http://colmprunty1.azurewebsites.net/a-debugger-is-attached-to-w3wp-exe/
Sounds like maybe you have just in time debugging turned on. Your program throws and exception that your current debugger is not configured to handle and perhaps the system is launching the just in time debugger. This is a registry setting but can also be controlled via options in Visual Studio.
http://msdn.microsoft.com/en-us/library/k8kf6y2a(v=vs.85).aspx
To disable Just-In-Time debugging by editing the registry
On the Start menu, search for and run regedit.exe
In the Registry Editor window, locate and delete the follow registry keys:
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft.NETFramework\DbgManagedDebugger
If your computer is running a 64-bit operating system, delete the following registry keys also:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft\Windows NT\CurrentVersion\AeDebug\Debugger
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Microsoft.NETFramework\DbgManagedDebugger
Take care not to accidentally delete or change any other registry keys.
Close the Registy Editor window.
Had the same problem. Got this message all the time I wanted to start my app in debug-mode.
Turned out the problem was, that I still had appverifier (http://msdn.microsoft.com/de-de/library/windows/hardware/ff538115(v=vs.85).aspx) linked to my app. Once unlinked everything went back to normal and I could debug normally.
Not sure if anything to do with your problem. Just saying :)
Are you able to modify the source code so that it thows a meaningful exception?
Also try to recompile the source with VS 2013 and check if the debugger runs fine this time.
Related
I have been assigned to work on a Windows Service project. I installed it in my machine using installer class (ProjectInstaller.cs). I want to debug the source code and sometimes need to make changes while it is in debug mode. I attached the process via Debug menu to debug the project which works fine but it throw an error while I am trying to edit or continue the source code:
Managed Compatibility Mode does not support Edit and Continue
I googled and tried tons of solutions but none of them worked for me, couple of them are as below:
Unchecked the Use Managed Compatibility Mode from Tools -> Options
Unchecked Managed Compatibility Mode from Debug -> Attach to Process
-> Attached To -> Select...
Checked the Managed (v4.6, V4.5, V4.0) from Debug -> Attach to
Process -> Attached To -> Select...
Played with Platform target in Project Build.
Added {351668CC-8477-4fbf-BFE3-5F1006E4DB1F} field in my .csproj file
The error message varies depending on different solutions I implemented.
Below is the link I last time tried:
https://blogs.msdn.microsoft.com/visualstudioalm/2013/10/16/switching-to-managed-compatibility-mode-in-visual-studio-2013/
I am guessing: the last one didn't work because I do not have an exe project for my service instead I have implemented ProjectInstaller.cs Class and manually installed it through command prompt.
Any suggestion/recommendation are welcomed.
Edit and Continue requires many factors which are not obvious to users. Your case is simply not supported (mostly for attaching cases).
See Supported Code Changes (C#) in MSDN. In particular:
Edit and Continue is not available in the following debugging scenarios: [...]
Debugging an application that has Attach to instead of running the application by choosing Start from the Debug menu.
Unckeck Use Managed Compatibility Mode, It working for me! and you must Enable Edit and Continue in Debuging General
Attaching my process for each debug was a headache for me.
Just want to share a link that saved a lot of my time by writing a simple method and calling it in Main() method inside Program.cs.
This also gives me flexibility to edit and continue my code as simple as WinForm / Web Form. LOVE IT.
https://coding.abel.nu/2012/05/debugging-a-windows-service-project/
I reset the VISUAL STUDIO settings and the problem is resolved
hope it helps to Reset visual studio setting
Pls don't mark it as duplicate .. bcoz I have seen all the solutions but nothing is working for my case..
I have two machines devMachine and serverMachine
in devMachine I am developing application with Visual Studio and Now I have a simple Console Application..my need is I need to run this Console Application in serverMachine and debug from devMachine via Remote Debugging.
As told in Microsoft document, I have installed Remote Debugging tool in serverMachine and set the Authentication mode as Native (No Authentication) and run the Console Application in serverMachine.
Now , I have attached the remote process in devMachine's Visual Studio. All are working fine
But only problem is breakpoint is not hitting in Visual Studio
Note: I have placed required .pdb file in serverMachine and set that .pdb file path in devMachine's Visual Studio (Tools->Option->Debugging->Symbols).
Can anyone help me to resolve this issue?
What does the error message on the breakpoints say (if you hover over the breakpoint) - that it's different from the source? --> You can try disabling (from Tools/Options/Debugging) - Enable source file to exactly match the original version
What does the Modules window say - do the PDB's appear as loaded? if not, have you tried loading them manually (from the Modules window, right click the PDB and load)? - Is there an error message if it fails?
--> you might be in a case where the source files in the local machine are different from the ones on the remote one. Try copying everything over and see if that works (PDBs would be in the same folder as the EXE)
There are two reasons for the remote debugger to not hit the breakpoint
Wrong symbols.
Using the wrong .Net framework while debugging ( you can select on the "attach to process" window in visual studio).
Don't attach and just set remote debugging on. Copy all the project files to the identically placed and named folder in the server during post-build.
I had an issue with Visual Studio not breaking at my breakpoints although it looked like everything was setup correctly for the remote debugger on an IIS machine. I searched everywhere for an answer. The issue finally presented itself when I tried to manually attach the VS debug to a process (VS menu --> Debug --> Attach to process...) For some reason, there were multiple processes for the same application pool (there should only be one process, not sure where the others came from) I logged into my IIS server and killed all the processes for my application pool and then restarted the IIS application. When I saw there was only one process for the app pool (as I expected), I tried debugging in Visual Studio and it attached to the correct process. It turns out that when there were multiple processes for the same application pool, it attached to the "wrong" one.
Looking at your screen shot, could it be simply because the break points are in the "main" function which could already have finished before you can attach the debugger?
Suggestion:
Maybe put some artificial wait/delay code of say 20 secs in "main" above the first break point to give yourself enough time to attach to the process before "main" completes.
I've come across an extremly annoying bug this afternoon. I've been working casually on console application I'm working on for a while now and for no reason at all the VS2012 debugger started hanging when I quickwatch any variables. It hangs for like 15-20 seconds, then I get the message
Function evaluation is disabled because a previous function evaluation timed out
If i then hit F10, the debugger unattach and the process goes on. It crashes on almost every variables that are implicitly declared
Here's the steps I have taken so far to resolve this problem.
Steps I have taken:
Restart VS
Reboot computer
Deleted all breakpoints
Deleted ncb and suo file
Symbol Server is not enabled
No Network location is used, User files are local, project files are
local.
Just My Code enabled/disabled
Ensured Enable .NET Framework source stepping is NOT enabled
Ensured Step over properties is enabled
Ensured Enable source server support is not enabled
Start visual studio with /SafeMode to suppress extensions
Cleared Watch Window (was empty anyway)
Tried changing target platform to x64 and any CPU
Disabling antivius
Resetting visual studio default settings(devenv.exe /ResetSettings)
Reinstall VS
The application I'm debugging :
Type : C# Console application
Target Framework: 3.5
Platform target: x86
For my health sake, please help.
EDIT : I have Visual Studio Update 3, version 11.0.60610.01
EDIT: My computer specs
Windows 7 Ultimate 64 bits
Dell Optiplex 960
Intel Core i5-2400 3.1 Ghz
4 GB RAM
EDIT : I tested on two machines (same code) without visual studio update 3 one that does work, one that does not.
EDIT: A created a simplified console application with the same settings that contains only the following lines of code. I'm getting the hang problem when I watch and then it unattach also. What could be wrong with my machine?
This is a simplified application that hangs the debugger
static void Main(string[] args)
{
var _AppLocation = System.Reflection.Assembly.GetEntryAssembly().Location;
_AppLocation = _AppLocation.Substring(0, (_AppLocation.Length -
(System.Reflection.Assembly.GetEntryAssembly().GetName().Name.Length + 5)));
var directoryInfo = new DirectoryInfo(_AppLocation);
Console.ReadyKey(); //I break here, check the directoryinfo
}
EDIT 10/3/13: This is still unresolved, reinstalling everything(office,framework,vs) completly did not solve the problem. It must be a vs2012 bug that is os/hardware related. I will open a ticket at Microsoft and update if they find out something usefull.
EDIT 10/30/13: This problem have been reproduced on two machines with different hardware configuration. I'm still in contact with microsoft to find the issue. Looks like something related to the framework/windows build/visual studio.
EDIT 11/19/13: I'm still in contact with Microsoft VS escalation team, here's the process monitor log and visual studio crash dump of the problem. http://sdrv.ms/1egpX4O
Solution found in parallelle with the Microsoft VS Escalation team. After analysing the crash dump and process monitor it seems that VS 2012 debugger process checks the store certificate for the Microsoft Root Authority certificate.
Since both computers where in a protected no internet environment, both of them never had been connected online. Thus, they never downloaded the Microsoft CA. Since the CA was absent from the store, it caused the debugger to hang and crash for 3.5 target framework specificly.
Here's the fix from Microsoft VS Team to bypass this check when debugging: (Add in the application app.config)
<configuration>
<runtime>
<generatePublisherEvidence enabled="false"/>
</runtime>
</configuration>
Problem resolved!
I had this same problem with Visual Studio 2015 (including Update 1 and Update 2). So posting my solution (which I submitted to MS) in case somebody else has this problem.
Whenever I tried to use QuickWatch in Visual Studio 2015 Enterprise it would hang the development environment. I can’t click on anything and I’m forced to kill the process via Task Manager. It seems like the modal window opens behind it.
My computer is an HP Spectre and I have another monitor plugged in. I’ve tried it on both monitors.
The fix was to:
Switch to a single monitor
Make the QuickWatch open (which it does)
Move it around (which must
save the window position)
Close it
Plug second monitor in
Now when I use the QuickWatch, it will open correctly
Consider using Process Monitor tool to get a log of file, network, registry and processes operations happen during your investigation. After capturing the log, you may see through it and investigate the possible reason. Or, you can send your log to me and I will investigate it on my side
http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
I have done a quick research on msdn and found this :
http://social.msdn.microsoft.com/Forums/vstudio/en-US/2055d3a0-56d9-4134-be23-09a91203e508/quickwatch-says-the-following-for-all-evaluations-function-evaluation-disabled-because-a-previous
Please try the following suggestions to check the result:
Click Tools | Options.. | Debugging | General, and uncheck "Enable
property evaluation and other implicit function calls" option. Step
into (F11) the code to find the root cause of the "time out" Restart
debugging
For more information on the Function Evaluation error, please refer
to: http://msdn.microsoft.com/en-us/library/ms234762(VS.80).aspx
Also, we could get more workarounds of Function Evaluation at blog:
http://blogs.msdn.com/greggm/archive/2005/11/18/494648.aspx
Also it may sound weird but have you the latest update of visual studio 2012?
I had some similar issues when running VS2012 with UAC(User Account Control) turned on, and when having installed some extensions, VisualStudio binds to the running w3p.exe process which works as expected under 1 worker process. Upon allowing multiple worker processes to exist studio cannot track all the independent threads and chokes on the data which reads as corrupted memory.
For myself I have the save setup has yours except for the x64 bit. This always gave me headache in programming... Visual Stutio is 32 bit as long as i know and there is surely a reason why... Anyway you sample work and no hang happend... I cannot tell you exactly why it happened but i'm sure it's a 64 bits related environment of development.
I tried provided code.
VS2012 Ultimate works fine on debug settings and on release setting.
I tested on two differents PCs (desktop and surface Pro)
I also forced x86 setting instead of AnyCPU.
Here is my output for the test application :
http://beehiver.jurion.me/debug%20working.png
I recomend complete uninstall all VS and ALL versions of .net and reinstall. It seems to be a problem on your laptop.
I had the same problem. I suppose its more to do with the hardware configuration. I recently upgraded from 4GB ram to 8GB with Vs 2012 and have never been able to replicate the problem. I used to consistently get this error with the earlier Hardware config.
This Problem happens when your code is waiting for some previous threads to finish there execution,also try to delete .suo file then restart visual studio
This may be related Console.ReadKey() problems/bugs.
http://blogs.microsoft.co.il/blogs/dorony/archive/2012/09/12/console-readkey-net-4-5-changes-may-deadlock-your-system.aspx
Does the problems persist if you use a different method of "pausing?"
There are also some disadvantages of VS. For example, if you open two VS at the same time, while you are writing code, it sometimes get into no response and showing "Saving auto recovery Infomation"
Visual Studio 2010 kills (there is no other word) data in one of the arguments of the function in the unsafe block.
What could cause this error? The following message shows by the debugger.
Cannot obtain value of local or argument as it is not available at this instruction pointer, possibly because it has been optimized away.
Go to Project Properties and under Build Make sure that the "Optimize Code" checkbox is unchecked.
Also, set the "Debug Info" dropdown to "Full" in the Advanced Options (Under Build tab).
Also
In VS 2015 Community Edition
go to
Debug->Options or Tools->Options
and check
Debugging->General->Suppress JIT optimization on module load (Managed only)
If you compile with optimizations enabled, then many variables will be removed; for example:
SomeType value = GetValue();
DoSomething(value);
here the local variable value would typically get removed, keeping the value on the stack instead - a bit like as if you had written:
DoSomething(GetValue());
Also, if a return value isn't used at all, then it will be dropped via "pop" (rather than stored in a local via "stloc", and again; the local will not exist).
Because of this, in such a build the debugger can't get the current value of value because it doesn't exist - it only exists for the brief instant between GetValue() and DoSomething(...).
So; if you want to debug... don't use a release build! or at least, disable optimizations while you debug.
In visual Studio 2017
goto Debug->Option then check Debugging->general->
and check this option
I just ran into this and I was running under Release build configuration instead of Debug build configuration. Once I switched back to Debug my variable showed in the watch again.
For web applications there is another issue which is important and it is selecting correct configuration during application publish process.
You may build your app in debug mode, but it might happen you publish it in release mode which omptimzes code by default but IDE may mislead you since it shows debug mode while published code is in release mode.
You can see details in below snapshot:
I have faced the same issue and the solution for me is change Solution Configuration from Release to Debug. Hope it helps
When I was faced with the same problem I just had to clean my solution before rebuilding. That took care of it for me.
Regarding the problem with "Optimize code" property being UNCHECKED yet the code still compiling as optimized: What finally helped me after trying everything was checking the "Enable unmanaged code debugging" checkbox on the same settings page (Project properties - Debug). It doesn't directly relate to the code optimization, but with this enabled, VS no longer optimizes my library and I can debug.
In my case, I was working on a web api project and although the project was set correctly to full debug, I was still seeing this error every time I attached to the IIS process I was trying to debug. Then I realized the publish profile was set to use the Release configuration. So one more place to check is your publish profile if you're using the 'Publish' feature of your dotnet web api project.
I found that I had the same problem when I was running a project and debugging by attaching to an IIS process. I also was running in Debug mode with optimizations turned off. While I thought the code compiled fine, when I detached and tried to compile, one of the references was not found. This was due to another developer here that made modifications and changed the location of the reference. The reference did not show up with the alert symbol, so I thought everything was fine until I did the compilation. Once fixing the reference and running again it worked.
As an additional answer for those experiencing this issue when debugging an Azure websites' web app:
When deploying from GitHub, for example, the code is compiled in Azure server optimized by default.
I tell the server to compile in a debuggable way by setting SCM_BUILD_ARGS to /p:Configuration=Debug
but there are more options. See this:
http://azure.microsoft.com/blog/2014/05/08/introduction-to-remote-debugging-on-azure-web-sites-part-3-multi-instance-environment-and-git/
In Visual Studio 2017 or 2015:
Go to the Solution right click on solution then select Properties-> select all the Configuration-> Debug then click OK.
After that Rebuild and Run,this solution worked for me.
Had the same issue before with a WPF application and all the solutions here did NOT solve the issue. The problem was that the Module was already optimized so the previous solutions DO NOT WORKS (or are not enough to solve the issue):
"Optimize Code" checkbox un-Checked
"Suppress JIT optimization on module load" checked
Solution configuration on DEBUG
The module is still loaded Optimized. See following screenshot:
To SOLVE this issue you have to delete the optimized module. To find the optimized module path you can use a tool like Process Hacker.
Double click your program in the "Process panel" then in the new window open the tab ".NET Assemblies". Then in the column "Native image path" you find all Optimized modules paths. Locate the one you want to de-optimize and delete the folder (see screenshot below):
(I blurred my company name for obvious reasons)
Restart your application (with check box in step 1 correctly checked) and it should works.
Note: The file may be locked as it was opened by another process, try closing Visual Studio. If the file is still locked you can use a program like Lock Hunter
Check to see if you have a Debuggable attribute in your AssemblyInfo file. If there is, remove it and rebuild your solution to see if the local variables become available.
My debuggable attribute was set to: DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints which according to this MSDN article tells the JIT compiler to use optimizations. I removed this line from my AssemblyInfo.cs file and the local variables were available.
In Visual Studio 2012:
Go to the project properties -> Debug -> Uncheck "Enable the Visual Studio hosting process"
I had the same issue. Tried all the above and found I also had to delete everything inside {PROJECT_ROOT}\bin\Release\netcoreapp2.2 and {PROJECT_ROOT}\obj\Release\netcoreapp2.2 for my project. Its definitely releated to publishing because although I use Deployment tools / bitbucket on my Azure Web App, I did try the Build >> Publish >> Publish to Azure because I wanted to inspect which files were actually deployed.
I am new to WPF and .net. I have a WPF app which someone else had written earlier and AFAI remember it was working just fine some time back. But today i see this mysterious error when trying to build the app and run from debugger :
Exception : "Could not find file 'D:\xxxx\bin\Debug\xxx.vshost.exe.config"
I am able to run the generated exe from outside debugger. I am getting the mentioned exception ONLY when trying to debug from VS2008.
First try doing a clean/rebuild. Also try closing Visual Studio and deleting the debug folder completely, then restarting and rebuilding.
Assuming that doesn't do it: to solve your short term problem, try going to the properties of your project, then to the Debug tab, and uncheck "Enable the Visual Studio Hosting Process". This should remove all reliance on the vshost.exe and the config file that gets generated for it. If the error above is your only problem, that should at least let you run in debug mode.
I'm guessing this is a locked file, permission problem, of file corruption problem. I've never heard of anyone having problems with the VSHost except on really slow machines.
I'm not sure what is the reason for the exception but I figured how to fix it.
Basically I had enabled "throw" checkbox under debug->exceptions, and that was what started the problem. Still don't know why vshost.exe looks for a config file by default.
I have faced same problem, It comes when we migrate our code from vs2005 to vs2013 or vs2015, for resolving this problem go in your bin folder in vs solution there you will see vshost.exe reference is missing, remove all reference related to vshost, then rebuild your application. :)
I saw previous answer on stack overflow, so my suggestion is
1. don't try disabling visual studio hosting.
2. don't try to build solution in release mode.
these both will not work.