0

我正在使用 Inventor api 自定义发明人文档。这里我使用 vb.net 代码来启动 Inventor 的一个实例。我的代码是

 inventorApp = CreateObject("Inventor.Application", "")
 inventorApp.Visible = True

没关系,工作正常。但是当我们以管理员身份打开 Visual Studio 时,createobject 出现了一些错误。有人知道启动 Inventor 实例的其他方法吗?

4

2 回答 2

0

尝试改用 marshal 方法。

    Dim m_inventorApp As Inventor.Application
    Try ' Try to use active inventor instance

        Try
            m_inventorApp = System.Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application")
            m_inventorApp.SilentOperation = True
        Catch ' If not active, create a new instance of Inventor
            Dim inventorAppType As Type = System.Type.GetTypeFromProgID("Inventor.Application")
            m_inventorApp = System.Activator.CreateInstance(inventorAppType)
            ' Must set visible explicitly
            m_inventorApp.Visible = True
            m_inventorApp.SilentOperation = True
        End Try
    Catch
        'Cant get or create an instance of inventor.
    End Try
于 2014-03-11T09:27:05.400 回答
0
Private Sub Open_Button_Click()

ThisApplication.SilentOperation = True                'Suppresses the resolve links dialog

Dim myPath As String
myPath = FileName.Text                              'Gets the string, FileName, from module 1
Dim Shell As Object
Set Shell = CreateObject("Shell.Application")
Shell.Open (myPath)                                                      'Opens selected file

Resolve_and_Open.Hide                                               'Hides module

CompareStrings

End Sub

这是为了打开一个需要解析链接的悲伤程序集。我不确定这是否会解决该错误,但请尝试使用:

ThisApplication.SilentOperation = True

要么,要么创建一个外壳,然后以这种方式而不是直接打开它。

于 2014-03-14T14:29:00.727 回答