MaxScript中使用动态编译的C#
MaxScript中使用动态编译的C#
CSharpCodeSource ="using System;
using System.Windows.Forms;
namespace TestNameSpace
{
public class TestClass
{
public void Test(string theString)
{
MessageBox.Show(theString);
}
}
}
"
CSharpProvider = dotnetobject "Microsoft.CSharp.CSharpCodeProvider"
CompilerParams = dotnetobject "System.CodeDom.Compiler.CompilerParameters"
CompilerParams.ReferencedAssemblies.Add("System.dll")
CompilerParams.ReferencedAssemblies.Add("System.Windows.Forms.dll")
CompilerParams.GenerateExecutable = false
CompilerParams.GenerateInMemory = false
CompilerResults = CSharpProvider.CompileAssemblyFromSource CompilerParams #(CSharpCodeSource)
WinAssembly = CompilerResults.CompiledAssembly
TestAssembly = WinAssembly.CreateInstance "TestNameSpace.TestClass"
TestAssembly.Test "动态编译的C#"
(DotNetObject "TestNameSpace.TestClass").Test "动态编译的C#"