QQ聊天

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

 

 

posted @ 2010-07-06 11:33  SITT  阅读(1203)  评论(0编辑  收藏  举报
QQ聊天