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.