oleg-shilo / cs-script

C# scripting platform
http://www.cs-script.net
MIT License
1.56k stars 234 forks source link

Is UnloadOwnerDomain no longer needed? #338

Closed oskarjf closed 8 months ago

oskarjf commented 12 months ago

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;

oleg-shilo commented 11 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: image

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();
oskarjf commented 8 months ago

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.

oskarjf commented 8 months ago

I'll try to use the Assembly.Unload() instead

oleg-shilo commented 8 months ago

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.