Visual Studio breaking without a breakpoint in a VB project? - vb.net

Running a particular project in Debug, Visual Studio is always stopping at the Public Sub New() line in my main form (it's an older project, so the code is within a autogenerated region in the .vb file rather than a .designer.vb file). No idea why this is happening and it's becoming a headache. It doesn't happen in any of my other VB projects (or running under Release). I can just hit F5 and it continues as normal.
Things I have tried:
Debug > Delete all breakpoints
Deleting the .suo file
I should note that both before and after doing the above, there is no breakpoint symbol next to the line. The execution just pauses and the line gets highlighted with a yellow arrow, as with a normal breakpoint line.
Why would VS be breaking at this opening line even without any breakpoints? I'm pretty sure I deleted the relevant files, so I would guess there's a VS setting I can't seem to find (but if it's a setting, wouldn't it affect other projects as well?).
Also, there are multiple developers working on this project. I am the only one this happens to.

The issue was that "Enable Just My Code" was turned off in my debug settings.
I'm still not entirely sure why that caused it to break at this particular line without a breakpoint attached (other projects don't break here, even my fellow developer didn't have this issue after matching his settings with mine and debugging the same project...), but after checking this option, it no longer breaks at that first line.

Related

Values cannot be null. (Parameter 'baseName')

When trying to open the form deisgn it says values cannot be null. (Parameter 'baseName'). I still can run the system without error. Dont know how to fix it and have to change some gui design. Help me its for my school tnx
I had this problem this morning and a few hours later I decided to just start over and copy the code from the old project to the new empty project. Everything is working in the new copy of the project. I copied from old to new by drag-n-drop. I copied all the UserControls before I copied anything that uses them, and built, then copied over the remaining things, and went through all the errors caused by the change in name of the top-level Namespace.
(All of the Namespace errors were in the .Designer.vb files. I have posted elsewhere "never edit those files by hand unless you know what you are doing." This case was one of the rare exceptions.)
I had the OP's problem that when I tried to open a Form in the designer, I got the message
Value cannot be null. (Parameter 'baseName')
It didn't matter if I tried to open the Form in Solution Explorer or by pressing Shift-F7 in the Form's code window. However, sometimes Shift-F7 resulted in a wait cursor followed by silence - no error message.
Like the OP, the project did run without errors (well, same bugs as before but you know what I mean).
Another symptom: If I launched VS and tried to open the Form designer before Intellisense was initialized, instead of the other error, the window that should show the layout of the Form showed this instead:
File path: full path of the file I was trying to open
Frame GUID: 2c01570-c72c-11d0-88c3-00ac0c9110049
Frame mode: VSFM_MdiChild
Error code: 0x80131500
There are no MDI containers in my project. It's a reference to VS 2019.
The same error occurred in every Form and UserControl in the project.
The same error occurred in any new Form or UserControl that I added to the project.
The error did NOT OCCUR in any and all other projects built in VS 2019 with a target of .Net 5.0
The error DID OCCUR with the same project on another machine running a clean install of a later version of VS 2019.
Attempts to Clean Solution or Clean Project failed, with a generic error message, it was something like "Clean Project failed."
Nothing about these problems appeared in any event logs.
Every time the problem happened, when I shut VS, one process was left running (per TM).
Here are some other things I did to try to suss it:
Ran a repair install on VS 2019 and reboot.
Opened each and every VS-generated file in another project and compared them line-for-line (most are text) against the corresponding files in the broken project. No data-independent differences.
Searched exhaustively with 3 search engines and many terms for someone else that posted about this error. This is the only post I found.
Deleted, renamed, or moved files that are automatically generated by VS, including some Json files, XMLs, and caches.
What I did not try:
Roll back the code to the most recent commit.
Uninstall VS 2019 completely, reboot, install VS 2019 as if an initial installation.
Just had the same experience. I took me a while before I got everything to work again, but the clue in my case was that I had added a new item to my project, and for some reason I had managed to delete the file name in the process so the only thing left was 3 new files with only the extensions .resx, .cs and .Designer.cs
I quickly deleted the ".cs" file but forgot the rest.
Suddenly I was unable to open my main form in the designer - and the “Value cannot be null. (Parameter 'baseName')” started to appear. It was only affecting my main form.
I tried almost everything described above except the reinstalling part.
But then I deleted ".Designer.cs" and ".resx" from within visual studio (Solution Explorer), and then the problem went away.
I started getting this error after using a hack to support generics forms (e.g. MyForm). The designer generated a file:
MyForm.resx
which worked for design time (even with the form being generic) but crashed at runtime. My hack was to rename the .resx file:
MyForm`1.resx
However that is when the Designer stopped working. It stopped working for ALL forms/user controls in entire solution (not just the generic I was experimenting with). I assume there is some kind of process that crawls all the resx files whenever you open any Designer and that is the source of the Exception.
I was able to work around the issue by:
Renaming the resx back to its non generic title (i.e. MyForm.resx)
Restarting visual studio.

Debug Design Mode in Visual Studio not breaking

So I am currently unable to open a Form and get the following error:
System.ComponenetModel.Design.ExceptionCollection was thrown.
or:
The designer loader did not provide a root component and has not indicated why
Usually the way to solve this is to open another instance of Visual Studio with the same project, attach the debugger to the other Visual Studio and try to open the form.
However, that does not seem to be working. The debugger does not break when the error is hit, and attempting to 'Break All' at any other point does not show me the source code and just the screen saying:
Your app has entered a break state, but there is no code because all threads were executing external code (typically system or framework code).
Attempting to put break points also results in:
The breakpoint will not currently be hit. No symbols have been loaded for this document
Am I missing a setting? Incorrect Setup?
I have been battling this for half a day and thoroughly search the interwebs with no luck thus far. My designer is also fairly complex and lengthy which means trial and error is an absolute last ditch option.
First attempt to resolve:
you may have tried it already. Right click the Solution in solution explorer, click "clean solution", this deletes all the compiled and temporary files associated with a solution.
Do a rebuild of the solution and try to debug again.
Second attept to resolve:
Start debugging, as soon as you've arrived at a breakpoint or used
Debug > Break All, use Debug > Windows > Modules. You'll see a list of all the assemblies that are loaded into the process. Locate the one you want to get debug info for. Right-click it and select Symbol Load Information. You'll get a dialog that lists all the directories where it looked for the .pdb file for the assembly. Verify that list against the actual .pdb location. Make sure it doesn't find an old one.
In normal projects, the assembly and its .pdb file should always have been copied by the IDE into the same folder as your .exe. The bin\Debug folder of your project. Make sure you remove one from the GAC if you've been playing with it.
third attept to resolve:
Disable the "Just My Code" option in the Debug/General settings.
there are might be other causes to your problem, i picked them from here. you may try other solution to try resolve your issues. Fixing "The breakpoint will not currently be hit. No symbols have been loaded for this document."

Visual Studio cannot start debugging

I'm working through a project in Visual Studio 2013 and I got the following error: "Visual Studio cannot start debugging because the debug target is missing". I've tried changing the build output path under Project -> Properties but it still doesn't work. So what gives?
Check your code and make sure you aren't missing a curly bracket anywhere. If one was accidentally deleted, moved, or misplaced, it causes this error among MANY others depending how critical the placement of the curly bracket is in your project.
^
I just recently had this problem in a project I was working on. I had highlighted to delete a section of code, and it took out a curly bracket with it. Unnoticed by myself, it took me a few days to finally realize that's what happened.
You won't get an error from the bracket missing, so it's stupid in itself and impossible to find at times.. but I had 51 errors, 7 warnings, and that "can't start debugging because the debug target is missing" error when I attempted to run the program, after the curly bracket went missing.
It's not to say that you might not have another issue going on that is causing this, but the curly brackets can wreak havoc if they aren't precisely placed. So it's worth checking into that before getting too extreme in options to "fix" the start error.
For future reference if this problem occurs again. Good luck.
Possible VS 2019 Solution
Right Click on Solution Properties
Go under Common Properties> Startup Project
Set Single startup project
Right Click on Project Properties
Click Application
Set Application Type to Windows Forms Application or Console Application or Windows Service
Click Startup Object
Set to Anything Other than (None)
Left Click on Project Properties
Set Copy Build Output to Output to True
Then Run
Hopefully that works for you

Why doesn't Visual Studio debug my VB.NET application?

I recently have encountered a weird issue with my project: as soon as I click debug and it builds the project, it stops debugging. There isn't any error message, or anything else that comes up, including the form itself.
I've tried messing with the settings: no splash screen and I've even changed the startup form to a blank Windows form. What could be causing this problem? Is it Visual Studio or my code?
Probably your program is exiting normally. Set a breakpoint at the first statement to be executed, press F5, then single-step through the program until you get to the last statement executed.
If the first statement is never reached, then one of two things probably happened:
You're mistaken about which statement is executed first, or
The program is terminating during initialization, probably because a class constructor is exiting the program either normally or abnormally.
A few ideas:
Use Debug->Exceptions, and check all the checkboxes so you break when an exception is thrown.
Use Debug->Step into to step into your code.
Then you can use Step Over and Step Into (look at the menu for the keyboard shortcuts)
I found a solution, but not the problem.
How I fixed it:
I just created a template for each form, created a new project, and imported everything into the new project. One thing that I found useful is in the new project is to add an existing item (CTRL + D), and group select (maybe, don't know if you can) and select all the non-code/form/designer/etc. files (like text files or images) and then import them.
I have found a possible solution after I had the same problem.
You probably have more than one project in your solution (The main project, plus an "InstallShield" project",perhaps)
Make sure you have the main project set up as "Startup Project".
In the Solution Explorer, right click on the Main Project and select "Set as Startup Project".
Everything will then run OK.
If you get the error like: "The debug mode is program but there is no program specified....." Go to Solution Explorer then Right Click on main project's name and Click on Set as StartUp project. You can debug your program.

Debug Triggering Build Errors (File Not Found) and Antivirus Program, Visual Basic (V11 2012)

I made some changes in my code and when I went to debug my program I got a build error. The error prompted my anti-virus software (Avast) to block my program as a "suspicious file".
Visual Studio returned this error:
Error 1 Could not copy the file "obj\Debug\CopyFile.exe" because it was not found.
Here is a run down of the events that occurred before this error began to happen.
Added new menu item to menu strip.
Replaced instances of radio button references in the code with the new menu items.
Ran a debug, program worked fine, until I clicked a button.
Found the remaining instances of radio button references in the code and replaced them.
Ran a debug, program was working fine. Exited debug.
Deleted the old radio buttons from the GUI. (They no longer had any references in the code.)
Tried to debug, received an error, antivirus software blocks program exe file as suspicious.
Error Could not copy the file "obj\Debug\CopyFile.exe" because it was not found.
What did I do to the code to cause this? Did I possibly delete some other area of the code on accident and I do not know? I can't see why my program won't debug.
Why don't you simply tell to your antivirus software to do its business in some other places than your working directory? ( Exclude Paths ) and ignore every action done by Visual Studio executables ?
By the way, this is one of the first things to do to get better performance when working with a complex IDE like VS that can create, move, delete thousands of files when working.
If I remember well, the AVAST has its exclusion list in File System Shield, Expert Settings, Exclusions