Edit: check out this quick summary/article that I did on the COM class error 80040154
What operating system? Is it 64 bit?
This problem could be caused by not registering/installing the DLL correctly or if permissions are not configured properly to allow the user running the ASP.net application access to the DLL.
You need to uninstall the old COM object using regsvr32:
regsvr32 -u <dllName>.dll
Please read further down for more instructions on how to use the regsvr32 tool on 64bit operating systems.
Please note that if the old COM object doesn't exist anymore you're going to have a problem. If possible make sure the old COM object is in the directory where it was registered and then call the regsvr32 to uninstall it.
Once uninstalled, remove the old DLL and replace it with the new one and then run the regsvr32 command:
regsvr32 <dllName>.dll
Please note that if you run the following it sometimes comes up with the message about no entry points found so stick with the command listed above:
regsvr32 -i <dllname>.dll
Make sure that the user that will be using the application has sufficient permissions to access the DLL (at least read/execute...but you may need more if your application requires it). If you're not using impersonation, the default anonymous user account is the ASPNET, or IIS_IUSRS and IIS_WPG Windows user account.
Once you've done this try running the application again.
If you're still having problems then I would suggest uninstalling the DLL again and then go through the registry looking for any entries for your DLL that may not have been removed/uninstalled properly. If there are entries in your registry referencing any old DLL (that no longer exists) then you're going to have problems.
Once you have uninstalled the COM object and cleaned your registry of it try registering your new one using regsvr32.
Please note that if your COM object is 32bit and it exists in a SysWOW 64 folder on 64 bit operating systems
You SHOULD NOT give read/write permissions to the anonymous user account on this folder (in fact I think the operating system prevents you from doing this). This could compromise your operating system!
Also, please note that the folder that the COM object is placed into must be accessible to the ASPNET application (especially if the COM object is reading/writing files etc).
So, if your COM component is in the SysWoW64 folder, move it out of there to somewhere that you can apply permissions to that will allow the internet user to use the COM component and prevent them from accessing anything else. Once you have done this and applied the correct permissions, you need to use the 32 bit version of the regsvr32 tool to register the 32 bit COM component. This tool is located in the
C:\Windows\SysWoW64\
directory. The regular regsvr32 tool is meant to register 64bit components (this regular tool is located in the
C:\Windows\system32\
folder).
If your COM object is really a true com component (not developed using .NET code) then regasm will not work.
Also, please note that if your COM component is 32bit you need to configure your build settings in your Visual Studio project to target the x86 platform (the 32 bit platform). If your project is targeting a 64 bit platform, you will continue to get this error.
I guess I could have summed everything up into 4 points:
- Make sure that you uninstall All old versions of the DLL before attempting to install the new one
- Make sure that your ASPNET user account (the account under which your ASP.NET application runs) has permissions to access the COM object
- Make sure that you use the correct regsvr32 tool to register the COM component
- Make sure that you have configured your project to target the appropriate platform (ie: it must target a x86 platform if the COM component is a 32 bit component)
I think the second point is probably what's giving your problems here :) mainly because whenever I see 80040154 errors I can fix them by setting the appropriate permissions on the DLL....I see 0x80004002 when things aren't installed/referenced properly.
A Note Specific to running ASP.NET application: you need to make sure that your website is running under a 32bit application pool. Setting the application pool is different for each version of IIS, so please research this topic so that your application can run properly.