Learning While Aging

Retrieving the COM class factory for component with CLSID failed due to the following error

First of all, as .NET developer, you should NOT use COM components in your .NET applications any more, because it is old and unmanaged.

The detailed error message usually looks like this:

 Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 800xxxxx

The error code may be different, but the cause of the error is usually the same.

The most common cause of the error is that most COM libraries are developed when 32-bit computers are common, so they are only compatible with x86 platform. If you are developing an .NET application on a 64-bit computer referencing COM components, you will need to change your project so that it will compile towards x86 platform. In your Visual Studio, right click your project and select Properties, in the Build tab, change the target platform from Any CPU to x86. Then recompile your project and run it, it should fix the error.

VisualStudio Platform Target x86
VisualStudio Platform Target x86

However, since .NET framework 4.5, a new setting is added for platform target: Prefer 32-bit, and it is by default set to true. So if you are developing .NET application in Visual Studio 2012 (with .NET framework 4.5 by default), then you will not see the above error because the default setting of platform target is Any CPU Prefer 32-bit, as shown in the following screen shot:

Visual Studio 2012 Platform Target Any CPU Prefer 32-bit
Visual Studio 2012 Platform Target Any CPU Prefer 32-bit

If your application is a web application, you may find the above method still does not fix the error. The reason is that your 64-bit IIS does not support 32-bit applications by default. You can enable IIS to allow 32-bit applications by change the application pool properties.

1. Launch IIS, then find the application pool that your application is using.

2. Right-click the application pool and select Advanced Settings, then set Enable 32-Bit Applications to True.

IIS_Enable32BitApplications

The permission to executing the COM component can also cause the error. Especially if you are trying to reference Office COM components in your web application. As a matter of fact, Microsoft recommends developers to use alternatives ways to perform common tasks.

References:

1. http://stackoverflow.com/questions/1036856/retrieving-the-com-class-factory-for-component-with-clsid-xxxx-failed-due-to-t

2. http://digioz.blogspot.com/2011/09/retrieving-com-class-factory-for.html

3. http://support.microsoft.com/kb/257757

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x