簡體   English   中英

當我嘗試以 C# window 形式運行時,.exe 文件出現錯誤

[英].exe file gives error when I try to run it in C# window form

我正在 C# window 中向文本應用程序發送語音,它工作正常並在 vs 但運行

當我創建一個exe文件然后嘗試運行它時顯示錯誤

它似乎工作正常,並創建了構建但是,當我嘗試運行可執行文件時,出現以下錯誤:

有關調用即時 (JIT) 調試而不是此對話框的詳細信息,請參閱此消息的末尾。

************** Exception Text **************
System.AggregateException: One or more errors occurred. ---> System.DllNotFoundException: Unable to load DLL 'Microsoft.CognitiveServices.Speech.core.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Microsoft.CognitiveServices.Speech.Internal.SpeechConfig.speech_config_from_subscription(IntPtr& config, String subscriptionKey, String region)
   at Microsoft.CognitiveServices.Speech.SpeechConfig.FromSubscription(String subscriptionKey, String region)
   at WindowsFormsApp5.Form1.<RecognitionWithMicrophoneAsync>d__0.MoveNext()
   --- End of inner exception stack trace ---
   at System.Threading.Tasks.Task.ThrowIfExceptional(Boolean includeTaskCanceledExceptions)
   at System.Threading.Tasks.Task.Wait(Int32 millisecondsTimeout, CancellationToken cancellationToken)
   at System.Threading.Tasks.Task.Wait()
   at WindowsFormsApp5.Form1.button1_Click(Object sender, EventArgs e)
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
---> (Inner Exception #0) System.DllNotFoundException: Unable to load DLL 'Microsoft.CognitiveServices.Speech.core.dll': The specified module could not be found. (Exception from HRESULT: 0x8007007E)
   at Microsoft.CognitiveServices.Speech.Internal.SpeechConfig.speech_config_from_subscription(IntPtr& config, String subscriptionKey, String region)
   at Microsoft.CognitiveServices.Speech.SpeechConfig.FromSubscription(String subscriptionKey, String region)
   at WindowsFormsApp5.Form1.<RecognitionWithMicrophoneAsync>d__0.MoveNext()<---



************** Loaded Assemblies **************
mscorlib
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4515.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/Windows/Microsoft.NET/Framework64/v4.0.30319/mscorlib.dll
----------------------------------------
WindowsFormsApp5
    Assembly Version: 1.0.0.0
    Win32 Version: 1.0.0.0
    CodeBase: file:///C:/Users/sars/AppData/Local/Apps/2.0/ZJ219HRQ.5KL/ET7TTANM.RTB/wind..tion_0f35f8da978c8171_0001.0000_3df998e5cb956487/WindowsFormsApp5.exe
----------------------------------------
System.Windows.Forms
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4515.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4488.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
System.Drawing
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4390.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Configuration
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4190.0 built by: NET48REL1LAST_B
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Configuration/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
----------------------------------------
System.Core
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4515.0 built by: NET48REL1LAST_C
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System.Xml
    Assembly Version: 4.0.0.0
    Win32 Version: 4.8.4084.0 built by: NET48REL1
    CodeBase: file:///C:/WINDOWS/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
Microsoft.CognitiveServices.Speech.csharp
    Assembly Version: 1.23.0.28
    Win32 Version: 1.23.0.28
    CodeBase: file:///C:/Users/sars/AppData/Local/Apps/2.0/ZJ219HRQ.5KL/ET7TTANM.RTB/wind..tion_0f35f8da978c8171_0001.0000_3df998e5cb956487/Microsoft.CognitiveServices.Speech.csharp.DLL
----------------------------------------

************** JIT Debugging **************
To enable just-in-time (JIT) debugging, the .config file for this
application or computer (machine.config) must have the
jitDebugging value set in the system.windows.forms section.
The application must also be compiled with debugging
enabled.

For example:

<configuration>
    <system.windows.forms jitDebugging="true" />
</configuration>

When JIT debugging is enabled, any unhandled exception
will be sent to the JIT debugger registered on the computer
rather than be handled by this dialog box.

這可能是版本控制問題。 檢查您是否安裝了 Microsoft Visual C++ Redistributable for Visual Studio 的必要版本。

此外,加載 packages.config 有時在較新版本的 Visual Studio 中行為不正確。 嘗試按照以下步驟操作: https://docs.microsoft.com/en-us/nuget/consume-packages/migrate-packages-config-to-package-reference

  1. 在解決方案資源管理器中,右鍵單擊 packages.config 和 select “Migrate packages.config to PackageReference...”
  2. 在打開的對話框中,默認情況下頂級依賴項中應該有 Microsoft.CognitiveServices.Speech.Core 並且沒有 package 兼容性問題。
  3. Select OK 開始遷移。
  4. 遷移完成后,重建解決方案,然后應該可以正常運行。

希望有幫助

如果您嘗試僅分發已編譯二進制文件中的 .exe 文件,則此錯誤很常見。 如果是這種情況,您應該確保您的編譯器 output 中的所有dll 和 bin 文件夾中的幾乎所有內容都已分發,這稱為 XCOPY 部署。

如果您使用的是單擊一次部署,則在發布選項的應用程序文件部分中,確保包含所有引用的文件: 在此處輸入圖像描述

在此處輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM