Closed oskarjf closed 8 months ago
Sorry for the delay with the response.
Can you guide me on which sample you are referring to?
The repo seems to not have any sample with this method:
Just in case, please be aware that with the new API there is a somewhat similar extension void Unload(this Assembly asm)
:
var script = CSScript.Evaluator
.With(eval => eval.IsAssemblyUnloadingEnabled = true)
.LoadMethod<ICalc>(@"public int Sum(int a, int b)
{ return a+b; }");
script.Sum(1, 2);
script.GetType().Assembly.Unload();
Sorry, I didn't mean that this was code from one of your samples. Only that the code is taken from the system I'm upgrading.
I'll try to use the Assembly.Unload() instead
Yep, since.NET Core introduced the mechanism for direct assembly unloading the old workaround UnloqadOwnerDomain
is no longer needed.
That's why this method is no longer in the API.
I'm upgrading from an older version of CS-Script and after installing the latest version the compiler complains that UnloadOwnerDomain is not a method of object. Can I just remove this?
Sample code:
CSScript.Evaluator.Reset(); var compiledObject = CSScript.Evaluator.LoadCode(ServerCompileIncludes + code); var result = compiledObject?.ToString(); compiledObject?.UnloadOwnerDomain(); compiledObject = null;