MaxScript里面不能创建 AppDomain,所以不能卸载,但是可以覆盖,虽然多占用了资源,但是开发时方便了。
using System;
using System.Collections.Generic;
using System.Text;
namespace Test
{
public class TestClass
{
public int GetInt()
{
return 199;
}
}
}
Fn GetDotNetAssemblyByFile dllFileName =
(
local result
DotNetAssembly = dotNetClass "System.Reflection.Assembly"
tempFolder = SysInfo.TempDir
sourceFileName = GetFilenameFile dllFileName
tempPrefix = (GenClassID returnValue:true)[1] as string
tempFileName = tempFolder + tempPrefix + sourceFileName + GetFilenameType dllFileName
CopyFile dllFileName tempFileName
result = DotNetAssembly.LoadFile tempFileName
result
)
DotNetActivator = DotNetClass "System.Activator"
TestAssembly = GetDotNetAssemblyByFile @"D:\TestProject\Test\Test\bin\Debug\Test.dll"
TestClassType = TestAssembly.GetType("Test.TestClass")
TestClassObject = DotNetActivator.CreateInstance TestClassType
TestClassObject.GetInt()