Wednesday, August 10, 2016

Fixing 'Cannot find wrapper assembly for type library "MSHTML"' After Windows 10 Upgrade

I received the Anniversary update to Windows 10 last week. After doing so, a solution I work on in Visual Studio 2013 would no longer compile.

Visual Studio showed multiple errors along the lines of "Metadata file xxxx.dll could not be found."

Thinking there was more to this than meets the eye, I navigated to Tools->Options. From there, I selected "Projects and Solutions->Build and Run." I increased the MSBuild logging to Normal:



Then, I ran the build and copied the "Output" tab to Notepad++. I searched for "Build Failed" and ran into this line:

C:\Program Files (x86)\MSBuild\12.0\bin\Microsoft.Common.CurrentVersion.targets(2234,5): warning MSB3283: Cannot find wrapper assembly for type library "MSHTML". Verify that (1) the COM component is registered correctly and (2) your target platform is the same as the bitness of the COM component. For example, if the COM component is 32-bit, your target platform must not be 64-bit.

Thinking that was a bit odd, I opened the references to the project and noticed there was a yellow exclamation mark next to MSHTML. So, I opened the project on my Windows 8.1 virtual machine, and noticed the reference was pointing to an ActiveX control that was registered from a file sitting in the Global Assembly Cache:



Curioius, I wanted to check if this file was in the GAC on my Windows 10 machine. I opened an instance of "Developer Command Prompt for VS2013" (Right-click, Run as Administrator), and entered the following command:
gacutil /l | find "Microsoft.mshtml"
I received a positive hit:


So, I then navigated to C:\Windows\assembly\GAC\Microsoft.mshtml and typed dir to see what folders were there:



I then went into the "7.0.3300.0__b03f5f7f11d50a3a" folder. From there, I registered the assembly using the regasm command:

regasm Microsoft.mshtml.dll



And now my solution compiles once again! Problem solved.

46 comments:

  1. Thanks Very Much for this. Of the two developers to upgrade so far both needed to do this to get our solution to compile.

    ReplyDelete
  2. Thank you. this helped me.
    The issue occurred after
    Windows 10 anniversary update
    Visual Studio 2015 installation.

    ReplyDelete
  3. Thanks a bunch, this helped an entire office of programmers out of a real jam when IT pushed out the anniversary update today.

    ReplyDelete
  4. This is the most useful thing I have read today. Many thanks for sharing this and saving lots of people lots of time.

    ReplyDelete
  5. regasm not found on my computer. Help!

    ReplyDelete
  6. Many thanks. You've saved me countless hours of confusion. I owe you! Keep up the great work!

    ReplyDelete
  7. Oh goodness! I feel I owe you lunch. Thank you so much!

    ReplyDelete
  8. This happened to me with another Windows 10 update. Thanks for this article!! It fixed my problem

    ReplyDelete
  9. @Vikas Yes same for me! THIS THING AGAIN! Jeez!

    ReplyDelete
  10. Thanks a lot, helped after Windows 10 May 2018 update.

    ReplyDelete
  11. Thanks, this resolved my problem after windows 10 update 1803 with visual studio 2017

    ReplyDelete
    Replies
    1. i have the same Problem.

      i can't find the mshtml in the GAC directory.

      Delete
    2. For Visual Studio 2017, the assembly is copied to C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies. If it is not at that location, you probably need to update your installation to include the "Office/SharePoint development" feature. You can do this by going to Control Panel->Programs and Features. Select "Visual Studio 2017" and click the "Change" button.

      Once the assembly is in the previously mentioned folder, run "Developer Command Prompt for Visual Studio 2017" from your start menu. Navigate to the folder containing the assembly and run "gacutil /i Microsoft.mshtml.dll."

      Delete
  12. I suppose this is going to happen for every Windows 10 update :-/

    ReplyDelete
  13. Thank you so much for sharing your findings, this has been invaluable information that has saved me hours of effort.

    ReplyDelete
  14. Thank you so much for this! Such a big help. Thumbsup.

    ReplyDelete
  15. Thank you, it worked for me. Same issue with Windows 10 update and Visual Studio 2015.

    ReplyDelete
  16. Last week my VS2015 app compiled under Windows 7, today, after a Windows 10 update was forced upon me, the same code doesn't compile.
    This has saved me hours of working to find out what has gone wrong.

    ReplyDelete
  17. Thank You for the information.
    After todays Windows 10 update I had the same problem.

    Marek Istvanek

    ReplyDelete
  18. Thanks, it helped after Windows 10 update.

    ReplyDelete
  19. The tip is still valid after receiving a new windows 10 update while still using VS 2012

    ReplyDelete
  20. regasm not found on my computer. Help!

    ReplyDelete
    Replies
    1. regasm is installed with the .NET Framework. It can be located at C:\Windows\Microsoft.NET\Framework\v4.0.30319\regasm.exe. It is far easier, however, to run "Developer Command Prompt for Visual Studio" as per the instructions.

      Delete
  21. Just came across this problem today! I was a Windows 7 holdout. Worked like a charm. THANKS

    ReplyDelete
  22. Thanks, This helped me out a lot. Using VS 2017.

    ReplyDelete
  23. In my case, using VS2019, i have NO DLL files in GAC folder, and sub folders. In GAC folder i have only folders "Microsoft.VisualStudio.Debugger.Interop" and "stdole" and dll file is NOT in any folder

    ReplyDelete
  24. Thank you! On my machine regasm.exe was located in C:\Windows\Microsoft.NET\Framework\v4.0.30319. I can build again!

    ReplyDelete
  25. Thanks a lot, I ran into this problem after major Win 10 upgrade

    ReplyDelete
  26. what if the command gacutil /l | find "Microsoft.mshtml" doesn't find anything. I have found regasm manually, but again, I can't register the assembly.

    ReplyDelete
    Replies
    1. For Visual Studio 2019, the assembly is copied to C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\Common7\IDE\PublicAssemblies. If it is not at that location, you probably need to update your installation to include the "Office/SharePoint development" feature. You can do this by going to Control Panel->Programs and Features. Select "Visual Studio 2019" and click the "Change" button.

      Once the assembly is in the previously mentioned folder, run "Developer Command Prompt for Visual Studio 2019" from your start menu. Navigate to the folder containing the assembly and run "gacutil /i Microsoft.mshtml.dll."

      Delete
    2. I do have the "Office/SharePoint development" feature installed, but the assembly is not where you have specified. In fact, i can't find it anywhere on my PC.

      Thank you for your help.

      Delete
    3. Turns out I found it, but now I can't get acces to the folder through vs cmd. What should I do?

      Thank you for your imput.

      Delete
  27. I am getting this kind off issue
    C:\WINDOWS\system32>C:\Windows\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a>regasm Microsoft.mshtml.dll
    'C:\Windows\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a' is not recognized as an internal or external command,
    operable program or batch file.

    ReplyDelete
    Replies
    1. While I am unable to teach you to use the Windows Command Prompt, I recommend watching some tutorials on the topic. A good starting one can be found at https://www.youtube.com/watch?v=MBBWVgE0ewk.

      Delete
  28. Please help me out from this issue.

    ReplyDelete
  29. Its happened to me today in 2021. VS 2017 This post saved me! Thank you!!!

    ReplyDelete