Jump to the main content

Reference handling combined with multidomain

Create a domain

Gets the default domain
Get the random field
Gets the domain of the specified name

Compile in the same domain

Preheat Natasha
Add a global using reference
Add metadata for the type to the global reference
If you need Natasha to automatically overwrite all references, introduce the 'DotNetCore.Compile.Environment' package.
Or append the assembly directly to the global reference

Create a domain
var domain = NatashaManagement.CreateRandomDomain();

Create a dynamic method
var action = NDelegate
Specify the domain
. UseDomain(domain)
Configuration class
. ConfigClass(item=>item
Specifies the name of the class in which the method resides
. Name("myTestClass")
Global Using is not loaded
. NoGlobalUsing()
The current domain compilation results in Using are not loaded
. NotLoadDomainUsing())
. Func<int, int, int>("return arg1+arg2;" );
Console.WriteLine(action(1, 2)); result : 3

Reuse the above classes and methods
var func = NDelegate
. UseDomain(domain)
. Func<int>("return myTestClass.Invoke(3,4);" );
Console.WriteLine(func()); result : 7