Activator.CreateInstance() works inside VSIDE but not externally

前端 未结 7 1513
天涯浪人
天涯浪人 2020-12-19 07:50

I have a bunch of COM objects which all implement the same interface, and need to create one of them as chosen at runtime from a list of options. Since I know the CLSID for

7条回答
  •  感动是毒
    2020-12-19 08:42

    Not sure what is happening there but as a workaround I wonder if you might try launching the process with something like...

    System.Diagnostics.Process.Start("THE_PROCESS.exe");
    

    Then once the process is running you could try to get the object from the running objects table using the ProgID...

    object appObj = System.Runtime.InteropServices.Marshal.GetActiveObject("THE_PROGID");
    

提交回复
热议问题