从Unity连接到COM对象

时间:2016-03-21 15:00:58

标签: c# unity3d com mono interopservices

我在Unity3D中制作了一个产品配置器。 我希望我的配置器的Windows版本与Autodesk Inventor进行通信,以生成配置产品的生产图纸 我制作了一个DLL文件并将其用作统一插件:

namespace InventorInterface
{
    public class InventorConnection
    {
        private Inventor.Application InventorApplication;

        public InventorConnection()
        {
            InventorApplication = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") as Inventor.Application;
        }

        public String FileName()
        {
            if (null != InventorApplication)
            {
                return InventorApplication.ActiveDocument.File.ToString();
            }
            return "Not Connected to Inventor!";
        }
    }
}

Unity中的我的脚本看起来像:

public class InventorConnection : MonoBehaviour {

    // Use this for initialization
    void Start () {
        InventorInterface.InventorConnection Connection = new InventorInterface.InventorConnection ();
        string File = Connection.FileName ();
    }
}

但是当我运行我的项目时,我收到了这条消息:

  

NotImplementedException:未实现请求的功能。   System.Runtime.InteropServices.Marshal.GetActiveObject(System.String progID)(at /Users/builduser/buildslave/mono/build/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs:317)   InventorInterface.InventorConnection..ctor()   InventorConnection.Start()(在Assets / Scripts / Inventor / InventorConnection.cs:10)

我怎样才能让它发挥作用?

0 个答案:

没有答案
相关问题