• MaxScript里面覆盖.Net的Dll文件的方式


    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()

  • 相关阅读:
    惊讶
    BLOG休假
    因考试得福
    Shape of My HeartSting !
    一个月的第一天了
    BLOG开张喽~~~
    该走了
    脏话
    EditText的属性
    游戏引擎
  • 原文地址:https://www.cnblogs.com/sitt/p/1977307.html
Copyright © 2020-2023  润新知