-
Notifications
You must be signed in to change notification settings - Fork 217
Conversation
cc @jkotalik |
|
||
|
||
## New host binary for component hosting | ||
Add new library `nethost` which will act as the easy to use host for loading managed components. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can AppHost be implemented as one customization of nethost (for code/scenario reuse)? For now, there's only framework-dependent apps with nethost, bit this is not a fundamental technical limitation, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Re framework dependent: Self-contained nethost
while possible introduces interesting problems - for one it would only allow loading one component. Trying to load a second component into that process would become really tricky, since we could not rely on framework resolution to validate/match framework dependencies. Instead this resolution would have to happen on assembly level which is obviously much more complicated. So while possible, I would like to see a real world scenario for this first.
Re apphost
== nethost
: All the hosts are essentially the same: apphost
, comhost
, ijwhost
and now nethost
all do basically the same thing - locate the hostfxr
and call into it. They differ in two things:
- What do they call in
hostfxr
- How do they expose the functionality
In that regard if we were to unify anything, then comhost
and nethost
are actually very similar. Also ijwhost
is similar to them to a degree. They all allow loading "components" - isolated islands of managed code (they will use fully isolated ALC to load the code into). They generate TPA which only contain frameworks - and they only support framework dependent apps.
apphost
is the outlier here.
- It's an
exe
unlike all the others which aredlls
. I know that on Windows it's possible for anexe
to be loaded as adll
and ask for exports, so in that sense it's possible to have both. I don't know about Linux/macOS - if it's even possible to have such a binary. - It runs the app - which effectively means it "owns" the process. For example returning from
Main
will terminate the process. Unlike all the other hosts which don't have that power. - It loads the managed code into the default ALC, meaning it produces TPA which contains everything, frameworks and app.
Then on Windows there's the added complexity of allowing customization of apphost
(native resources, name and so on).
From a testing point of view it's kind of unfortunate since we need to test that many binaries, but from a shipping point of view it kind of doesn't matter. Each needs its own support in SDK, so there's no real gain from sharing the binary. Not counting that nethost
is special in this sense as it won't be integrated into SDK - it will be its own NuGet package (or something like that).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not counting that nethost is special in this sense as it won't be integrated into SDK - it will be its own NuGet package (or something like that).
We need nethost in every app that we are trying to run using AspNetCoreModule, having export on apphost would be much more preferable as it would allow us to avoid having two copies of the same functionality in every customers app.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually don't think you need nethost in every app - you need nethost in your code - to find hostfxr… has very little to do with the app. nethost has to be 100% backward compatible anyway, so it should work on old apps as well.
If we add an export to apphost it would only work for new apps, it won't fix your problem with existing apps.
And more importantly nethost to find hostfxr doesn't need to know much about the app, what it must know are the various rules how to find the install location of .NET Core on the machine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we add an export to apphost it would only work for new apps, it won't fix your problem with existing apps.
We would have to keep the existing code for backcompat anyway, we do a lot more than the apphost does (traverse the PATH)
I actually don't think you need nethost in every app - you need nethost in your code - to find hostfxr… has very little to do with the app. nethost has to be 100% backward compatible anyway, so it should work on old apps as well.
Not sure how I feel about redistributing nethost with AspNetCoreModule and if it brings any benefit.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure how I feel about redistributing nethost with AspNetCoreModule and if it brings any benefit.
I think I'm confused. I though the general desire was to not have the "how to find hostfxr" logic in the ASP.NET code, but instead for that to come from some other component. I agree that in case of apps withapphost
it can come from there, but apps which don't haveapphost
will still have that problem.
This API is also for cases where there's no app at all to begin with (for example the MSBuild/VS case of finding all available SDKs).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When loading the apphost.exe
or dotnet.exe
it may be nice to add versioning for API capabilities. Today, we would check versioning by calling GetProcAddress on these functions to check for existence. In the future, if we decide to add another set of APIs, the logic would get even more complex.
Co-Authored-By: vitek-karas <[email protected]>
Co-Authored-By: vitek-karas <[email protected]>
@jkotalik What do you mean by version API? Hosts which will use |
I mis-read above. I now see that the apis will be exposed on |
I've split the "Loading components" part of this proposal into a separate document see #5486. It seems that the "loading components" part of the discussion has more or less reached approval, so having it separate will make it possible to merge and start the implementation work. That feature is independent of the other proposal around runtime properties and location of |
Please give this another read. Based on the feedback we've now designed an API which allows for runtime property resolution/modification as well as possibly caching (to avoid double resolve in the ASP.NET scenario). The new proposal adds quite a few new APIs to Note: For now I'm leaving out an easy-to-use API on |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for writing this up @vitek-karas, I really like the initialize then activate structure. I am also happy to see that we are proposing a way to modify the default startup flags by the host. I have asked some questions and provided some feedback.
PR feedback
Adds detailed description of proposed behavior for multi-threaded cases. Adds detailed description of proposed versioning behavior.
Added detailed description of multi-threading and versioning behavior. |
Co-Authored-By: vitek-karas <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for iterating on this design. I am a little fuzzy on the usage of the delegate, I like the design but think we need a sample to help show people on how to use it. (which can be a separate document)
Design describing current level of support for hosting managed code from native applications and proposal for improvements in this area. Commit migrated from dotnet/core-setup@1a68a6c
Design describing current level of support for hosting managed code from native applications and proposal for improvements in this area.