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 Dynamic
might 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