© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•14mo ago•
18 replies
Get

PersistedAssemblyBuilder to generate executable

Hello! I'm trying to generate IL executable from C# via PersistedAssemblyBuilder.
I'm running into issues where the generated IL throws an exception:
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.
Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Private.CoreLib, Version=9.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e' or one of its dependencies. The system cannot find the file specified.

I'm not sure if I did something wrong as I followed the docs https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-reflection-emit-persistedassemblybuilder or even if I tried to copy and paste the code directly (
SetEntryPoint()
SetEntryPoint()
example with output path modification, shown in screenshot), it still gives me error when I run the exe. I definitely have .NET 9 installed (as I need .NET 9 to actually run this exe generator in the first place).

Can someone help me figure out what went wrong? And how can I fix it so that it runs fine?
image.png
image.png
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

✅ how to generate an executable from a csharp code
C#CC# / help
2y ago
Build single executable
C#CC# / help
16mo ago
✅ When I create a dll with PersistedAssemblyBuilder, there is a problem
C#CC# / help
9mo ago