The official source of product insight from the Visual Studio Engineering Team
Weston Hutchins – Program Manager, Visual Studio Shell Team Short Bio: I started at Microsoft as an intern in 2005 and have been working in Visual Studio ever since. I’m currently a PM on the VS Shell Team. No, not the “Isolated” or “Integrated” Shell, but the core VS IDE – it’s UI and services. Prior to my current duties, I was the SKU manager for the Visual Studio Express products. Outside of work, I’m an avid football fan, love winter sports, and always enjoy some quality mac and cheese.
Introduction So, you’re sitting on your couch and all of sudden…epiphany! You’ve got the solution to the code problem you’ve been working on for a few days! You go to fire up Visual Studio, and instead of being treated with a new instance of VS you are presented with this -- the dreaded error: “The application cannot start.”:
“Well, it was working fine this morning!” you say. “What happened!?”
I wish I had a quick, easy, one-line answer for why this happens, but as with most things in life, it isn’t that simple. There are a number of scenarios that will cause the IDE to get into this state, which makes diagnosing this issue rather non-trivial. When Visual Studio is launched, the initialization code branches off and begins to perform a number of tasks such as reading the window layout, importing the saved settings, loading a number of .dlls, creating the main window, etc. If any one of these operations encounters a critical exception from which it cannot recover (which means VS won’t be able to initialize properly), an error is raised and the user is presented with “The application cannot start.”
Now, you may be asking, “Well the least you could do is give me some exception message that would make debugging this easier, right?” Unfortunately, no. Because of the managed to native interop on the initialization thread, all the code gets back is an HRESULT; it loses its error context. There are a few alternative approaches that we are investigating for RTM around providing a more meaningful error message.
Now that I’ve given you the background, what do you do if you hit this? We’ll start with the most common case, at least for Visual Studio 2010 Beta 2.
The Issue In Visual Studio 2010 Beta 2, there are two straightforward ways to get into this state. Both of these issues have been fixed for RTM, and, fortunately, there are workarounds for Beta 2.
The Workaround To workaround these issues, you’ll need to reset your settings file. NOTE: The IDE will be reset to its default state and all customizations will be lost. If you have customizations that you want to save, please copy CurrentSettings.vssettings under “%USERPROFILE%\Documents\Visual Studio 2010\Settings” to another location.
If you’re using a non-Express SKU:
If you’re using an Express SKU your steps will be a bit different:
What we’ve done for RTM As mentioned above, both these issues have been fixed for RTM. Additionally, we’ve also added better fallback scenarios so that if something does go wrong, the IDE will try a few workarounds itself.
What if that didn’t fix the problem? The above workaround should fix the majority of users that run into this issue, but if you’ve tried that to no avail, here are a few other things you can try:
If your still experiencing problems, the best option is to file a Connect Bug so that we can take a further look. To help us debug, please attach the following files to the bug:
Weston Hutchins Program Manager – Visual Studio Shell Team
We have recently found out another possible cause leading to "Application cannot start" message for Visual Studio. This issue has been fixed by .NET Framework team for VS 2010 RTM, but if you're still running the RC1 build you may still run into it.
The problem occurs when the shell is trying to create a new profile file to store the VS settings. The shell calls System.IO.Path.GetRandomFileName() function to obtain a new file name where the profile settings will be stored. Unfortunately the function throws a "File not found" exception. According with a developer in CLR team, "The problem occurs when the code is running on a thread that has a user context without a loaded [Windows] user profile or with a temporary [Windows] user profile. In that case, Windows cannot access the key containers we try to ask for since those are stored in the user profile.". For instance, one way that will cause Windows to start with a temporary user profile is to delete all the files and folders under %UserProfile% folder of a user from disk, then login on the machine with that user.
There is no easy way to fix the CLR code using an RC build,
There is a way to workaround the problem for Visual Studio startup, but this may be a temporary solution. VS calls on startup GetRandomFileName() function to generate new random names for the VS profile files. Once such file name is generated, the name of the profile and the name of the file storing the profile settings are cached in a Windows.index file. Basically, the Windows.index file is just a map from (profile_name -> profile_file). Next time VS is started or the profile is needed, the names of the files from Windows.index file are used. Therefore, if you run into this problem and you are missing the %APPDATA%\Microsoft\VisualStudio\10.0\Windows.index file, you can try copying the Windows.index file attached to this post in %APPDATA%\Microsoft\VisualStudio\10.0\ folder, and you should be able to start VS. The Windows.index file attached contains entries for a couple of most used profile names (Design, Debug, Design-FullScreen, Debug-FullScreen, NoToolWindows), but you'll encounter problems later, the next time a profile with unknown name will be needed or other Visual Studio component will call System.IO.Path.GetRandomFileName. Also, if Windows was using a temporary profile, once you logoff the machine, Windows will delete the temporary profile folder, so on next login you'll need to reapply the workaround. If your Windows user is using a temporary profile you'll probably want to make system changes in order to stop this from happening (e.g. recreate your user, delete completely the %UserProfile% folder, etc)
Alin Constantin Visual Studio Shell Team Development
Win7, Studio 2010 RC <downloaded today>
'application cannot start' error exactly the same as you have above. Tried your fixes, still does not start.
Splash shows for 4-5 secs
Error message twice, exits
@Jason: I'm sorry to hear the suggested fix hasn't worked out for you.
Can you follow up the steps from the "What if that didn’t fix the problem?" section in the article and open a Connect bug, attaching the requested files so we can investigate further?
[VS Shell dev]
Ahh.. you saved my day! Thanks!
Don't know if this will help, but after a lock up and power on power off about two weeks ok VS would give me the error under discussion if I tried to open VS without a project. If I clicked on one of the recent projects it opened ok, so I lived with that until today.
I was running two instances of VS when one instance locked up on me (the other was minimized). After reboot the error occurred under all circumstances (i.e. with or without a project being selected) I then ran setup in maintenance mode and all reinstalled correctly. When I ran VS after installation the error was still there. I then found your blog and executed run devenv /resetuserdata. I then ran VS and hey presto it ran. Interestingly it came up with the first time dialogue and set up.
Thanks for the help.
Thanks a lot. It works!
I've been fighting this problem for a couple of days. I'm glad I found this page. When I first tried the proposed workaround, it gave me an error about needing to elevate my permissions. (I'm running Vista.) I had to run the command prompt as an administrator, which can be done by finding it in the Start menu by clicking on All Programs > Accessories and then right clicking on "Command Prompt" and choosing "Run as Administrator". That allowed me to reset my settings as the post mentioned, but it still didn't solve the problem.
I saw what DK said about double clicking on the solution file instead of the application shortcut, which worked. Once I pressed Tools > Settings > Reset from VC#Express 2010's menu, the application shortcut worked again.
I can finally program again!
Thanks very much mate, you save dme a lot of hassle
thanks a lot.... it helped!
Awesome. You saved me a lot of time. "devenv /resetuserdata" worked like a charm.
I call it bad programming. if at version 10 your product is unable to even install properly on a machine with OS coming from your company... you guys suck.
what I have installed here is not a beta, not RC, it is the commercial product, downloaded straight from our paid msdn subscription. and the only thing I can get (after nearly 2 hours installation), is "the application cannot start". And now I have to read all this, and mess with the CLR? why??
@Ron: If you've installed the RTM version of VS10, you're not running into the CLR issue I mentioned before, so there's no "need to mess with the CLR". The CLR issue and the other 2 shell problems with the profiles that were the main cause of this message for Beta/RC builds have been fixed for RTM.
The "application cannot start" error message simply means a failure to create the main window. It can be caused by anything, from a bad CLR/WPF install to 3rd party extensions you may have installed.
Were there any errors during VS setup? If yes, you may want to repair your VS install or uninstall/reinstall.
Also, make sure you haven't installed extensions or other programs that integrate with VS and that were designed for beta/rc versions of the IDE, as they may not be compatible with the RTM version.
If that doesn't help, you may have run into some other problem that we haven't seen before. Please open a Connect bug and attach the files Wes is indicating in the article. You can also use ProcDump (technet.microsoft.com/.../dd996900.aspx) and capture minidumps of exceptions (use "procdump -e -x "%ProgramFiles%\Microsoft Visual Studio 10.0\Common7\IDE\devenv.exe" "%temp%\devenv.dmp"), then attach the dump to the Connect issue for further analysis. (For faster communication and resolution you can email us at westonh or alinc AT microsoft.com)
[Visual Studio Shell development]
The "devenv /resetuserdata" workaround does not work for me, but "devenv.com /resetuserdata" does.
same issue here. With the VS 2010 from MSDN like Ron.
Microsoft Visual Studio 2010 version: 10.0.30319.1
It was working till now - but now it's crashing - application cannot start.
From the log:
56 ERROR Leaving function LoadDTETypeLib 8002801d VisualStudio 2010/06/19 23:12:12.007
devenv /resetuserdata didn't help.
My only installed addon was the VS Powertoys and the Reflector plugin - both were working well, and I didn't used them when this crash first occured.
Not so funny...
@Mike: You might want to take a look at Alin's post (two comments above yours). The specific issues Wes blogged about have been fixed for the VS 2010 build you have; the "application cannot start" error message simply means a failure to create the main window and can be caused by any number of things. Unfortunately it's difficult to diagnose crashes in blog comment streams, so bug reports tend to be more successful at resolving this type of problem. I'd encourage you to read Alin's comment, try his suggestions, and open a Connect bug with the information he mentioned if the issues persist.
Program Manager, Visual Studio Editor