tags:

views:

553

answers:

3

When I try to create a instance of a COM class it throws an exception as

Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG))

Please suggest how could i solve it?

+2  A: 

By registering the class (specifically its CLSID) -- see e.g. here.

Alex Martelli
Could it also be some object that needs to be installed on his machine or server, not necessarily a registration of the class.
Xaisoft
@Xaisoft, "installation" typically involves "registration", as the MSDN url I pointed to mentions.
Alex Martelli
That makes sense.
Xaisoft
+1  A: 

It looks like whichever program or process you're trying to initialize either isn't installed on your machine, has a damaged installation or needs to be registered.

Either install it, repair it (via Add/Remove Programs) or register it (via regsrv32.exe).

You haven't provided enough information for us to help you any more than this.

Jay Riggs
A: 

Also note that the class context when initializing can create that exception. If you have an object which is coded as INPROC_SERVER but you try to CoCreateInstance as CLSCTX_LOCAL_SERVER, you will also get that error.

You need to ensure the object is registered and the CoCreateInstance is creating an instance with the correct class context.

Andrew Keith