the breakpoint can not be inserted at this location - visual-studio-2010

When I try to set a new breakpoint in my Asp.net project I have this message "Breakpoint can not be inserted at this location" in the bottom of the page
This message appears only in this projetc, I tried with other projetcs it works. I was able before to add breakpoints.
I tried to repair visual studio but it doesn't work, I think it's related directly with the projetcs since it work with others
Thanks

In my case, a method at the bottom (line 1000) of the file had this issue.
Fixed by moving the method up to the begin (line 100) of the file.

Related

MSI Installer error 2810 interrupts installation, but still let's it finish with no problems

I have a setup created that installs an application, and still does, but it started giving a strange warning at the end out of the blue. So, when the installation process finishes, the following appears:
The installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 2810.
So I checked 2810, and it says:
On the dialog [2] the next control pointers do not form a cycle. There is a pointer from both [3] and [5] to [4].
I was not changing anything in the "User interface" or "Custom actions" so this came unexpected. Also the installation completes if you just click ok and everything works fine, it just doesn't look good from a user perspective. Any help or similar issues encountered?
Control_Next: This is probably just the tab-order for the controls on the dialog. See the Control_Next column of the Control Table. You need to find a way to visit each control of the dialog in sequence and sort out so there are no loops or double links.
TAB Order: In the dialog in question (launch the setup and get yourself to the FinishedForm dialog), try hitting TAB repeatedly to see what happens. It might work, but you might see the control order being messed up so TAB unexpectedly moves around the dialog haphazardly going in "reverse" selecting a control already visited or similar.
Fix: Fixing this depends on what tool you are using. You can "test fix" directly in the final MSI using ORCA or a similar tool to edit the Control Table directly (just open the MSI and do it). The real, lasting fix will be in the sources used to compile the setup. WiX, Installshield, Advanced Installer, Visual Studio Installer, or whatever tool you are using. Exact fix depends on tool. A screen shot of the Control Table content could give us the clue we need.
(combining comments into an actual solution)
If you're using the common script EnableLaunchApplication.js within a Visual Studio Installer project, then the 2810 error code is most likely caused by a single line within that script, along with a recent Visual Studio update.
The fix, as mentioned by user Olaf:
in the EnableLaunchApplication.js I changed the line INSERT INTO 'Control' ... and replaced the value 'CloseButton' with 'Line1'. – Olaf Jan 9 at 14:16
With the entire corrected script linked by user Shangwu:
Here is the latest JavaScript without causing error 2810. stackoverflow.com/a/59888956/6079057 – Shangwu Jan 24 at 0:49
The underlying reason can be found in answers by Adam cosby and Stein Åsmul.
I actually had the same problem and my Control Table was over populated just as you mentioned above. I beleive it was related or at least co-incided with the Visual Studio update from 16.3 to 16.4.2. For me I used the Visual Studio Installer too and on the older version of VS it compiles fine but the same commit number on a different machine with the new version it causes the same issue and the Control Table has a lot more Control_Next entries populated. Still not sure how to fix yet though in the source.
Edit:
Ok I discovered the problem. The issue with it now populating more of the Control_Next I can only put down to a the update. However, the automatic entries put in by Visual Studio would have been fine but I realised we had the MSI launch the exe after install using this: Visual Studio Installer > How To Launch App at End of Installer technique.
That meant I was injecting and modifying the Control_Next and thus caused the loop of Control_Next to be non circular. It is worth noting that the Control_Next is basically the tab order of the MSI screen and it must always be closed (imagine the tab without anywhere to go).. Anyway, it was ultimately caused by us modifying on the post build process the Control_Next to add in the checkbox. After working out the last entry on a build without our code running i just modified the original last entry and then slotted in out one there. Now it works fine.
Hope this helps

Visual Studio Not Capturing Entire Line

I am asking the question in MVC as that is the framework I am using for this issue, but it could be a Visual Studio issue as well.
We are using Visual Studio 2010 / MVC 4.0 for our application and all of this is while running in DEBUG mode to test the code and get it working.
I needed to add a new AccordionPanel to a section of our website. We have about 10 total Accordion Panels on this page and all of this worked with no issue. Between the third and fourth panel, I needed to add a new panel, so I added the below code:
#using (Html.BeginAccordionPanel("Cancelled Reason", "pnlCancelledReason"))
{
#Html.Partial("~/Views/Project_View/TrackingInformation/_CancelledReason.cshtml", Model)
}
What is happening is that this new section does not appear on the page. What I found odd is that if I add some HTML on the end such as:
#using (Html.BeginAccordionPanel("Cancelled Reason", "pnlCancelledReason"))
{
#Html.Partial("~/Views/Project_View/TrackingInformation/_CancelledReason.cshtml", Model) <b></b>
}
and refresh the page, this new section appears until I stop debugging and restart, then it no longer appears.
What is very odd about this is: when I step through the code and Visual Studio hits the "#Html.Partial" line, the yellow box that highlights your current row, only captures about 75% of the line above (stopping around the dR in the file name). If I readd some HTML to that line and refresh, the yellow highlighted box for current line now captures the entire line up to the area between , but since it captured all of the relevant code, the panel appears until I stop debugging.
I can't seem to figure out what causes this? If I copy any other panel section and paste it in the same location, the same issue occurs, so it doesn't seem to be the code, but something within Visual Studio causing this.
Any help is appreciated.
After spending two days on this and not sure why, but it seems if I remove the “.generated.cs” file from Visual Studio this issue goes away. I didn’t find any articles for this, just figured ‘why the heck not’.
Sorry to have bothered you.

Remove unwanted code in Visual Studio 2010?

When I'm creating a GUI of Windows Forms in Visual Studio, I sometimes happens to double click on a component and get some auto generated code. To remove this unwanted code, I read somewhere, but I can't remember where, to remove this code you shouldn't delete it, it should be done in some other way to prevent future errors. How do I remove this unwanted code in Visual Studio the right way?
Normally, I simply delete the code and nothing bad come out of it. At worse, when you try to build, you'll get an error in the designer.cs saying some code is not found. Simply delete that and everything will work fine.
You can also use Ctrl+Z when you double-click, but it will delete the component you double-clicked on and you'll have to add it again to your form.
AFAIK, the answer is NO. Unless there is some specific add-ins from Microsoft (Which I am not aware off) which enables it.
So, You will have to manually delete the unnecessary code which have been auto generated.
Control-Z - it will remove the event handler registration from the YourForm.designer.cs file and also the method from YourForm.cs file.
A warning box will come up as soon as you press Control-Z, just click yes.
Just remove it from the XAML code. For example, if you double click a button, search for Click="button1_Click" in your XAML and delete it.
If you created a Windows Forms project, go to Solution Explorer and open file file Form.Designer.cs and from function InitializeComponent() delete this line:
this.button1.Click += new System.EventHandler(this.button1_Click);

Microsoft visual studio screen problem

I am having a problem thats not about the code, it's about the screen in Microsoft visual studio 2008.
Actually problem is i created one utility from couple of weeks i didn't opened that utility today i opened (in Microsoft visual studio the screen appearing blank no controls are visible in that.But all the controls properties are there. I tried a lot but i didn't get solution. Last when the same thing happened i created the controls again. Now i don't want to go to create all the controls again. If any one have the solution please help me.
Before screen is like this:
Now its blank (like new page)
From your description I'm not sure if this is a application/code build issue or an IDE issue, what you could try is to reset the settings in visual studio and see if this helps.
You can do this by going to Tools -> Import/Export settings and then following the wizard to reset the settings, you may also want to perform a backup before resetting them (this is also part of the wizard) then they can be restored if this causes you further issues.
I don't have a copy of 2008 available at the moment so some menu entries may be slightly named different.
Hope this helps!
EDIT:
Now there is more information, this looks like there may be a problem with the code in the
InitializeComponent
method of the form.designer file (e.g. if you are using c# this would be something like Form1.Designer.cs and can be found by expanding the corresponding form in the solution explorer), if you remove/comment the lines that say
this.Controls.Add(this.NameOfControl)
(NameOfControl is where you would see your declared controls name)
then you get the behaviour that you are seeing, the controls do not render as they are never added to the forms controls collection but as they are declared you will still see them in the properties drop down and wont be able to add another control with the same name.

breakpoint will not currently be hit, why not?

Sometimes I get the message that the breakpoint will not be hit, and no symbols will be loaded.
The red icon in vs.net changes color, and the debug mode just doesn't work.
what is the reason for this?
You may be running your project in Release mode. If so, then switch to Debug mode
From Visual studio debugging issue with files of the same name by Philip Carney
Do each bullet in the link below ONE AT A TIME, but repeat my steps below with each one you try.
Stop debugging (press red square icon) in Visual Studio
Clean Solution
Build Solution
Tools > Attach to Process (or start with debugging)
Start the program that you're attaching to, and run it such that your code will get hit
If attaching to nunit.exe, then open NUnit and run a test so your breakpoint will be hit
If attaching to w3wp.exe (IIS site), then open your site in the browser and go to the page that will hit your breakpoint
for manage code only - theres a good answer for this problem on the following site:
http://geekswithblogs.net/dbutscher/archive/2007/06/26/113472.aspx
for native + managed code - in the startup solution properties-> Debug tab
make sure that "enable unmanaged code debugging" check box is checked
After trying several suggested fixes for this I did the following to get it working.
Right Clicked my Project in the Solution Explorer and selected "Properties".
Went to the "Web" section and made sure "Start Action" was set to "Current Page".
Spent 3 1/2 hours on that... I'm going to go get a drink now.
I resolved this problem by selecting Automatic:Native Code for the "Attach to" field in "Attach To Process" form
Next to the "Debug/Release" dropdown list, there is another one with "Any CPU/Configuration Manager...". Click "Configuration Manager...", and you will see some of your projects might be in Release mode. Change all of them to Debug.
This can happen if the symbol fiels are different from the assembly (remote debugging), or when there is no "direct path", so the assembly hasent been load, but might be loaded using reflection and loading of the required assembly at run time.
This can also happen if the debugger is not attached to the process for whatever reason. If it's the case, you can always go to Debug - Attach to Process... and choose the right process. Your breakpoints should return to normal once VS determines it can hit them.
What does it say when you hover the mouse over the disabled breakpoint? It will usually tell you the problem. My favorite is the old 'source code is out of date', especially when I'm debugging a DLL. Another favorite is when the file you're looking at isn't the one you're debugging (a copy in another folder?). If it's a case where you can breakpoint a caller routine, but not the callee, stepping into the callee will force VS to open the 'proper' source file and you'll be able to set breakpoints. Confusing, I usually swear at VS at this point, it seems to help.
I had the same problem. Which I know is normally if the build versions are different, and something isn't matching up. I cleaned my project, rebuilt it, and then deployed and that got everything back in-sync.
I do not like to play with knives but the only thing that worked for me involved editing the .csproj file itself. So, unload the project file, edit it by cutting and pasting the three asp.net files so that they are together in the ItemGroup. However, sometimes it is necessary to go further as explained here: http://carnotaurus.tumblr.com/post/4130422114/visual-studio-debugging-issue-with-files-of-the-same - Also, I give a list of other proposed solutions that did not work for me. I hope it helps.
I have tested with both deployed application and service, what I have found out that If the deployed code is different than a code in visual studio then breakpoint will not hit. Even small changes will affect and the breakpoint will not hit. So, It is better to debug the same version which is there on vs code and also in deploy application or service.
To fix this I had to re-create the virtual directory. I'm using Asp.Net 4.7 Framework and IIS Express. Went to Web project > property page > Web tab > clicked the "Create Virtual Directory" button next to Project Url textbox.
I forgot I had clicked this button in my "Main" branch, but then had switched to my "Sprint" branch. It kept running the "Main" code until I clicked "Create Virtual Directory" on my "Sprint" branch.
For me it was giving this because I haven't started the relevant project at start of application , it worked after I added project run on start

Resources