Blazor WASM - Visual Studio Debugger - Getting Uncaught The name does not exist in the current context - visual-studio

I'm trying to debug in Visual Studio 2022 Preview 6.0 (the last) a Blazor component (NET 7) but when I assign a variable to another one, I don't get an error but I cannot see the variable content if I move the cursor over the variable name and in watch panel I get the following error:
The debugger continues and it is not raising errors but the variables stopped been filled.
I've tried different suggestions from here with no success:
delete .vs folder
delete all bin/obj folders
clean the solution
What else could I try?

Related

(FORTRAN 90) Visual Studio Watch not displaying variables, although they appear in Locals for debug mode - identifier is undefined

I have just reloaded a project on visual studio (2019) that I was using a few days ago and the watch function in debug mode does not appear to be working anymore. I have normal debug flags (no optimisation and full debug information) and as far as I can remember I have not changed anything from the last time that I used this project (when the watch function was working normally). Apart from this, the code runs normally and without bugs.
When the code hits a breakpoint, although the local variables appear in the locals tab, when trying to view variables in the watch 1 tab, all variables (even those defined locally) appear as identifier "..." is undefined. Hovering over variables has also stopped displaying their value.
I have tried restarting visual studio, clean and rebuild, restarting the PC, opening a different project and creating a new project, but the problem persists for all of these.
Maybe there is a switch that I have changed accidentally since the last time it was working? Thanks in advance!
I managed to fix this by using the visual Studio installer and using the repair option under more->Repair. After the repair and a restart, the issue was solved.

Visual Studio 2019 break point is getting hit

I am working on Dotnet Core + Angular application with Visual Studio 2019. After publishing code in release mode and deployed on IIS. When I changed the code to debug and tried to debug something the breakpoints are not getting hit on any controller. Does anybody ever faced this problem, it would be helpful to have any solution on this. Here is my project properties
Visual Studio 2019 break point is getting hit
This is indeed a very strange behavior and I suggest you could try these suggestions to troubleshoot your issue:
Suggestion
1) Right-click on your project-->Properties-->Build-->Advanced-->change Debugging Information to Full.
2) make sure that you use IIS Express with Google Chrome or change to use IE to debug your project
3) Tools --> Options-->Debugging-->Symbols--> select Microsoft Symbol Servers-->Click Load All Symbols
4) close VS Instance, delete .vs hidden folder under solution folder, bin , obj folder and then restart your project to test again.
Update 1
Based on your issue, JS sent request to Core and could not enter the breakpoint, you can try these steps:
1) enable option Javascript Debugging for Asp.Net(Chrome,Edge and IE) under Tools-->Options-->Debugging-->General
2) If you try to debug js on cshtml, you should move these js into a single javascript file and then reference such js file in cshtml. You can refer to this link.
Hope it could help you.

Visual Studio has stopped working on clicking Go To Definition (F12)

My Visual Studio crashes while pressing F12 (Go To Definition) after fresh installation.
But its working if i log on using different profile on same machine. i tried resetsettings, resetuserdata, resetpkg etc also deleted visual studio folder from %user% folder but issue still persisting
Note: Goto Definition is not working only on type or method which is referred from other assembly or Dotnet framework types(such as Form, Console etc)

Visual Studio 2010 Build Fails to File Copy Error

I'm building a project in Visual Studio 2010 and the build fails because it cannot copy the assemblyname.dll file from obj to bin folder. The exact error message is:
Error 7
Unable to copy file "obj\Debug\AssemblyName.dll" to "bin\AssemblyName.dll". The requested operation cannot be performed on a file with a user-mapped section open.
I think this is because the previous file in bin-folder is not accessible. When I try to delete the file manually, I get an error "The action can't be completed because the file is open in another program". If I try to see what application locks the file with Unlocker, I don't get any results (No Locking handle found).
If I restart Visual Studio, the error goes away but happens again after a build or two. Goes without saying that this is seriously slowing me down. Any advice how to start solving this?
VIsual Studio 2012 on Windows 8. I was receiving the same error message on my project. Restarting Visual Studio or cleaning the obj folder manually did not help. Finally I closed all open files (Windows -> Close All Documents) and the problem went away.
This behavior was due to a newly installed Visual Studio extension called Visual Studio Achievements (http://visualstudiogallery.msdn.microsoft.com/bc7a433b-b594-48d4-bba2-a2f24774d02f)
I noticed that the .pdb file was locked by FxCop (using Unlocker) and I think that the Achievements -extension uses it. After disabling the extension I've no longer got the error mentioned above.
This bug has been fixed in recent versions of the extension (>1.7). It was released as a beta, btw...
This behavior of VS happen very often even on my computer (and on computers of my coworkers).
In my experience it happen more frequently when:
I have some form opened in design when i compile
I stop the execution od the application by pressing the "stop" button
in VS instead of exiting the application
So, closing the form in design before compile, and exiting the application instead of stopping it, somewhat mitigate the issue... but it still happen :-|
My computer is Win 7 x64 SP1 with VS 2010 SP1, 8Gb ram, and no swap file
Platform: Windows 8 Pro, Visual Studio 2012
I found that I receive this error when I am accessing the folder in Windows Explorer.
I was creating PDF documents with Visual Studio 2012. To review the sample document I would right click in Solution Explorer and use Open Folder in File Explorer.
On Windows 7 I would get a SYSTEM.IO error if the actual PDF document was open in Adobe Reader which is expected. With Windows 8 I found that I receive the above error if I have the folder open. I suspect there is a conflict with the Windows 8 preview.
If I close the folder and run the program it works fine.
Check if you open the dll in visual studio.
I open the dll in visual studio and this error happen!!

Visual Studio 2010 Crashing on Solution Load

I've seen a lot of similar questions, but I don't think I'm duplicating. Here's my situation. I have three solutions that I'm working with. A works fine, but when I try to load B or C, VS 2010 crashes shortly after loading the solution, particularly after I try to open a file form my solution explorer.
What I've tried:
Disabling all add-ins and macros vis tools -> options -> add-in/Macros Security then unchecking the two relevant check boxes
Deleting my .suo file.
Rebooting my machine
Running VS 2010 as Administrator
Here's the error from my event viewer
Faulting application name: devenv.exe,
version: 10.0.30319.1, time stamp:
0x4ba1fab3 Faulting module name:
cslangsvc.dll, version: 10.0.30319.1,
time stamp: 0x4ba20c61 Exception code:
0xc0000005 Fault offset: 0x0024b651
Faulting process id: 0x1408 Faulting
application start time:
0x01cbddd78972584a Faulting
application path: c:\Program Files
(x86)\Microsoft Visual Studio
10.0\Common7\IDE\devenv.exe Faulting module path: c:\Program Files
(x86)\Microsoft Visual Studio
10.0\VC#\VCSPackages\cslangsvc.dll Report Id:
cd32c352-49ca-11e0-b3d8-0026b9c2aa7e
EDIT
This is a solution with two projects -> a win forms project, and a console project. Both in C#
RESOLUTION
It turns out there was some silly (stupid?) code in my solution that was making VS go crazy. The code should never really have been in there; it was just something I wrote playing around for no good reason.
On a related note, if you ever want to be evil to someone you don't like, insert the following code into their solution somewhere, and sit back and watch the fun:
namespace System {
public partial class Boolean { }
}
I put this code into the first solution, and watched it crash after building. I ass-umed the crash was unlreated to the code I had just written and proceeded to put it into my second solution to see if it was possible to extend Boolean without extension methods, then got angry that VS was still crashing. That code could be capable of crashing VS never crossed my mind.
Try disabling all extensions via tools -> extension manager. I've had extensions crash visual studio only in certain projects.
Alternatively try running VS in safemode: devenv.exe /SafeMode
I tried the following in the order i performed:
devenv.exe /resetsettings , devenv.exe /resetskippkgs (did not work)
devenv.exe /safemode (told me that product version cannot open .ccproj types. But no counter solution worked)
renamed the .user, .suo files (did not work)
Installed any and every service pack for VS2010 even if they were remotely related to C# development.
"Reinstalled" VS2010 using the 'repair/reinstall' option(did not work)
Uninstalled VS2010 and then installed (this was my solution even though many of them tried this and failed. Might be because this was my last resort.)
If it's a C++ project, try deleting any PDB files that are hanging around - these sometimes get corrupted and cause crashes.
I encountered a similar problem, VS2010 crashed upon loading a specific solution.
It turned out to be an incomplete line in the code that caused VS2010 to run amok. When I commented the line out, everything was ok.
The line in question was:
getCommonResourcesDirectory([out, retval] BSTR* );
A crash can also happen in Visual Studio 2010 during solution load if/when the testing tools (Test View window etc.) load a DLL that throws an exception during initialization.
My specific case was a C++/CLI test project where a global variable was throwing an exception during construction of it, that constructor being called during DLL INIT. (It was the std::tr1::regex class constructor throwing due to invalid pattern string passed to it.)
This was quite a subtle problem because you don't expect your code to run until you execute the test; but in the case of ctors of C++ globals it is being run by the IDE immediately after build and on solution load.
I suspect Visual Studio 2010 test manager component isn't wrapping the Dll load call in a try/catch block where it might.
Set the form that crashes Visual Studio as the main form to load. Then start the form in debug mod from the DEBUG menu.
I realize this is an old post, but I came up with another solution today as I was working on the same issue. In my case, VS was trying to open a source code file using the CSharp Form Editor instead of the CSharp Editor.
When that happened, the code started to run (I saw my splash screen) but an error occurred (I saw my error message about not finding some hardware) and the resulting error closed VS. Trying to reopen the project would have VS open the *.cs file again, creating a frustrating loop of crashes.
I was able to open the project after deleting the *.suo file. Then in Solution Explorer I right clicked the code file and selected Open With. In the dialog I changed the default and everything was fine, including seeing the hardware that I was not finding before.

Resources