Как исправить исключение «Не удалось найти файл C: \ CoolApp.vshost.exe.config»? - PullRequest
0 голосов
/ 06 февраля 2011

У меня есть программа, которая перемещается по разным веб-сайтам с помощью элемента управления Winforms браузера, но сама по себе, но через 5-10 секунд она вызывает вышеприведенное исключение в Visual Studio и выделяет эту строку:

Application.Run (new MainForm ());

в Program.cs.

Также я вижу местоположение исключения, потому что я включил опцию исключений CLR.

Но почему это происходит? Я ничего не делаю со всхостом. Как я могу это исправить?

РЕДАКТИРОВАТЬ: стек вызовов:

    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 1106    C#
    System.dll!System.Uri.GetConfig(ref System.UriIdnScope idnScope = None, ref bool iriParsing = false) Line 1009  C#
    System.dll!System.Uri.InitializeUriConfig() Line 907 + 0x13 bytes   C#
    System.dll!System.Uri.InitializeUri(System.Uri.ParsingError err = None, System.UriKind uriKind, out System.UriFormatException e = null) Line 108 + 0x5 bytes    C#
    System.dll!System.Uri.CreateThis(string uri, bool dontEscape, System.UriKind uriKind) Line 50   C#
    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 bytes  C#
    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 bytes    C#
    System.Windows.Forms.dll!System.Windows.Forms.Application.ThreadContext.RunMessageLoop(int reason, System.Windows.Forms.ApplicationContext context) Line 3261 + 0xd bytes   C#
>   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   

Ответы [ 3 ]

0 голосов
/ 06 февраля 2011

Мне кажется, что вы пытаетесь запустить программу, скомпилированную в режиме отладки, на компьютере, на котором не установлен отладчик.

0 голосов
/ 24 марта 2017

Чтобы устранить проблему, попробуйте установить флажок «Включить только мой код (только для управляемого)» в «Инструменты / Параметры / Отладка / Общие»

0 голосов
/ 06 февраля 2011

Подробную информацию о VSHost можно найти здесь: http://blogs.msdn.com/b/dtemp/archive/2004/08/17/215764.aspx

Также я нашел похожий вопрос в SO: Загадочное исключение «Не удалось найти файл 'D: \ xxxx \ bin \ Debug \ xxx.vshost.exe.config'."

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...