Could not load file or assembly 'Microsoft.mshtml ... Strong name validation failed
Asked Answered
C

6

21

I made a WPF/C# program and I am using the internet control for WYSIWYG HTML editing.

it is a regular Executable program.

it works on most computers however some computers are giving me the following error.

Could not load file or assembly 'Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Strong name validation failed.

The 'Microsoft.mshtml.dll' file is distributed with the program. It is with all of the other required dlls in the same folder as the exe file.


Here is the output from Fuslogvw

*** Assembly Binder Log Entry  (1/14/2010 @ 6:36:51 PM) ***

The operation failed.
Bind result: hr = 0x80070002. The system cannot find the file specified.

Assembly manager loaded from:  c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorwks.dll
Running under executable  C:\Documents and Settings\office\Desktop\Database\DATABASE.exe
--- A detailed error log follows. 

=== Pre-bind state information ===
LOG: User = CAMPUSREMOTE\office
LOG: DisplayName = Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
 (Fully-specified)
LOG: Appbase = file:///C:/Documents and Settings/office/Desktop/Database/
LOG: Initial PrivatePath = NULL
LOG: Dynamic Base = NULL
LOG: Cache Base = NULL
LOG: AppName = DATABASE.exe
Calling assembly : ChabadOnCampusMainFrontEnd, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null.
===
LOG: Start binding of native image Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a.
WRN: No matching native image found.

Thanks

Charest answered 14/1, 2010 at 22:56 Comment(0)
K
21

Verify that the 'Microsoft.mshtml.dll' file, distributed with the program is the PIA file and not an Office file. Some sites claims that the Office files are "delay signed" and the PIA file (installed with the VS installation) is a signed copy. on my computer I have 3 different versions of 'Microsoft.mshtml.dll' file, (same file-size, but different content):

  1. "c:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\Microsoft.mshtml.dll"

  2. "c:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.mshtml.dll"

  3. "c:\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll"

Remove "Microsoft.mshtml.dll" reference from the project. Use "Add Reference", ".Net" tab, select the PIA file, use "copy loacal" option. (It worked for me . . .)

Atara

Kennel answered 9/3, 2010 at 10:36 Comment(5)
B"H Thank you. That is basicaly what I figured out. some how the delay signed ddl is the one that gets added to the project and gets distributed however on my local machine the .net runtime took the signed one anyway because it was in the PIA. So as soon as you distribute the one from the PIA all the probelms go away.Charest
Atara your answer was spot on, thanks, you saved me hours of work, thanks!!! and thanks stackoverflow!!Thorrlow
If someone can't enable "Copy Local", you have to set "Embed Interop Types" to False. (just ran into this)Davey
Well, just ran into this same problem and this helped me out, i just removed this reference and it worked, no need to add it again... thank youHyperdulia
So, if I'm trying to build a project on a CI server (Jenkins) without Visual Studio or Office installed. What's the best route to take? more info here at this questionHonorary
C
8

Microsoft.mshtml.dll from PIA folder is not signed.
If you have signed project, you must take version from "Primary Interop Assemblies" folder.


To do that:

1. Remove reference to Microsoft.mshtml (if you have one in your project)

2. Click "Add Reference" and than DO NOT select "Extensions" but "Browse" and point to "C:\Program Files (x86)\Microsoft.NET\Primary Interop Assemblies" (for .64 bit Machines) - that version is signed.

3. Edit properties (select microsoft.mshtml reference and press F4) in order to set:

Embed Interop Types=false
Copy Local=true


4. Rebuild your project

Cernuous answered 20/4, 2015 at 10:50 Comment(0)
S
2

The first step to tracking down this issue is to determine if it's really Mcirosoft.mshtml.dll or one of it's dependencies. The best way to do this is to use fuslogvw to track the assembly load failure. It will provide detailed information about which assembly is failing.

Once you deterimen which assembly is failing, please post back with the results.

EDIT

That warning message suggests that the operation eventually succeeded. It doesn't appear to have the error in it.

Sherlynsherm answered 14/1, 2010 at 23:3 Comment(1)
I posted the results in the original postCharest
R
2

I had this same problem too but my issue was using TFS Build 2008. The hintpath was relative and had to be changed to the exact path. Otherwise during the build it kept picking up the Office mshtml.dll

<HintPath>..\..\..\..\..\..\..\..\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll</HintPath>

<HintPath>C:\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll</HintPath>
Ruvolo answered 18/12, 2010 at 0:34 Comment(0)
H
0

After days of trying to find answers and trying different solutions, i ended up just doing a search at the root of my project (in windows explorer) for 'Microsoft.mshtml' and deleting it.

Hyksos answered 17/1, 2022 at 8:22 Comment(0)
Y
0

I had a c# asp.net project which I had upgraded and installed in a new intranet web server and came up with this error upon doing tests.  All I had to do was to remove the entry from the web.config file in the [assemblies] section. That did the trick. Hope this helps.

Youngling answered 20/10, 2023 at 14:38 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.