{"id":2913,"date":"2009-10-28T22:46:00","date_gmt":"2009-10-28T22:46:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/visualstudio\/2009\/10\/28\/how-to-fix-the-application-cannot-start-error\/"},"modified":"2019-02-14T15:42:12","modified_gmt":"2019-02-14T23:42:12","slug":"how-to-fix-the-application-cannot-start-error","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/visualstudio\/how-to-fix-the-application-cannot-start-error\/","title":{"rendered":"How to Fix &#8220;The application cannot start&#8221; Error"},"content":{"rendered":"<div id=\"author\">\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/wespic_2.jpg\"><img decoding=\"async\" title=\"wespic\" border=\"0\" alt=\"wespic\" align=\"left\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2009\/10\/wespic_thumb.jpg\" width=\"86\" height=\"70\"><\/a><\/p>\n<p><strong>Weston Hutchins<\/strong> \u2013 Program Manager, Visual Studio Shell Team <br \/><strong>Short Bio<\/strong>: I started at Microsoft as an intern in 2005 and have been working in Visual Studio ever since.&nbsp; I\u2019m currently a PM on the VS Shell Team.&nbsp; No, not the \u201c<a href=\"http:\/\/www.microsoft.com\/downloads\/details.aspx?FamilyID=e7af4fed-8dc8-4b31-b3f5-695122a8c072&amp;displaylang=en\">Isolated<\/a>\u201d or \u201c<a href=\"http:\/\/www.microsoft.com\/downloads\/details.aspx?FamilyID=c6a64e02-6fd6-41e3-a3fd-399d174a84b7&amp;displaylang=en\">Integrated<\/a>\u201d Shell, but the core VS IDE \u2013 it\u2019s UI and services.&nbsp; Prior to my current duties, I was the SKU manager for the Visual Studio Express products. Outside of work, I\u2019m an <a href=\"http:\/\/www.gatorzone.com\/\">avid football fan<\/a>, love winter sports, and always enjoy some quality mac and cheese.<\/p>\n<\/div>\n<p><strong><u>Introduction <br \/><\/u><\/strong>So, you\u2019re sitting on your couch and all of sudden\u2026epiphany!&nbsp; You\u2019ve got the solution to the code problem you\u2019ve been working on for a few days!&nbsp; You go to fire up Visual Studio, and instead of being treated with a new instance of VS you are presented with this &#8212; the dreaded error: \u201cThe application cannot start.\u201d:<\/p>\n<p><a href=\"https:\/\/devblogs.microsoft.com\/wp-content\/uploads\/sites\/4\/2019\/06\/image_2.png\"><img decoding=\"async\" title=\"image\" border=\"0\" alt=\"image\" src=\"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-content\/uploads\/sites\/4\/2009\/10\/image_thumb.png\" width=\"529\" height=\"405\"><\/a> <br \/>\u201cWell, it was working fine this morning!\u201d you say.&nbsp; \u201cWhat happened!?\u201d<\/p>\n<p>I wish I had a quick, easy, one-line answer for why this happens, but as with most things in life, it isn\u2019t that simple.&nbsp; There are a number of scenarios that will cause the IDE to get into this state, which makes diagnosing this issue rather non-trivial.&nbsp; 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.&nbsp; If any one of these operations encounters a critical exception from which it cannot recover (which means VS won\u2019t be able to initialize properly), an error is raised and the user is presented with \u201cThe application cannot start.\u201d<\/p>\n<p>Now, you may be asking, \u201cWell the least you could do is give me some exception message that would make debugging this easier, right?\u201d&nbsp; Unfortunately, no.&nbsp; Because of the managed to native interop on the initialization thread, all the code gets back is an HRESULT; it loses its error context.&nbsp; There are a few alternative approaches that we are investigating for RTM around providing a more meaningful error message.<\/p>\n<p>Now that I\u2019ve given you the background, what do you do if you hit this?&nbsp; We\u2019ll start with the most common case, at least for <a href=\"http:\/\/msdn.microsoft.com\/en-us\/vstudio\/dd582936.aspx\">Visual Studio 2010 Beta 2<\/a>.<\/p>\n<p><strong><u>The Issue <br \/><\/u><\/strong>In <a href=\"http:\/\/msdn.microsoft.com\/en-us\/vstudio\/dd582936.aspx\">Visual Studio 2010 Beta 2<\/a>, there are two straightforward ways to get into this state.&nbsp; <strong>Both of these issues have been fixed for RTM<\/strong>, and, fortunately, there are workarounds for Beta 2.<\/p>\n<ol>\n<li>The first issue is importing a non-TrueType font from a previous version of Visual Studio.&nbsp; This was already covered by Brittany in her <a href=\"http:\/\/blogs.msdn.com\/visualstudio\/archive\/2009\/10\/27\/VS-2010-Beta2_3A00_--Workaround-for-Raster-Font-Settings-Issue.aspx\">excellent blog post<\/a>. <\/li>\n<li>The second way to get in this state is by a corrupted window profile \u2013 the file that persists your IDE window state.&nbsp; If you have <strong>floating<\/strong> tool windows (e.g., drag off Solution Explorer to another monitor or show the Find dialog), minimize Visual Studio, and then close Visual Studio from the minimized state, on the next launch you will hit this error.&nbsp; <\/li>\n<\/ol>\n<p><strong><u>The Workaround <br \/><\/u><\/strong>To workaround these issues, you\u2019ll need to reset your settings file.&nbsp; <strong>NOTE:<\/strong> The IDE will be reset to its default state and all customizations will be lost.&nbsp; If you have customizations that you want to save, please copy <strong>CurrentSettings.vssettings <\/strong>under \u201c<font size=\"2\" face=\"Courier New\">%USERPROFILE%DocumentsVisual Studio 2010Settings<\/font>\u201d to another location.&nbsp; <\/p>\n<p>If you\u2019re using a non-Express SKU:<\/p>\n<ol>\n<li>Start Menu-&gt;Run (or Windows Key + R for the keyboard savvy) <\/li>\n<li>Type \u201c<font size=\"2\" face=\"Courier New\">devenv \/resetuserdata<\/font>\u201d.&nbsp; The issue should now be fixed. <\/li>\n<li>If you wish to reimport your old settings, go to Tools-&gt;Import and Export Settings, select \u201cImport selected environment settings and browse to the .vssettings file you saved. <\/li>\n<\/ol>\n<p>If you\u2019re using an Express SKU your steps will be a bit different:<\/p>\n<ol>\n<li>Start Menu-&gt;Run (or Windows Key + R for the keyboard savvy) <\/li>\n<li>Depending on the SKU installed, type the following:\n<ul>\n<li>For Visual Basic Express type, \u201c<font size=\"2\" face=\"Courier New\">vbexpress \/resetuserdata<\/font>\u201d <\/li>\n<li>For Visual C# Express type, \u201c<font size=\"2\" face=\"Courier New\">vcsexpress \/resetuserdata<\/font>\u201d <\/li>\n<li>For Visual C++ Express type, \u201c<font size=\"2\" face=\"Courier New\">vcexpress \/resetuserdata<\/font>\u201d <\/li>\n<li>For Visual Wed Developer Express type, \u201c<font size=\"2\" face=\"Courier New\">vwdexpress \/resetuserdata<\/font>\u201d <\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<p><strong><u>What we\u2019ve done for RTM <br \/><\/u><\/strong>As mentioned above, both these issues have been fixed for RTM.&nbsp; Additionally, we\u2019ve also added better fallback scenarios so that if something does go wrong, the IDE will try a few workarounds itself.<\/p>\n<p><strong><u>What if that didn\u2019t fix the problem?<\/u><\/strong> <br \/>The above workaround should fix the majority of users that run into this issue, but if you\u2019ve tried that to no avail, here are a few other things you can try:<\/p>\n<ul>\n<li>Browse <a href=\"http:\/\/msdn.microsoft.com\/en-us\/library\/ect3fzs0(VS.80).aspx\">this MSDN article<\/a>.&nbsp; This article is a bit outdated but does have some other causes and workarounds for fixing this issue. <\/li>\n<li><a href=\"https:\/\/www.21concepts.com\/Blog\/EntryId\/10\/Visual-Studio-2005-2008-The-application-cannot-start.aspx\">Some users<\/a> have had success using <a href=\"http:\/\/technet.microsoft.com\/en-us\/sysinternals\/bb896645.aspx\">procmon<\/a> to see what Visual Studio is trying to load.&nbsp; This isn\u2019t for the faint-hearted, but it might help you debug the issue. <\/li>\n<li>Analyze the Activity Log.&nbsp; Sara Ford has a <a href=\"http:\/\/blogs.msdn.com\/saraford\/archive\/2008\/11\/27\/did-you-know-there-s-a-way-to-have-visual-studio-log-its-activity-for-troubleshooting-366.aspx\">post on how to do this<\/a>.&nbsp; <\/li>\n<\/ul>\n<p>If your still experiencing problems, the best option is to file a <a href=\"https:\/\/connect.microsoft.com\/VisualStudio\/content\/content.aspx?ContentID=12362&amp;wa=wsignin1.0\">Connect Bug<\/a> so that we can take a further look.&nbsp; To help us debug, please attach the following files to the bug:<\/p>\n<ol>\n<li><strong>Your window layout file:<\/strong> the file will be named \u201c<font size=\"2\" face=\"Courier New\">Design_<em>somecharacters<\/em>.winprf<\/font>\u201d under \u201c<font size=\"2\" face=\"Courier New\">%APPDATA%MicrosoftVisualStudio10.0<\/font>\u201d <\/li>\n<li><strong>Your settings file: \u201c<\/strong><font size=\"2\" face=\"Courier New\">CurrentSettings.vssettings<\/font>\u201d under \u201c<font size=\"2\" face=\"Courier New\">%USERPROFILE%DocumentsVisual Studio 2010Settings<\/font>\u201d <\/li>\n<li><strong>Your Activity log: <\/strong>From a Visual Studio Command Prompt, type \u201c<font size=\"2\" face=\"Courier New\">devenv \/log<\/font>\u201d.&nbsp; Attach \u201c<font size=\"2\" face=\"Courier New\">%APPDATA%MicrosoftVisualStudio10.0ActivityLog.xml<\/font>\u201d to the bug. <\/li>\n<\/ol>\n<p>Happy coding!<\/p>\n<p>Weston Hutchins <br \/>Program Manager \u2013 Visual Studio Shell Team<\/p>\n<p>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;<\/p>\n<p>We have recently found out another possible cause leading to &#8220;Application cannot start&#8221; message for Visual Studio. This issue has been fixed by&nbsp;.NET Framework&nbsp;team for VS 2010 RTM, but if you&#8217;re still running the RC1 build you may still run into it.<\/p>\n<p>The problem occurs when the shell is trying to create a new profile file to store the VS settings. The shell calls <span>System.IO.Path.GetRandomFileName() <\/span>function to obtain a new file name where the profile settings will be stored. Unfortunately the function throws a &#8220;File not found&#8221; exception. According with a developer in CLR team, &#8220;<span>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.&nbsp;&nbsp;In that case, Windows cannot access the key containers we try to ask for since those are stored in the user profile.&#8221;. <\/span>For instance, one way that will cause Windows to start with a temporary user profile is to delete&nbsp;all the files and folders under&nbsp;%UserProfile% folder of a user from disk, then login on the machine with that user.<\/p>\n<p>There is no easy way&nbsp;to&nbsp;fix the CLR code using an RC build, <\/p>\n<p>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&nbsp;cached in a Windows.index file.&nbsp;Basically, the Windows.index file is just a map from (profile_name -&gt; 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&nbsp;the %APPDATA%MicrosoftVisualStudio10.0Windows.index file, you can try copying the Windows.index file attached to this post&nbsp;in %APPDATA%MicrosoftVisualStudio10.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&#8217;ll encounter problems later, the&nbsp;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&#8217;ll need to reapply the workaround. If your Windows user is using a temporary profile you&#8217;ll probably want to make system changes&nbsp;in order to&nbsp;stop this from happening (e.g. recreate your user, delete completely the %UserProfile% folder, etc)<\/p>\n<p>Alin&nbsp;Constantin&nbsp;<br \/>Visual Studio Shell Team Development<\/p>\n<p><a href=\"https:\/\/msdnshared.blob.core.windows.net\/media\/MSDNBlogsFS\/prod.evol.blogs.msdn.com\/CommunityServer.Components.PostAttachments\/00\/09\/91\/45\/23\/Windows.index\">Windows.index<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Weston Hutchins \u2013 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.&nbsp; I\u2019m currently a PM on the VS Shell Team.&nbsp; No, not the \u201cIsolated\u201d or \u201cIntegrated\u201d Shell, but the core VS IDE \u2013 it\u2019s UI and services.&nbsp; [&hellip;]<\/p>\n","protected":false},"author":13,"featured_media":255385,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[155],"tags":[1383,9,585,653],"class_list":["post-2913","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-visual-studio","tag-c","tag-debug","tag-r","tag-visual-basic"],"acf":[],"blog_post_summary":"<p>Weston Hutchins \u2013 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.&nbsp; I\u2019m currently a PM on the VS Shell Team.&nbsp; No, not the \u201cIsolated\u201d or \u201cIntegrated\u201d Shell, but the core VS IDE \u2013 it\u2019s UI and services.&nbsp; [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/2913","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/users\/13"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/comments?post=2913"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/posts\/2913\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media\/255385"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/media?parent=2913"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/categories?post=2913"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/visualstudio\/wp-json\/wp\/v2\/tags?post=2913"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}