0

Long story short, trying to build a 'Smoke Tester' application. I'd like to be able to dynamically be given "Hey, this COM assembly (guid, progid) should exist" and attempt to create the COM object via ProgId or guid.

I know how to [ComImport] classes, but instead I'm looking to do this programatically. Is this possible?

2
  • It is only possible to create them programmatically. What on Earth are you asking? You specify the CLSID guid or the ProgId, not both. Use Activator.CreateInstance(), passing the type returned by either Type.GetTypeFromProgID() or Type.GetTypeFromCLSID(). Do try to avoid "System.ReformatDisk", if you don't know what it does then it probably does something you don't want. Commented Apr 20, 2017 at 16:25
  • ROFL - I meant that I'd like to create from GUID or ProgID, depending upon what is handed to me via the interface. GetTypeFromProgID + CreateInstance is what I was looking for, thanks! Commented Apr 20, 2017 at 16:32

1 Answer 1

4

Call Activator.CreateInstance(Type.GetTypeFromProgID("progid")) (or Type.GetTypeFromCLSID).

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.