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

 

 

相关文章:

  • 2021-12-16
  • 2021-10-19
  • 2021-03-26
  • 2022-12-23
  • 2021-10-16
  • 2022-02-27
  • 2021-10-18
猜你喜欢
  • 2021-07-04
  • 2021-10-28
  • 2021-10-04
  • 2022-12-23
相关资源
相似解决方案