Longit644
Longit644

Reputation: 43

Create Com object

Hello I got the following exception.

Retrieving the COM class factory for component with CLSID {6BF52A4F-394A-11D3-B153-00C04F79FAA6} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

When i try to create o COM object with flow code( in c#)

Object instancePlayer = null;
Guid guid_IWMPPlayer = typeof(WMPLib.IWMPPlayer).GUID;
Guid guid_IUnknown = new Guid("00000000-0000-0000-C000-000000000046");
Type type = Type.GetTypeFromCLSID(guid_IWMPPlayer);
instancePlayer = Activator.CreateInstance(type);

Upvotes: 1

Views: 4304

Answers (1)

Martin
Martin

Reputation: 5452

COM uses GUIDs to identify classes and interfaces. It looks like you're using an interface ID (IID) called IWMPPlayer instead of a class ID (CLSID). See if you can find a corresponding class for the player object and use the GUID of that.

Update: I looked up the class for you. Get the CLSID like this...

Guid guid_WMPPlayer = typeof(WMPLib.WindowsMediaPlayer).GUID;

... and then pass this CLSID into Type.GetTypeFromCLSID.

Update 2: Can I just check though, that you definitely need to use these GUIDs? Why not just do...

instancePlayer = new WMPLib.WindowsMediaPlayer();

...?

Upvotes: 1

Related Questions