© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
1 reply
proot

System.Speech incompatible with PublishSIngleFile / PublishTrimmed

When I compile my project that uses speech syntheis to read something, even though I have
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>
<RuntimeIdentifier>win-x86</RuntimeIdentifier>
<PublishSingleFile>true</PublishSingleFile>
<PublishTrimmed>true</PublishTrimmed>


in my csproj file there is still a separate DLL that gets created that my exe will not work without and an error that says
Unhandled exception. System.NotSupportedException: Built-in COM has been disabled via a feature switch. See https://aka.ms/dotnet-illink/com for more information.
at System.Speech.Internal.ObjectTokens.RegistryDataKey..ctor(String fullPath, SafeRegistryHandle regHandle)
at System.Speech.Internal.ObjectTokens.RegistryDataKey.Open(String registryPath, Boolean fCreateIfNotExist)
at System.Speech.Internal.ObjectTokens.ObjectTokenCategory.Create(String sCategoryId)
at System.Speech.Internal.ObjectTokens.SAPICategories.DefaultDeviceOut()
at System.Speech.Internal.Synthesis.VoiceSynthesis..ctor(WeakReference speechSynthesizer)
at System.Speech.Synthesis.SpeechSynthesizer.get_VoiceSynthesizer()
at System.Speech.Synthesis.SpeechSynthesizer.SelectVoice(String name)
at SystemSpeech.Program.Main(String[] args) in C:\Users\anton\Documents\cshart\SystemSpeech\Program.cs:line 19
Unhandled exception. System.NotSupportedException: Built-in COM has been disabled via a feature switch. See https://aka.ms/dotnet-illink/com for more information.
at System.Speech.Internal.ObjectTokens.RegistryDataKey..ctor(String fullPath, SafeRegistryHandle regHandle)
at System.Speech.Internal.ObjectTokens.RegistryDataKey.Open(String registryPath, Boolean fCreateIfNotExist)
at System.Speech.Internal.ObjectTokens.ObjectTokenCategory.Create(String sCategoryId)
at System.Speech.Internal.ObjectTokens.SAPICategories.DefaultDeviceOut()
at System.Speech.Internal.Synthesis.VoiceSynthesis..ctor(WeakReference speechSynthesizer)
at System.Speech.Synthesis.SpeechSynthesizer.get_VoiceSynthesizer()
at System.Speech.Synthesis.SpeechSynthesizer.SelectVoice(String name)
at SystemSpeech.Program.Main(String[] args) in C:\Users\anton\Documents\cshart\SystemSpeech\Program.cs:line 19

(but only when using PublishTrimmed, without that there is just an unwanted DLL that is required for running the exe) I am far too inexperienced to know what any of this means and would just like a self contained EXE with all the code required to run standalone produced on compilation
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

PublishSingleFile, PublishTrimmed and SelfContained .. breaks serilog (Reflection issue?)
C#CC# / help
3y ago
Memory leak problem with System.Speech.Recognition && Microsoft.Speech.Recognition
C#CC# / help
3y ago
Property setter disappears on `PublishTrimmed`
C#CC# / help
11mo ago
Has anyone every used: System.Speech.Recognition locally with great success?
C#CC# / help
2y ago