MSHTML DLL on Windows 10
Asked Answered
F

9

35

I have a C# solution that makes use of Smith Html Editor (I'm developing on the main project which uses this, so I don't know much about this library), which makes a reference to MSHTML. This worked fine until my upgrade to Windows 10 and it can't find MSHTML anymore. I can directly reference the DLL on the GAC folder, and it stops complaining and thus builds, but it's getting some runtime errors related to the editor not instantiating.

After a little research, it turns out that MSHTML is phased out of Windows 10 as it now uses EdgeHTML. Does anyone have any idea how I can go around this?

The solution still works for Windows 7.

Flirt answered 6/8, 2015 at 10:43 Comment(4)
Have you tried contacting the author of the html control?Olivas
It is not "phased out", MSHTML is still heavily used in Win10. The Winforms and WPF WebBrowser classes depend on it. Nothing is visibly wrong with the COMReference is that .csproj file. Try it out with a dummy project, use Project > Add Reference > Browse button and select c:\windows\system32\mshtml.tlb. If that falls over then you'll know something else you can document in your question. At a minimum quote exact error messages and mention the Path property value of the MSHTML reference.Sphene
if my answer was helpful it would be great if you could flag my answer as correct. Thank you!Ahern
@Flirt Can we use this in Windows 10 UWP app?Weightless
A
53

I just created a blog post on this issue. The problem is that the Microsoft.mshtml.dll assembly in the Global Assembly Cache becomes unregistered from ActiveX during the upgrade process. To fix this issue, it is necessary to run "regasm" on the assembly:

  1. Open an instance of "Developer Command Prompt for VS2013" (or whatever version of Visual Studio you happen to be using). Run it as Administrator by right-clicking the icon and selecting, "Run as Administrator."
  2. Navigate to "C:\Windows\assembly\GAC\Microsoft.mshtml\7.0.3300.0__b03f5f7f11d50a3a." It is possible your path will vary. To verify, go to "C:\Windows\assembly\GAC\Microsoft.mshtml" and type "dir."
  3. Once you are in the correct path, type regasm Microsoft.mshtml.dll
Attenuate answered 10/8, 2016 at 10:38 Comment(6)
I've the same Problem after updating to Windows 10 (Ver. 1607) For me this solution worked fine. Thank you!Lilililia
We had the issue that it wasnt event located in the GAC at all. We got it working by manually creating the mentioned folder structure first and then following these steps.Aconite
Thank you - this fixed exactly my problem after a Windows 10 update !Isopiestic
I had this problem today, after Windows 10 Fall Creators Update. Your solution works great!Interference
Thanks, this solution worked for me after I had upgraded to Windows 10, Ver 1803, OS Build 17134.81Marissamarist
In a clean install of Windows 11 it's not there at all! Need to use @Chris answer. You can search the gac with gacutil.exe /l | find "Microsoft.mshtml" first to confirm. This is most easily run in the Visual Studio command prompt.Plane
T
10

Great solution Aron!

In my case it was:

CD C:\Program Files (x86) [Enter]
CD Microsoft Visual Studio\2019 [Enter]
CD Community\Common7\IDE\PublicAssemblies [Enter]
gacutil -i Microsoft.mshtml.dll [Enter]
exit

(I wrote these on seperate lines since word-wrap made it confusing to read).

Trombley answered 12/7, 2019 at 10:31 Comment(1)
Visual Studio is now 64 bit. As of VS 2022 today on a Windows 11 machine I found this in C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\ide\PublicAssembliesPlane
E
7

I had the exact same problem. Adding the C:\windows\system32\mshtml.tlb worked. Note it's NOT the dll, but the tlb.

Eames answered 6/8, 2015 at 16:17 Comment(0)
E
5

I had the same issue and I think what's going on, at least in my case, is that the project was originally a VS2012 project on Windows 7 and there was a primary interop assembly installed that was referenced. When I removed and re-added the reference to MSHTML and did a diff on the files, the only difference was that the <WrapperTool> was changed from primary to tlbimp and <EmbedInteropTypes> was changed from false to true.

At some point, Visual Studio added the ability to embed the COM wrappers directly into the assembly instead of referencing PIAs, so my guess is that a new VS2015 installation on Windows 10 no longer installs PIAs because they're not necessary. So that's why removing and re-adding the reference fixes the problem and the project should continue to build fine on older OS as well.

Extractive answered 10/8, 2015 at 20:3 Comment(3)
Removing MSHTML and re-adding it is the solution. Re-adding was VERY slow to work, let it have some time!Sadyesaechao
After I removed this dll I just figured out nobody used it. :)Kilmer
This worked, and changed the reference to Microsoft.Mshtml instead of MSHTML.Girasol
P
4

In case if all of the above failed to work for you, here's my solution which is different to the above and it worked for me:

I registered the microsoft.mshtml.dll in the global assembly cache.

Here is the solution:

Step 1: Open the Developer Command Prompt by typing dev in your windows 10 search box and right click the Developer Command Prompt for VSxxxx and run as administrator

Step 2: Navigate to your microsoft.mshtml.dll library. In my case:

CD C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies>

Step 3 Run the following command to register in the global assembly cache:

gacutil -i Microsoft.mshtml.dll

For more information visit this web article: https://learn.microsoft.com/en-us/dotnet/framework/app-domains/how-to-install-an-assembly-into-the-gac

Prim answered 3/7, 2019 at 21:59 Comment(1)
Thanks! This worked for me, and the other solutions did not work.Multiparous
A
3

MSHTML is still an important component in Windows 10, even with Edge as the default browser. You can find it in "C:\Windows\System32". To quote from the official FAQ:

http://dev.modern.ie/platform/faq/will-the-webbrowser-control-work-with-mi

MSHTML:

In Windows 10 the WebBrowser control will use Internet Explorer’s legacy rendering engine, mshtml.dll. At this time EdgeHTML is not available through the WebBrowser control.

EdgeHtml

In Universal Windows Apps built for Windows 10, the WebView control use Microsoft EdgeHTML. WebView controls in apps built for Windows 8 & 8.1 will continue to load the MSHTML to preserve compatibility.

Ahern answered 6/8, 2015 at 17:3 Comment(0)
B
1

Using VS 2015 I had this issue after the last Windows 10 update. I removed the reference "Microsoft HTML Object Library" and added it again to the project. This resolved the issue in my case.

Bruell answered 30/1, 2018 at 3:4 Comment(0)
S
1

For some reason in my case the Microsoft.mshtml file was located in a different directory. On Visual Studio, double click the assembly reference, and you'll find the path to it. Now open the "Developer Command Prompt for VS2017", type the following cd C:\Program Files (x86)\Microsoft Visual Studio\2017\Enterprise\Common7\IDE\PublicAssemblies. Then regasm Microsoft.mshtml.dll.

Saintpierre answered 29/9, 2018 at 20:33 Comment(0)
K
1

Got the same problem with a new build server on Windows Server 2022 and Visual Studio Build Tools 2022. The Library was not in the GAC, and i couldn't add the mshtml.dll from C:\Windows\System32 via gacutil. The answer that worked for me was here - Install the component "Visual Studio Tools for Office (VSTO) build tools" (Microsoft.VisualStudio.Component.TeamOffice.BuildTools) via the Visual Studio Installer - the library among with a ton of other stuff is added to the GAC and the build should work fine.

Kronick answered 17/1 at 7:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.