© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
3 replies
Hawk

❔ CSharpCompilation using Roslyn

Hello there

I’m trying to build a console executable programmatically using Roselyn api.

Both the application building and the built application target .net 6.

I’m using PreserveCompilationContext and DependencyContext.Default.CombineLibraries to get the references to pass to CSharpCompilation.Create but I get an error at runtime saying the executable cannot load System.Runtime. The file is located in the refs/ folder along the application building and the I believe the references are being used during the build but they are not being loaded at runtime.

Do I need to specify the path to where the executable can find the assemblies at runtime? How come can’t it find them?

Thanks
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

❔ ✅ `System.Runtime` Assembly missing in `CSharpCompilation` when using referenced Attribute
C#CC# / help
3y ago
✅ Using Roslyn language server with Neovim lspconfig
C#CC# / help
2y ago
❔ Using Roslyn from a 'single-file' app
C#CC# / help
3y ago
Roslyn String Allocation
C#CC# / help
13mo ago