There are a lot of questions being asked on how this works - we need to have documentation for it.
cc @gkhanna79
https://blogs.msdn.microsoft.com/dotnet/2016/05/27/making-it-easier-to-port-to-net-core/#comment-77765 has some frequently asked questions that this documentation should provide answers to.
Sounds good @jkotas I will look into this next week.
On the blog at the link above you write :
"AssemblyLoadContext does not provide data isolation. Objects can be passed between them without"
.. but is this not then inconsistent with having separate static variables per context ?
Essentially I want parallelism with a very low dependency on having to write thread-aware code. Appdomains gave that to me.
I am not sure where you see the inconsistency. For both AppDomain and AssemblyLoadContext, the code that sets up your computation has to be thread-aware.
Hi,
Sorry I wasn't very clear. It is true the "scaffolding" code written by developer A would have to be threadsafe. But the code that will run in each context written by developer B should not have to be threadsafe, Developer A would be the more experienced dev who is comfortable coding in a world consisting of multiple threads but developer B is .. for example a mathematician who shouldn't need to worry about writing code that is threadsafe. He should be able to write code that computes his formulae without having to concerns himself with some complex paradigms in software engineering. With the infrastructure that Devloper A provides the software is able to service multiple requests for computation of Developer B's algorithm. I realise it appears a bit of a contrived example however it is pretty close to what my situtation is. I don't want to tell Developer to not use static variables for example.
@Ninds Your example makes sense. It should be possible to build this with AssemblyLoadContext.
ah great. so isolated static variables in each context ?
But I guess we would have to build our own proxies of class which are to be called across context boundaries .. but since they should be very minimal and light that should not be a big problem.
So will we be getting some doc on this feature soon ?
Will AssemblyContexts be added to .NET Framework in the future too ?
.. one more thing will exceptions propagate across context boundaries ?
isolated static variables in each context ?
Correct.
some doc on this feature soon ?
@gkhanna79 is going to start working on the docs soon.
Will AssemblyContexts be added to .NET Framework in the future too ?
It is in our backlog - we do not have the date for it.
one more thing will exceptions propagate across context boundaries ?
Yes.
That's GREAT !
Thanks very much !
I'll come back later with any other questions.
Hi
I'd like to chime in with a couple of other AssemblyLoadContext questions. (I'm told this is the place to ask them so they'll be addressed in the documentation - apologies if this isn't the right place.)
The scenario I'm interested in is a long-running server that compiles and loads some source code (and runs it etc.) but can unload it and recompile and reload a new instance of it if the source code is changed.
Looking at the current source code for AssemblyLoadContext (https://github.com/dotnet/coreclr/blob/d2f9a4dd588a1a9e6349c8bc4f0694e0d1130ab6/src/mscorlib/src/System/Runtime/Loader/AssemblyLoadContext.cs) I'm not sure if this is even possible - a comment in the source code says 'Since unloading an AssemblyLoadContext is not yet implemented...'
Even if it's not possible, it'd be great if the docs could state that it wasn't possible. There's not a lot of info around for AssemblyLoadContext and some of it is contradictory.
Also, if it's not possible, how does Kestrel do this? I struggled finding that bit in Kestrel's source code so if you've any pointers I'd appreciate them.
Many thanks!
Correct - the runtime/ALC implementation does not support it. I have been a little behind in the doc but will ensure it is called out there as well.
I am not sure about Kestrel - can you point me to it?
Hi,
Thanks for that.
Kestrel's just the default web server when I do dotnetcore+MVC development on OS X, and I think it recompiles and reloads pages when they change which is sortof what I'm aiming for.
The code starts at: https://github.com/aspnet/KestrelHttpServer but it may be part of MVC that does the reloading.
Many thanks - I look forward to reading the docs when they're available!
Kestrel doesn't unload anything. MVC (which sits on top) has a view engine (Razor) that compiles views on the fly. https://github.com/aspnet/Mvc/blob/7ce344270a63f6cb397c1ef9829e5c54e7c171ed/src/Microsoft.AspNetCore.Mvc.Razor/Internal/DefaultRoslynCompilationService.cs#L183
No magic 馃槃
Ah well - I was kinda hoping for some magic here!
Many thanks.
Hi,
Where can we find the doc ?
Rgds
N
Any updates on this? Trying to do some work in this area and can't find a lot of documentation on it.
Hi ,
Can someone comment on this topic given the latest developments in .NET Core ?
Has the documentation project been discontinued ?
@jkotas @gkhanna79 I'm currently trying to implement AppDomain-like functionality using AssemblyLoadContext and would really appreciate some documentation on it.
Specifically, it would really help to know:
If a type in the TPAs gets loaded in multiple LoadContexts is the JIT'd code shared between them?
Are statics always shared across AppContexts?
Assuming (2) is true, is it safe to lock a static for synchronization across AssemblyLoadContexts?
Also, it appears that Assembly.LoadFromStream doesn't support netmodules. Is there any other way to load a netmodule from a byte[]?
.NET Core as a whole does not support netmodules.
Please see https://github.com/dotnet/coreclr/pull/10271
@gkhanna79 This is great, thanks!
When I search Bing for AssemblyLoadContext documentation, it leads me to this page. I read through the whole post looking for a link to some documentation, maybe I missed it. Anyway, without a search engine I found this page:
Can anyone please confirm if that's the documentation you've been referring to? Is it the total of all documentation produced on AssemblyLoadContext since June 2016?
@gkhanna79 do you have another link to the real documentation?
Thanks.
@ro-jo The Pull Request referenced by @gkhanna79 created this document. Did you look at that?
@svick err... nope, but thanks. Might have seen it briefly in my search and skipped over it, since it doesn't use the term 'AssemblyLoadContext' ubiquitously. Hardly at all actually. I wouldn't have thought it was describing AssemblyLoadContext if you hadn't told me.
Most helpful comment
Hi ,
Can someone comment on this topic given the latest developments in .NET Core ?
Has the documentation project been discontinued ?