如何修复“无法找到文件'C( CoolApp.vshost.exe.config'异常())

古之立大事者,不惟有超世之才,亦必有坚忍不拔之志。这篇文章主要讲述如何修复“无法找到文件' C: CoolApp.vshost.exe.config' 异常?相关的知识,希望能为你提供帮助。
我有一个程序,它使用浏览器Winforms控件导航到不同的网站,但是在5-10秒之后,它会在Visual Studio中抛出上述异常并突出显示以下行:

Application.Run (new MainForm ());

Program.cs
此外,我可以看到异常位置,因为我打开了CLR例外选项。
但为什么会这样呢。我没有对vshost做任何事情。我怎样才能解决这个问题?
编辑:调用堆栈:
mscorlib.dll!System.IO.__Error.WinIOError(int errorCode, string maybeFullPath) + 0x4b7 bytes mscorlib.dll!System.IO.FileStream.Init(string path, System.IO.FileMode mode, System.IO.FileAccess access = Read, int rights, bool useRights = false, System.IO.FileShare share, int bufferSize = 4096, System.IO.FileOptions options, Microsoft.Win32.Win32Native.SECURITY_ATTRIBUTES secAttrs, string msgPath = "CoolApp.vshost.exe.config", bool bFromProxy) + 0xa14 bytes mscorlib.dll!System.IO.FileStream.FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share, int bufferSize, System.IO.FileOptions options, string msgPath, bool bFromProxy) + 0x8a bytes mscorlib.dll!System.IO.FileStream.FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access) + 0x54 bytes System.dll!System.Uri.ParseConfigFile(string file, out System.Uri.IdnScopeFromConfig idnStateConfig, out System.Uri.IriParsingFromConfig iriParsingConfig) Line 1106C# System.dll!System.Uri.GetConfig(ref System.UriIdnScope idnScope = None, ref bool iriParsing = false) Line 1009C# System.dll!System.Uri.InitializeUriConfig() Line 907 + 0x13 bytesC# System.dll!System.Uri.InitializeUri(System.Uri.ParsingError err = None, System.UriKind uriKind, out System.UriFormatException e = null) Line 108 + 0x5 bytesC# System.dll!System.Uri.CreateThis(string uri, bool dontEscape, System.UriKind uriKind) Line 50C# System.Windows.Forms.dll!System.Windows.Forms.WebBrowser.WebBrowserEvent.BeforeNavigate2(object pDisp, ref object urlObject, ref object flags, ref object targetFrameName, ref object postData, ref object headers, ref bool cancel = false) Line 1934 + 0x1a bytes C# [Native to Managed Transition] [Managed to Native Transition] [Native to Managed Transition] [Managed to Native Transition] System.Windows.Forms.dll!System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(int dwComponentID, int reason, int pvLoopData) Line 2106 + 0xc bytesC# System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(int reason = -1, System.Windows.Forms.ApplicationContext context = {System.Windows.Forms.ApplicationContext}) Line 3377 + 0x35 bytesC# System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Line 3261 + 0xd bytesC# > CoolApp.exe!CoolApp.Program.Main() Line 18 + 0x28 bytes C# [Native to Managed Transition] [Managed to Native Transition] Microsoft.VisualStudio.HostingProcess.Utilities.dll!Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() + 0x47 bytes mscorlib.dll!System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext executionContext, System.Threading.ContextCallback callback, object state) + 0x9b bytes mscorlib.dll!System.Threading.ThreadHelper.ThreadStart() + 0x4d bytes

答案你可以在这里找到有关VSHost的详细信息:http://blogs.msdn.com/b/dtemp/archive/2004/08/17/215764.aspx
我也在SO中找到了类似的问题:mysterious exception "Could not find file 'D:xxxxinDebugxxx.vshost.exe.config'."
另一答案在我看来,您正在尝试在没有安装调试器的机器上运行以调试模式编译的程序。
另一答案【如何修复“无法找到文件' C( CoolApp.vshost.exe.config' 异常())】要解决此问题,请尝试在工具/选项/调试/常规中选中“仅启用我的代码(仅管理)”框

    推荐阅读