1

I am in a situation where I have Visual Studio installed on my work laptop but CATIA is installed on a remote machine. I am not allowed to have Visual Studio installed on the remote machine so my machine has no COM reference to CATIA. In VBA, I can simply use the code below to display the ActiveDocument's name developed on my work laptop and have it run on the remote machine without an issue.

Dim oCATIA as object
Dim oDoc as object
set oCATIA = GetObject(,"Catia.Application")
set oDoc = oCATIA.ActiveDocument
MsgBox oDoc.Name

I have trouble getting it worked with C# .NET, I learned that there is Dynamicmight be used but I don't know how to make this work.

    Type catiaType = Type.GetTypeFromProgID("Catia.Application"); //No issue
    dynamic oCatia = Activator.CreateInstance(catiaType); //No issue

    if((object)oCatia !=null)
    (
      dynamic oDoc = oCatia.ActiveDocument;   //Error
    )

I got what I believe very generic COM error message (0x800040005) Error HRESULT E_FAIL has been returned from a call to a COM component

N.TW12
  • 241
  • 2
  • 11
  • If Catia is not open your oCatia is null? If Catia is not installed on remote machine your oCatia is null? In the future you will deploy this application to the machine where Catia is installed, right ? – Disvoys May 29 '23 at 16:33
  • @Disvoys, CATIA is there. That is why if I use VB.NET Framework 4.8 then I can get CATIA without any issue. – N.TW12 Sep 01 '23 at 02:28

0 Answers0