I have recently changed from web site model to a web application model. One change that i noticed was that in a web site, while i was running the site on my browser locally, i could make changes to the .cs files and just refresh the browser for the changes to take effect.
However in a web application the .cs files seem to have a lock which does not allow me to edit the .cs file without stopping the debugging.
This gets kinda lengthy since i have to stop and run again instead of making changes on the fly.
Is there any debug setting to get around this?
Thanks in advance.
Here is my current Edit and Continue window with the current settings. Do i need to change anything here?:
You can modify the code in a Web Application while the code is paused. You'll need to set a break point above the line of code you wish to change. Execute the code to reach the break point, and then while you are stopped at the break point you can modify the code. The once the modification is done you can resume execution.
There are certain things you cannot change while paused like this, like adding in a new method. If the change cannot be accepted while paused Visual Studio will tell, however, it won't tell you what exactly is doesn't like.
The feature you are looking for is "Edit and Continue" and should be in Debug>Options and Settings>Debugging>Edit and Continue. This doesn't give you the complete flexibility to change anything you want but does allow some basic changes.
Related
Recently started a new project is VS2019 and "Edit and Continue" doesn't seem to be supported. By this I mean that I've enabled the various settings for it to work based on what I've found online and it simply doesn't seem to be possible.
Is this something incredibly daft that I'm doing or not doing, or does it just not work in VS2019 and I should go back to VS2017? Thanks.
Immediately after running in debug mode, edit any line of any file to get this:
Is this something incredibly daft that I'm doing or not doing, or does
it just not work in VS2019 and I should go back to VS2017?
The premise of Enable Edit and Continue in C# is that you should set a breakpoint in that function or just in the Page_Load function. And when you do some code changes or any others,you should move the cursor to the changes, and then VS will apply these changes while debugging.
Besides, when you do these changes and click Continue, these changes will be applied in the current debug process but you can not re-execute the breakpoint at the same time.
Solution
Set a breakpoint at the beginning of the method you want to debug. And when you write some changes later, please move the cursor into the changes so that the changes will be applied.
Then you can see the successful message about this.
Note that these changes are stored in a temporary repository for debugging purposes only and are not built into the output file at the same time. They are only built into the output file when you stop and restart debugging. And this is quite different from the C++ mode.
Hope it could help you.
I have written a rather large application running in the background, doing dome stuff and processing some data.
Now the problem is, for some time the application runs fine. But when I check a day later for example the Backgroundworker of my application seems to loop or stuck. There is no error message and the UI of the application is still running fine. It just stops processing data.
Specifically for this case I added a simple website for myself where the Backgroundworker reports the current DateTime. So when the DateTime on the website is somewhat current I know it is running fine. But when it's in the past I know my application is stuck.
The issue comes after a undefined time. It can be 10 minutes or 90 Hours.
Now for debugging: Is there a way in Visual Studio that I can see where the application currently is? That would make debugging a whole lot easier. Otherwhise I would have to set breakpoints on trial-and-error base...
Best regards,
Julian
you have two options:
1.- attach the debugger as it is suggested already and check the code, but if the application runs fine for a long time, it is not the best idea.
2.- log files. Create log files to track your application.
What I would do: I would combine both options. Add log files to check results and when the application reached certain points (to decide by you) and then, once I know more or less where the problem is, use the debugger.
Good luck
Edit:
I fully concur with this answer but would add that you may benefit from making the background worker pass key position information back to the UI as it enters and leaves particular sections so that you can simply interrogate this when you attach. Since the problem can take several hours to manifest itself you could end up with a lot of log file to wade through unless you use a rolling log with limited entries, continuously setting a telltale would at least allow you to know approximately where to put the breakpoint at that moment.
I'm using VS 2012 express to build a "multi-tenanted" website with MVC4. The website itself is all going swimmingly.
In order to ensure separation of concerns, I have a plugin type of architecture, whereby I have other projects in my solution, one for each "tenant" so to speak. This means I can have a core website and just plug in a tenant plugin when required.
This appears to work fine. How it works is that on a build, various files get xcopied into the host site. It's a slight nuisance that a change to a .cshtml for example, I have to build to get the latest, but no matter.
I did also have problems trying to connect the database for the host with the database for the tenant through linq (so that I could have user specific data from the tenant, based on the logged in user on the host), but that is working now.
However, I am now hitting a bit of a road block and it is drastically slowing me down.
Because the files are xcopied, they don't appear to come under the debugger, so putting in a breakpoint on a tenant controller has absolutely no effect.
Does anyone know (or have any ideas) on how to debug the tenant DLL? All ideas would be appreciated. Thank you.
I've done it again... been puzzling over the problem for quite a while and then worked out how to do it.
In the "tenant" project properties, click "Web". CHECK "Override application root URL" and use the same URL as the host website.
Basically, the host is using IIS Express, on http://localhost:51402 the "tenant", even though it is not the main project was using http://localhost:49931 so was not getting connected as the tenant project was not technically being run.
Making it use the same URL by overriding application root URL allowed it to connect.
EDIT
Now, I am not so sure that the above actually solved the problem, partially solved it or was just timing that made it look like it solved it.
Reason being, I had it happen again where it didn't debug. However, hovering over the breakpoint, it said the source was different to what is currently running. This confused me a little.
It seems that when a build happens by clicking the green go button, the post build events that are in the properties are not executed. In the post build, I have the xcopy to copy the files over to the host app.
So, that means I have to build by hand, then run the green button (and build again).
As the questions says, I want to write code or debug an appication in real-time without setting breakpoints or pausing/restarting the application.
For example, when I write a game, I want to see what is happening when I change the code for the calculation of the light effects or the AI of the enemies immediately, while running the game on my second monitor.
Update:
Ok, it seems that you guys don't understand exactly what I want.
I want Visual Studio to be more like a WYSIWYG editor...make changes or add new code and see instantly what has changed in my application, without the application to pause it's work.
Update:
I saw this feature in this Video with Java in Eclipse (go to 14:30, where he changes the light effects of the game without stopping it.)
Sometimes. Check out the Edit and Continue feature: http://msdn.microsoft.com/en-us/library/bcew296c%28v=vs.80%29.aspx
Based on the comments, it sounds like you either want a dynamic language (a lot of games are scripted with LUA, or check our IronPython or IronRuby) or you want to dynamically load and reload assemblies, which would require something like MAF perhaps. With that, you could build the bits that you are changing as addins, and then unload and reload the addin assemblies when they change. That seems hacky though, and will likely perform poorly compared to a DLR language.
here is all you want to know abt the Edit and continue feature in Visual Studio:
http://msdn.microsoft.com/en-us/library/bcew296c(v=vs.80).aspx
You can edit the code while debugging, but no instruction will be executed during this time.
If you hit F10, the next instruction will be executed. If you hit F5 the normal execution will continue.
Why not create a resource file with the values to apply. Then have a command you can execute in the app that will reread the file. World of Warcraft has a feature like this. /reload ui
Yes, but unless Edit and Continue is enough for your need you need to design and implement the functionality yourself.
if the change is data driven - just reload the data when some file changes.
if change is in code - consider making that portion of the code to be in separate assembly and dynamically load and rewire the assemebly (may require strongly signed assembly to proper version code). Or dynamically compile code into new assembly (to avoid assembly conflicts in the same app domain).
In all cases you need to figure out how to deal with loosing part of previous state that could be in older objects.
I am designing a basic app with multiple forms I seem to be coming across this problem and it will probably be something stupid.
When I make a change to my main form in design mode (like add a button), the button appears in design mode and I can code it but when I build the program it doesn't show up.
Any ideas?
Clean and Rebuild
Make sure you're you're starting a correct form in Application.Run in Program.cs
Most Important of all ..
Save your changes !
And make sure that the build compiles (it might not compile and not ask you if you want it to run the last successful build).
Check out what Microsoft themselves say:
http://vidmar.net/weblog/archive/2005/02/04/999.aspx
The problem was resolved. Just go to taskbar> build >clean rebuild.
Some questions:
If you change the code-behind, does the debugger stop on a breakpoint you put on that change? Also, declare a dummy variable and check if it is visible through the debugger windows such as "Locals", "Autos", "Watch" or "Immediate"?
Did you tamper with Form's default constructor (add parameters, change visibility, that sort of things)?
The form you are changing - are you positive that it is actually a main form (check the Program.Main)?
Does your form include user controls?
Did you try restarting the Visual Studio?
Did you try a full rebuild?
Did you try manually deleting all bin/obj folders then rebuilding?
Is your project actually selected for building under current configuration/platform (investigate the Build check-box under Configuration Manager)?
Did the project successfully build (check the error log)?
Are you running the same configuration/platform that you are building? Are you running the same project that you are building?
Ensure the right project is bold in the Solution Manager or check the start-up project in Solution Manager.
Do you happen to use "Start external program" under debugging options?
OK, this is not exactly an "answer", but answering these questions may produce some clues as to where is the actual problem...