I'm not sure if this is the correct place to ask, but as it's programming related, here it is:
I have a solution with several projects (all .NET/C# based. some libraries, some WPF, some XNA, some portable class library, all together) and I have problems with performance:
While running my project, when I hit restart (Ctrl+Shift+F5) while debugging, the instance stops, VS recompiles all the projects in the solution again, and then it runs again.
When I stop my running instance. Without touching any code (not even spacebar in the code editor), I hit F5 and similarly, it again recompiles the whole solution.
When I'm working in only one of the projects and hit Debug without touching any code in the other projects in the solution, VS, again, recompiles all the projects in the solution.
This creates a real bottleneck as my project normally starts in <1 sec. but it compiles for a few seconds even on SSD. A few seconds don't seem much but I make some very small changes to only one code file and try something several times by running the application again and again, it becomes a real trouble.
I think that if you have your studio setup to always build, it will do so. Make sure you have the correct settings in studio. See below.
I've found out the reason and the problem is solved. I was using BuildVersionIncrement plugin and it was incrementing the build number every time I compile, and Visual Studio was thinking that, because of the change in files, the project was outdated, thus, bebuilding the whole solution. I changed the BuildVersionIncrement settings to increment only on full rebuild, and the problem is solved.
Related
I've been googling this all afternoon and I found any number of people ask the question, and all of the place a few people would answer it with the same things, and then there's a dozen comments by the rest of the world and the OP about how those answer don't fix it. So I'm going to include what I've tried here, and if your solution is to do one of the things I've already tried, I'm going to be very sad.
I have a solution in Visual Studio 2019 that has a class library, a wpf application, and a setup project (using the setup project extension). The WPF app also references a bunch of assemblies of course, but one of those is from another project I maintain in a different solution. I copy/paste the compiled dll after I update it from its own project to this one. Nothing tricky, everything works.
The problem is the installer. If I build everything and then build the installer, it produces an MSI as expected. If I right click on the project in Visual Studio and choose "Install", everything is perfect.
The problem is after I make some updates to either of the code projects, I then build both and build the setup project, and again if I right click to install it's perfect. If I run the MSI though, it doesn't always update the target files. If I delete the target files it will create them with the new ones, but it won't overwrite the old ones correctly.
AssemblyVersion and AssemblyFileVersion are both being incremented each time and are being kept in sync with the "Version" property of the setup project. I tested with these extensively, the new installer that isn't working properly 100% has updated dlls in it with correctly updated version numbers.
When I change the "version" of the setup, it asks to change the GUID for the ProductCode. I say yes, it changes the code. I have also tested without doing this and that makes it much worse as we all know.
"RemovePreviousVersions" is set to "true" in the installer project
If I right click the project and choose "Install" it seems to be 100% reliable at upgrading the existing installation.
If I run the MSI directly it seems to be 100% unreliable and never gets it right.
Side note, it does seem to usually but not always get the WPF application upgraded and the other project dll I bring in if I remember to update its version, but the class library (which is referenced by the WPF application) almost never works.
Has anyone got this to work reliably?
For all the people finding this in the future, here's the final word:
The build project can be inconsistent, this is well documented all over the internet as I have above. You're not doing anything wrong - it is just inconsistent.
Stop trying to solve it if it's affecting your project and move on (I've had a dozen projects before this one work just fine). The consensus seems to be to use WiX, but I'm not here to discuss the alternatives. Personally I am going to embark on the WiX learning curve though.
I have used go to declaration to view the source code of objects/methods that are declared in the other projects within the same solution. It has been worked great. Suddenly, the go to declaration option is not available after I highlighted the method, and I don't see it in the content menu.
Note
1) I always reboot the machine every day
2) I have been working on the same project for the past few weeks. I have been working on the same solution file before and after go to declaration menu is gone
I did make a lot change on the solution. I recompiled the object so many times. Not sure, if I accidentally cause any problem
Right now, I have to traverse to different project in the solution to find the source code. I can also put the break point. Once the program stops at that break point, I can step into the code.
More about the project, many objects/classes and defined in the other projects. Technically, they are external DLL. I know how to debug external dll, but it is cumbersome. Therefore, I include those projects in the solution (actually, the developers at my show include most of them. Then I included more). Go to definition always navigates back to metadata, but go to declaration will go back to the actual code. It is a wonderful tool, but I cannot see it anymore in the past few days.
Any thing I can do to revive this menu. Oh, I did try ctrl-f12. It does not work
Thanks
Ok
I finally figured out what happened. It was resharper that was causing the problem. What happened was I had to change my machine 3 weeks ago. I slowly installed more and more software. Then I applied the product key. Then one day, the go to declaration disappeared. I did not even notice that
Intellisense and code suggestion not working in Visual Studio 2012 Ultimate RC
The above link is the long thread that has various resolutions. Different people may encounter different issues. I have tried various resolutions (restart the visual studio, etc), and none of them work.
Resharper->Options->IntelliSense->General Set to 'Visual Studio native IntelliSense
This one works for me. Oh, you need to get your R# license to have this feature turn on
I am having great problems running the application in the debugger from Visual Studio 2008.
When I'm using vshost.exe, it says:
And when vshost.exe is turned of, it simply states:
Interesting thing about it is that when i do use vshost, debugger is actually started and breakpoint is hit on the first line of the Main().
I tried:
rebuilding the project(s)
removing .ncb, .suo, .user for the projects
repairing Visual Studio 2008
changing the build architecture for the project
... no help there...
Any experience in (trouble)shooting that?
More info: some projects DO work, and one that I have to work on, does not.
I have some ideas such as:
trying to create NEW project, add thing by thing to it and see at what point it will start to miss behave
work it other way around, delete project by item by item to see when it will (if it will) be working OK again.
EDIT (for google, as I see that there are many similar questions on the web):
Errors:
Error while trying to run project: Unable to start debugging.
and
Error while trying to run project: Unable to start program '....\PlayKontrol.exe'
Try upgrading your Visual Studio to Service pack 1, if you haven't already.
Did you restarted your computer? You never know how windows will react to that :).
Also be sure there aren't any keys stuck, like the ctrl or windows key.
Note that the key does not have to be visually stuck, it can be stuck for visual studio and not for the explorer.
The most common source of sudden problems like this is corruption of one of the data files that vs uses to cache information between builds.
You've tried a clean build, but this won't delete everything. A real clean build is: quit vs, delete bin, obj, debug, release folders, delete all generated files in the root - primarily ncb. Do the same for any locally built libraries that you're project references.
The easiest way to do this is if you have the code in source control, as you can rename away your entire code folder and then force a get of all the source.
You often need to do all of these things in one hit to clear the problem.
Less frequently, a reinstall of vs will sort things out (although this sounds unlikely in your case if it is only one project that breaks)
Also think carefully about anything you might have installed just prior to it failing... And remember that some install effects may not occur until the next reboot so it could be days ago. A particular cause of this are automatic windows updates and trial versions of things like the vs 11 beta.
You might try running the application from outside of VS, but have a line of code that looks like this: Debugger.Launch(); where you want your first breakpoint.
I have a Click Once application (WPF) in C#. Initially when I would hit F5 to debug/launch the application it worked smoothly. Eventually, F5 only would build the solution and not launch the application (therefore I could not step through my code). For a short while I switched from Debug to Release mode and for some reason that allowed the application to launch after using F5 and I could step through my code again. But now that no longer works either. Long story short, I cannot get the application to run in a manner that allows me to step through the code. I can only do a Start without Debugging (Ctrl + F5). Obviously this doesn't do much for me other than tell me if the application works or not.
The thing that worked for me today was to open Task Manager and look for any debug programs that didn't terminate properly.
Task Manager > Processes > kill all programs "*.vshost.exe *32"
You probably have lost your start up project in the solution, or the start up project is messed up, and no correct "item" is defined for the startup.
Right click on one of your projects, and select : define as startup project.
Then retry that should do the trick. If not, check in that projects properties to see if a form or something is defined as the startup object for that project.
Edit : Obviously dont define a class library project as startup project, but choose your UI :).
I had this same issue today and came here looking for help. I tried all the suggestions here and nothing helped.
Seeing as my solution was a simple console application I recreated it from scratch. The new solution didn't exhibit the problems, so I started comparing the two.
I reset the solution and project files so that they were identical (apart from Project GUID, name and root namespace) but the first solution still didn't run.
I then tried deleting the suo files, and the bin and obj folders. Still the first solution wouldn't run.
Finally, I noticed the vshost.exe process was still running for the project. When I killed that and reloaded, it all started working correctly.
I just had this problem today. The solution turned out to be a slight twist on the issue with *.vshost.exe mentioned previously.
I could build the application just fine but msvs refused to launch it. I could manually launch the application and the time stamp on the file indicated that it was in fact a fresh build as well. *.vshost.exe wasn't showing up in the task manager, so I couldn't end the process as suggested.
When all else failed, I tried deleting the .exe's and found that *.vshost.exe would not delete because it was in use. The error message indicated that it was actually the steam client (third party software) that had somehow grabbed my *.vshost.exe file and was "using" it. Not sure how or why. At any rate, I completely shut down steam, then it let me delete *.vshost.exe. After that, building and running from msvc worked normally.
Had the same issue, eventually tried deleting all breakpoints and the debug started working again. Yet to figure out why, but at least it works.
As well as the ghost *.vshost.exe. It could also be that you have the same Solution/Project open in another version of VS. I had the same Solution open in both VS2010 and VS2015 and when running in VS2010 it compiled but failed to start. Closing the VS2015 Solution and it ran as expected.
After years of using VS 2008, I suddenly had the F5 problem not launching the application. There must be a dozen different suggestions out there - I tried a few. Someone suggested a virus. My Microsoft Security Essentials was not automatically updating (a common problem it seems), so I manually updated it. It found a virus, removed it, and the F5 problem went away !
Had this problem and tried to delete everything in bin/debug folder but could not delete vshost.exe file - kept requesting admin permission and then still could not remove it even though running from admin account. Restarted and file was gone and f5 worked again
When I start up our rather large silverlight application it takes ages to start. This is because it compiles everything again every time I start up.
It does this even if it is just compiled everything.
The project is using RIA services as well which I realise contributes to this.
Is there any way to make startup faster?
If nothing has changed, then I often use "attach to process" to hook into the silverlight app to debug it.
Another performance gain can be made by doing the following in Visual Studio: Tools | Options | Projects and Solutions | Build and Run | Turn on "Only build startup projects and dependencies on Run" option.
Maybe some of your source code were saved with a date or time in the future. Sometimes I change my computer date/time to debugging reasons, and save some files. When I restore to the correct date, the compiler compare these files with the output DLL's and recompile everything because they are newer than the DLL files.
When my Silverlight debugging slowed to a death-crawl, I tried disabling the LastPass IE toolbar, and that fixed everything. I went from taking 2 minutes to step over a line to almost instantaneous. Maybe try disabling some IE addons?