-
Notifications
You must be signed in to change notification settings - Fork 4.6k
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
How to locate coreclr.dll from hostfxr_initialize_for_runtime_config #34946
Comments
I couldn't figure out the best area label to add to this issue. Please help me learn by adding exactly one area label. |
Tagging subscribers to this area: @vitek-karas, @swaroop-sridhar |
/cc @elinor-fung |
I've been researching my managed assembly loading issues with That doesn't help me with my core issue, though. I need a supported way to call into my managed entry point, such that the managed environment is the same regardless of whether the app was published FDD or SCD. This custom host could easily end up in an installer built this year that someone tries to use 10 years now with .NET Core 2030. I can think of 3 options:
|
Is this problem solvable via the proposed solution mentioned in #35465? (I assume these two issue represent the same scenario - right?) Just for completeness to answer your questions:
|
Yes, I created both of these from the same scenario so I shouldn't need this anymore. However, someone else might have a scenario where they need to use |
Customize startup flags: This is already fully supported by the Issue #3156 will add a new runtime property (I think the last proposed name was something like |
Looking at #644, I don't see any path information in |
This doesn't seem to be going anywhere. Like I said, I don't believe #3156 is going to help here because it's not going to be adding anything with path information. This can easily be accomplished by getting |
Maybe a better issue to reference would be #33472. The underlying implementation is similar as both needs to expose information about frameworks in the runtime properties. This one explicitly mentions paths to be included. |
TL;DR What's the correct way to locate coreclr.dll using the results of a successful call to
hostfxr_initialize_for_runtime_config
?I am writing a custom .NET Core host for wixtoolset/issues#6108. The use case here is that the main application (the Burn engine, or burn.exe) is a native application that loads basically another application (the Bootstrapper Application, or BA) from a DLL. Both Burn and the BA run on their own threads and communicate with each other to get the job done. So my custom host needs to load the .NET Core runtime, instantiate the managed code BA (from a user provided DLL), and return essentially a handle to that managed BA to the native engine. This was implemented long ago for the full .NET Framework here.
Since I need to load the managed code as a component, I started with
hostfxr_initialize_for_runtime_config
with an self-contained deployment (SCD) style test project. I quickly learned, however, thathostfxr_initialize_for_runtime_config
doesn't support a.runtimeconfig.json
for SCD. (Why does my custom host need to know whether the target was deployed by the SCD or FDD (framework-dependent deployment) style?) I eventually got SCD working by not using the nethost/hostfxr/hostpolicy layer.So I came back to
hostfxr_initialize_for_runtime_config
for testing FDD style projects, since I need the logic of finding the appropriate framework based on the requirements of the target managed application. The initialization worked great, but I had trouble withload_assembly_and_get_function_pointer
. (Why do the type and delegate parameters require an assembly qualification, when I'm required to provide the assembly path as a parameter to the same function?)After working that out, I successfully got to the managed side of this custom host. But I ran into some issues trying to load the target managed DLL. The original code was using
AppDomain.Current.Load
, which returnedE_FILE_NOT_FOUND
. (AppDomain.Current.Load
was working perfectly when I loaded the framework directly throughcoreclr
for the SCD workflow, why would it behave differently throughhostfxr_initialize_for_runtime_config
?) Then I switched toAssembly.Load
and eventually started setting theAPP_PATHS
runtime property with the target directory. I don't remember which combinations produced which errors, but sometimes a dependent assembly wasn't getting loaded and sometimes that dependent assembly was getting loaded twice. (AreAppDomain.Current.Load
andAssembly.Load
supposed to work differently? )Because of those managed assembly load issues with
hostfxr_initialize_for_runtime_config
, and plus the SCD workflow can't use it either, I want to usecoreclr
directly in both scenarios. But I still needhostfxr_initialize_for_runtime_config
in the FDD workflow so that it can tell me which coreclr.dll to load. What is the correct way to do that? I have calledhostfxr_get_runtime_properties
and there are multiple properties that I could use to guess where coreclr.dll is. For instance, go through the TPAs and get the parent directory of a certain DLL (but which DLL?). Or get the parent directory ofJIT_PATH
(is this always going to be available in future versions?). Or use the directories inNATIVE_DLL_SEARCH_DIRECTORIES
(it includesC:\
which seems weird to me).The text was updated successfully, but these errors were encountered: