By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,931 Members | 1,247 Online
Bytes IT Community
Submit an Article
Got Smarts?
Share your bits of IT knowledge by writing an article on Bytes.

COM class error 80040154

Expert Mod 5K+
P: 9,731
This article is specifically about the error code 80040154. If you are not seeing this error code then the follow information may not apply to you. If you are seeing a 80040150 error you should probably also read through this article but it is highly likely your registry is messed up by multiple versions of your COM component being registered with the operating system.

Looking on the web for information about this error can be frustrating and tedious because the error code is vague and there is no official explanation about it from Microsoft.

From my experience I have discovered that this error is caused by one or more of the following:
  • Insufficient permissions have been applied to the COM component to allow the user running the application to access/use it
  • The component was registered using the incorrect regsvr32 tool for the operating system platform that it is being used on
  • The visual studio project build settings are targeting an incorrect platform

The first point is the most common cause to the 80040154 error. You have to make sure that the user running the application has sufficient permissions to read/execute the component. In the past, all 32bit COM components had to be placed into the C:\Windows\SysWoW64 folder so that the 64bit operating system could run the component properly. Setting permissions on this folder and the components within it could compromise your operating system if you apply them incorrectly. For example, if you are developing a web application that uses a COM component, you should NEVER give the internet user account permissions to this folder! You can now move the 32bit COM components out of the SysWoW64 folder to another place and use appropriate tools to tell the operating system how to execute them.

That brings me to the second point, if your application is going to be executed on a 64bit operating system and your COM component is 32bit, you need to make sure that the correct regsvr32 tool is used to register your COM component.

There are 2 versions of this tool on a 64bit Windows Operating system.
  • One exists in the C:\Windows\system32 folder. This one is the default tool used to register COM components and works perfectly fine to register 32bit COM components on 32bit operating systems; however on a 64bit operating system it is meant to register 64bit components.
  • On 64bit operating systems, another version of this tool exists in the C:\Windows\SysWoW64 folder. This version registers 32bit components in a way that allows them to work properly on a 64bit operating system.

It is important to use the correct tool to register your COM component properly with the operating system that it is be used on.

The third point is important to note because even if you have set up everything correctly so far you will still get this error on 64bit operating systems if your application doesn't specify that it needs to be run under a 32bit platform. You will get this error when you run your application on a 64bit operating system if your project's build settings are targeting "Any CPU" or "x64". Change this setting to target "x86" in order to tell the operating system that it needs to use the 32bit platform when running the application.

So, if you are are experiencing this error right now, I recommend that you:
  • Uninstall your component using the regsvr32 tool(s)
  • Ensure that the component is located in a folder that you can apply appropriate permissions to so that the user running the application can read/execute it
  • Apply the appropriate permissions to the component and, if need be, the folder containing the component
  • Register the component with the operating system using the correct regsvr32 tool
  • Re-reference the component in your project
  • Configure your project's build settings to target the x86 platform
  • Compile and run the application

This should fix the problem.

If you are seeing a 80040150 error, then your registry is messed up. Use the regsvr32 tools to unregister your component in every location that it exists on your operating system, reboot the system and use the appropriate regsvr32 tool register the one component that you are interested in. If you are still getting the error, unregister the component and then use the regedit tool to search through your registry to remove any entries that were not properly cleaned up. After you have done this, try again.

Please note that if your COM object is really a true COM component (not developed using .NET code) then regasm will not work. I know a lot of people try to use it but it's not applicable to these COM components.

A note specific to running ASP.NET application:

If your web application uses a 32 bit COM component and your web server is a 64bit operating system you need to make sure that your website is running under a 32bit application pool or else you will see a "Bad Format Image" error. Setting the application pool is different for each version of IIS, so please research this topic so that your application can run properly.

I know these errors can be frustrating and it seems like there is no fixing them. I really hope this article helps you out!

Nov 8 '13 #1
Share this Article
Share on Google+

Post your comment

Sign in to post your comment or Sign up for a free account.

Browse more .NET Framework Articles on Bytes