-
Notifications
You must be signed in to change notification settings - Fork 4.7k
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
Use another Core Assembly with PersistedAssemblyBuilder
#101018
Comments
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov |
Tagging subscribers to this area: @vitek-karas, @agocke, @VSadov |
Tagging subscribers to this area: @dotnet/area-system-reflection-emit |
I think you can use an assembly from |
Pass the value returned by Also, you should use types returned by the MetadataLoadContext instance throughout your compiler. For example, instead of
You should direct your uses to use reference assemblies for this purpose: https://www.nuget.org/packages/Microsoft.NETCore.App.Ref/. This package is also included as part of .NET SDK at paths like The core assembly is going to be System.Runtime when using reference assemblies, reference assemblies do not have @buyaa-n Could you please make sure that we have documentation and a sample for this scenario at https://learn.microsoft.com/? |
Thanks for pointing this out, I didn't even know there is a |
We have it explained in the conceptual doc https://learn.microsoft.com/en-us/dotnet/fundamentals/runtime-libraries/system-reflection-emit-assemblybuilder#persisted-dynamic-assemblies-in-net, need to add a sample |
As for the examples in .NET Libraries in .NET 9 Preview 3, we can use
typeof(object).Assembly
as the Core Assembly to instantiate thePersistedAssemblyBuilder
:But how can we use another Core Assembly, for example another version of
System.Private.CoreLib
? The runtime rejects loading it, according to #89215 and my own tests.The constructor defined a parameter specifically for it and allow us to provide our own Core Assembly, I'm curious if the scenario above can be achieved, or I left something.
EDIT: I'm writing a toy compiler which needs the ability to dynamically generate IL and save .dll to disk. I'm stucking at how to let users to specify their own
System.Private.CoreLib
reference, just like whatcsc
do.The text was updated successfully, but these errors were encountered: