I want to create a .NET CF application for Windows Mobile 5. In this application, I want to load a COM object based on the ProgID (or CLSID).
I have tried adding the .ocx file as a Reference, but I get an error, and I am not sure about 'question 2'. I have also tried loading the COM object using
Type type = Type.GetTypeFromProgID("my.prog.id")
MyObject myObject = (MyObject)Activator.CreateInstance(type)
...but this results in an InvalidCastException on the second line.
EDIT: For the record: I am working on a 64-bit Windows 7 machine, not sure if this complicates things...
You need a runtime callable wrapper (RCW). See this MSDN article for the basics. For more complex things like ActiveX controls, see this article.