代码之家  ›  专栏  ›  技术社区  ›  f.lechleitner

在Mathematica中创建Petrosim COM对象失败

  •  0
  • f.lechleitner  · 技术社区  · 6 年前

    我试图使用以下命令从Mathematica调用Petro-Sim:

    petrosim = CreateCOMObject["PetroSIM.Application"];
    

    这将返回以下错误消息:

    CreateCOMObject::netexcptn: A .NET exception occurred: 
    System.Runtime.InteropServices.COMException (0x800401F3):
    Ungültige Klassenzeichenfolge (Ausnahme von HRESULT: 0x800401F3 (CO_E_CLASSSTRING)) bei System.RuntimeType.GetTypeFromProgIDImpl(String progID, String server, Boolean throwOnError) bei Wolfram.NETLink.Internal.COM.COMUtilities.createCOMObject(String clsIDOrProgID) bei Wolfram.NETLink.Internal.CallPacketHandler.createCOM(KernelLinkImpl ml).
    

    抱歉,最后一行应该翻译成:

    Invalid string-class (Exception of HRESULT: 0x800401F3 (CO_E_CLASSSTRING)) at System.RuntimeType.GetTypeFromProgIDImpl(String progID, String server, Boolean throwOnError) at Wolfram.NETLink.Internal.COM.COMUtilities.createCOMObject(String clsIDOrProgID) at Wolfram.NETLink.Internal.CallPacketHandler.createCOM(KernelLinkImpl ml).
    

    我在另一台电脑上使用了相同的Mathematica版本和PetroSim版本,而且工作正常。我对.NET和这些东西一无所知,到目前为止我在互联网上发现的所有问题都无济于事。你知道这个问题是从哪里来的吗?事先谢谢!

    1 回复  |  直到 6 年前
        1
  •  1
  •   Joseph Willcoxson    6 年前

    首先,您需要验证hkcr\petrosim.application是否在注册表中。然后验证clsid是否在注册表中,然后验证是否安装了应用程序。

    您可以验证是否运行此PowerShell宏,该宏将提供相关信息:

    param
    (
     [Parameter(Mandatory=$true)] [string]  $ProgId
    )
    
    $ProgIdPath = join-path "hklm:\software\classes" $ProgId
    
    $ProgIdPath = join-path $ProgIdPath "CLSID"
    
    Try
    {
        $ProgIdEntry = gi $ProgIdPath
    
        $CLSID = $ProgIdEntry.GetValue("")
    
        Write-Host "CLSID: " $CLSID
    
        $CLSIDPath = join-path "hklm:\software\classes\clsid" $CLSID
    
        $CLSIDEntry = gi -path $CLSIDPath
    
        ls $CLSIDEntry.PSPath
    }
    Catch
    {
    }