I need to use a COM object in my .NET 2.0 compact framework project, but I can't use the CreateObject function. Is there any other way to call a COM object that will work in my environment?
+1
A:
You'll need to call CoCreateInstance(). You can find a P/Invoke declaration for it here. If you only have a ProgID then you need to call CLSIDFromProgID() first. Make sure you've exhausted all possibilities of finding a type library for the COM server (Tlbimp.exe), this kind of code isn't easy to get right.
Hans Passant
2009-12-23 09:32:31