IIS7 Gotcha – COM Error 80040154

We have all seen the 80040154 COM error. Normally the solution is to run regsvr32 on the com dll so it is registered on the machine.

“System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {D1CB0D81-7D2B-4064-9AC7-D0D88DEC3D16} failed due to the following error: 80040154.”

Of course regsvr32 was the first thing I did, but the error still happened in the ASP.Net MVC project on IIS7/ Server 2008. Using regedit.exe verified the dll was registered, so I ran the NUnit tests… same error! The solution is to permit the IIS7 App Pool to run 32 bit code as shown below:

IIS7 COM Gotcha

IIS7 COM Gotcha

This entry was posted in ASP.Net MVC. Bookmark the permalink.

32 Responses to IIS7 Gotcha – COM Error 80040154

  1. Edg Cer De Lor says:

    Hi Paul, I just wanted to thank you. I was having this problem at work and now i solved it. Thank you so much!!!!

    Saludos desde Barranquilla, Colombia!!!

    • Desmond Hume says:

      Thanks so much, i tried everything with registry regsvr32 and permissions and stuff. Now it worked, got me into some frustrating days

  2. Paul Lockwood says:

    No problem, as IIS7 starts to roll out I imagine this will get a lot of hits from search engines as that is a nasty gotcha. Looking at my logs most people finding it today just have the plain jane regsvr32 issue

  3. Anonymous says:

    Thanks, worked for me.

  4. EDS says:

    This is not a solution–we need to run 64-bit code.

  5. Paul Lockwood says:

    @EDS: You can still run 64 bit code as well, this fix is to permit 32 bit code in addition to 64 bit code.

  6. Jon says:

    I’ve trying to resolve this issue for a litle while now myself. I checked the same things you did and I’d love to try this solution, however that option is not in my Advanced Settings!

    Any ideas?

  7. Jon says:

    nevermind – I’m running 32bit Vista, so not applicable.

    ..s.till searching for a solution.

  8. Paul Lockwood says:

    Jon, did you try regsvr32? I’ll email you..

  9. Had the same problem, after enabling 32bit apps on 64 bit 2008 server. Tried a restart the w3wp.exe service, but same problem. Restarted the entire server, and everything worked fine. We’ve experienced this on all our win 2008 servers. So try a restart (or find out what other services apart from WWW Publishing Service that needs restarting)

    N. Gjermundshaug

  10. Andrew says:

    thank you thank you…

  11. HML says:

    Thanks, This information helped me out a lot!

  12. Anita says:

    Dear Paul,
    in my advanced settings I don’t have that option…I really tried to solve this problem, i did EVERYTHING, every single thing I found on net, but NOTHING worked. error 80040154 REALLY makes me angry. please,please,help me…
    thanks a lot.. greeting from croatia =)

  13. Stijn says:

    What about 32 bit servers?

    The solution you mention works for some cases where you are running a 64bit server and want to use a (32bit) ADO provider. However, what if you get this error on a 32bit server?

    We are getting this error on a 32bit machine. We used regsvr to register the provider and it works, however, the issue keeps reappearing. Any known issues that may cause the regsvr registration to get lost?

    • Paul Lockwood says:

      I cannot be very helpful at this time, but do remember having that issue years ago with a COM object. Why it happened is not coming to mind, if it does I’ll email you

  14. Julio Garibay Castillo says:

    Muchas gracias hermano me salvaste la vida… ya no me sale el error pero ahora tengo el problema de conectarme al SQL Server 2008 no puedo conectar ya que la conexion esta dentro del DLL en VB6.

    Desde peru muchas gracias

    • Paul Lockwood says:

      Julio, glad to help – good luck with the connection string. As a quick hack maybe just hex edit the dll? It might be in plaintext

  15. Matt Moeller says:

    I looked for about an hour to figure this out with no luck, my problem was I was looking to the vendor of the dll and they had nothing. Worked perfect thank you!

  16. Paul Lockwood says:

    Thanks for leaving the comment Matt. Only a small percentage of people leave comments but this page receives a lot of traffic from search engines. I bet it has saved man-months of time.

  17. Paulo Eduardo says:

    Thanks a lot ! Great ! Saved my project !

  18. Norbs Hutcake says:

    Paul, I’m using IIS 6.0. How can I fix this issue? Thanks

  19. Paul Lockwood says:

    @Norbs: This post won’t help with IIS6 at all. You are probably hitting the common regsvr32 issue. i.e. you just need to register the COM object – there many posts out there that cover this

  20. grant7bar7 says:

    I can’t tell you how much time I put in to trying to resolve this to no avail. Everything worked fine in the ASP.NET Visual Web Developer 2010 Web Development Server, Cassini, but I got the Com Component not registered error when publishing to IIS 7 on my remote Windows 2008 x64 box. THANK YOU!!!!!

  21. Bill says:

    This was a bear. Totally threw me this AM. I KNEW the vb comm interop I was given to use was registered because it would work when testing in Cassini. I only started getting this wierd error when I tried testing in IIS7 on the same workstation. I figured it was a permission problem, and didn’t even consider the bit issue. Thanks for the solution, you saved me a lot of time trying to figure this out.

  22. Jonathan says:

    Thanks so much, this is an invaluable piece of knowledge.

  23. Pingback: How do I allow accessing COM components through IIS service?

  24. CoryJ says:

    Paul, this information was a lifesaver! I had a COM DLL working great from a desktop app I was using to test, but my asp.net app completely refused to load it, offering instead its 80040154 apologies. I’ve been wrestling with this for a day and a half before stumbling onto this blog and solving my problem in about 3 minutes.

    Thank You!

  25. simonwdixon says:

    Thank you, Thank you, Thank you… I’ve had a very stressful day on this problem.

  26. Garen Hagopian says:

    i just wanted to say thank you sooo much
    this issue had me going in circles for two whole days. now it’s fixed.

    i kept getting COM component errors which did not help in troubleshooting the problem.

  27. dev says:

    i’m using windows 7.. and vs2008. I couldn’t find an option to enable 32-bit applications! Do you know any other way around?

  28. It’s there in Win7; I was playing with a few weeks ago to solve an Oracle ODP.Net issue

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s