Trying to use some COM-objects in my C# app.
1-st variant:
using AXVLC;
Type t = Type.
GetTypeFromCLSID(
Guid.Parse("E23FE9C6-778E-49D4-B537-38FCDE4887D8")
);
AXVLC.VLCPluginClass vid = Activator.CreateInstance(t) as VLCPluginClass;
But getting such error: Interop type 'AXVLC.VLCPluginClass' cannot be embedded. Use the applicable interface instead. ComObjectCalls
I have understood that the COM object does not expose a public constructor then I shall have to find some other means of using the object. A lot of time COM objects use the factory model to create instances of objects (eg. IClass instance = COMClass.CreateInstance(); )
Or trying using Activator.CreateInstance()
Also I have another question with COM objects: - I have using dynamic type: dynamic shell = AutomationFactory.CreateObject("WMPlayer.OCX.7");
It creates - ok. But how to get known, which metods I can use in it. How can I cast it?
The main problem is: that I want to access COM-object with Silverlight application. So there is a way to work with dynamic/expondo object or calling with P/Invoke some native libraries in Silverlight like:
[DllImport("user32.dll", CharSet = CharSet.Auto, EntryPoint = "MessageBox")]
public static extern IntPtr MineMessageBox(int hWnd, string text,
string caption, uint type);
...
MineMessageBox(0, "Hello World", "Platform Invoke Sample", 0);
What is the best way to access COM-object features in Silverlight and also may to get all info in Runtime about this COM-object ( get methods, which I can call etc )
Thank you!