C#C
C#6mo ago
radioegor146

✅ Published dotnet AOT app crashes with strange error

The project in question: https://github.com/radioegor146/microsoft-sapi-openai
When publishing as native (dotnet publish -c Release -r win-x86 -f net9.0 --self-contained) and running, when requesting /audio/voices the following error occurs:
        Common Language Runtime detected an invalid program. The body of method 'Void System.Speech.Internal.SapiInterop.SpDataKey..ctor()' is invalid.
    StackTrace      :
        at Internal.Runtime.TypeLoaderExceptionHelper.CreateInvalidProgramException(ExceptionStringID, String) + 0x36
        at System.Speech.Internal.SapiInterop.SpDataKey..ctor() + 0xf
        at System.Speech.Internal.ObjectTokens.RegistryDataKey..ctor(String, SafeRegistryHandle) + 0x17
        at System.Speech.Internal.ObjectTokens.RegistryDataKey.Open(String, Boolean) + 0xa7
        at System.Speech.Internal.ObjectTokens.SAPICategories.DefaultDeviceOut() + 0x22
        at System.Speech.Internal.Synthesis.VoiceSynthesis..ctor(WeakReference) + 0x2a6
        at System.Speech.Synthesis.SpeechSynthesizer.get_VoiceSynthesizer() + 0x41
        at STT.Program.<VoicesHandler>d__3.MoveNext() + 0x5f
        --- End of stack trace from previous location ---
        at EmbedIO.Actions.ActionModule.<OnRequestAsync>d__6.MoveNext() + 0x54

Can I do something with it, or its the problem with Speech/COM interaction?
GitHub
Simple WebServer to expose Microsoft SAPI 5 voices as OpenAI speech generation APIs - radioegor146/microsoft-sapi-openai
Was this page helpful?