public unsafe class Program
{
[UnmanagedCallersOnly]
public static void Main()
{
try
{
Assembly funcLibrary = Assembly.Load(ToMemoryStream(File.OpenRead("FunctionLibrary.dll")));
Type? module = funcLibrary.GetType("FunctionLibrary.Module");
FieldInfo testField = module?.GetField("Test", BindingFlags.Static | BindingFlags.Public);
testField.SetValue(null, true); // Set FunctionLibrary.Module.Test = true
Assembly userLibrary = Assembly.Load(ToMemoryStream(File.OpenRead("UserLibrary.dll")));
Type? userModule = userLibrary.GetType("MyLibrary.MyModule");
MethodInfo entryPoint = userModule?.GetMethod("OnStartup", BindingFlags.Static | BindingFlags.Public);
entryPoint.Invoke(null, null); // Print out the value of FunctionLibrary.Module.Test, expected to == true
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}
public unsafe class Program
{
[UnmanagedCallersOnly]
public static void Main()
{
try
{
Assembly funcLibrary = Assembly.Load(ToMemoryStream(File.OpenRead("FunctionLibrary.dll")));
Type? module = funcLibrary.GetType("FunctionLibrary.Module");
FieldInfo testField = module?.GetField("Test", BindingFlags.Static | BindingFlags.Public);
testField.SetValue(null, true); // Set FunctionLibrary.Module.Test = true
Assembly userLibrary = Assembly.Load(ToMemoryStream(File.OpenRead("UserLibrary.dll")));
Type? userModule = userLibrary.GetType("MyLibrary.MyModule");
MethodInfo entryPoint = userModule?.GetMethod("OnStartup", BindingFlags.Static | BindingFlags.Public);
entryPoint.Invoke(null, null); // Print out the value of FunctionLibrary.Module.Test, expected to == true
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
}
}