New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
AssemblyBuilder still lacks SetEntryPoint #101667
Comments
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov |
Tagging subscribers to this area: @dotnet/area-system-reflection-emit |
I expect that this it is what we are going to do under the covers eventually. The fundamental feature currently missing in PersistableAssemblyBuilder compared to in-memory RefEmit is ability to append new types to already executing assembly. If you do not need to append new types to already executing assembly, you may want to switch to PersistableAssemblyBuilder + Assembly.Load to get the features that are unavailable with in-memory RefEmit. |
|
@buyaa-n This was not meant to be about |
Based on @jkotas comment:
I assumed we wouldn't fix in runnable |
Description
In the recent work on
Reflection.Emit
saving in .NET 9 preview, theSetEntryPoint
API was removed entirely, with the developer left to implement it manually usingPersistableAssemblyBuilder
and variousSystem.Reflection.Metadata
APIs. This works well enough if you're trying to save to a file, but one important use case is still failing hard: generating executable assemblies in-memory. This has real-world applications for a REPL, or for a compiler test suite.Reproduction Steps
System.Reflection.Emit
SetEntryPoint
API available.Expected behavior
It should be possible to generate an executable assembly in-memory, as it was in .NET Framework.
Actual behavior
It is not possible to generate an executable assembly in-memory.
Regression?
This worked in .NET Framework.
Known Workarounds
It's possible to use
PersistableAssemblyBuilder
and save the whole thing to aMemoryStream
, and then callAssembly.Load
on the bytes in the stream, but this feels like a gross hack.Configuration
.NET Core 9, Preview 3, Windows 10, x64
Other information
No response
The text was updated successfully, but these errors were encountered: