现在的位置: 首页 > 综合 > 正文

MaxScript中使用动态编译的C#

2012年11月28日 ⁄ 综合 ⁄ 共 792字 ⁄ 字号 评论关闭

 

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#"

 

 

抱歉!评论已关闭.