C# 无法加载文件或程序集 'Microsoft.mshtml ... 强名称验证失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2068159/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Could not load file or assembly 'Microsoft.mshtml ... Strong name validation failed
提问by Rabbi
I made a WPF/C# program and I am using the internet control for WYSIWYG HTML editing.
我制作了一个 WPF/C# 程序,我正在使用 Internet 控件进行 WYSIWYG HTML 编辑。
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.
无法加载文件或程序集“Microsoft.mshtml, Version=7.0.3300.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a”或其依赖项之一。强名称验证失败。
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.
“Microsoft.mshtml.dll”文件随程序一起分发。它与所有其他必需的 dll 位于 exe 文件所在的同一文件夹中。
Here is the output from Fuslogvw
这是来自的输出 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
谢谢
采纳答案by Atara
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):
验证随程序分发的“Microsoft.mshtml.dll”文件是 PIA 文件而不是 Office 文件。一些站点声称 Office 文件是“延迟签名的”,而 PIA 文件(随 VS 安装一起安装)是签名副本。在我的计算机上,我有 3 个不同版本的“Microsoft.mshtml.dll”文件(文件大小相同,但内容不同):
"c:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\Microsoft.mshtml.dll"
"c:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.mshtml.dll"
"c:\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll"
“c:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office11\Microsoft.mshtml.dll”
“c:\Program Files\Microsoft Visual Studio 9.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.mshtml.dll”
“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 . . .)
从项目中删除“Microsoft.mshtml.dll”引用。使用“添加引用”,“.Net”选项卡,选择 PIA 文件,使用“复制本地”选项。(它对我有用......)
Atara
阿塔拉
回答by JaredPar
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.
追踪此问题的第一步是确定它是否真的是 Mcirosoft.mshtml.dll 或其依赖项之一。最好的方法是使用 fuslogvw 来跟踪程序集加载失败。它将提供有关哪个程序集失败的详细信息。
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.
该警告消息表明该操作最终成功。它似乎没有错误。
回答by John
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
我也有同样的问题,但我的问题是使用 TFS Build 2008。hintpath 是相对的,必须更改为确切的路径。否则在构建过程中它会不断获取 Office mshtml.dll
<HintPath>..\..\..\..\..\..\..\..\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll</HintPath>
<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>
回答by Hrvoje Mati?
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
PIA 文件夹中的 Microsoft.mshtml.dll 未签名。
如果您已签署项目,则必须从“Primary Interop Assemblies”文件夹中获取版本。
要做到这一点:
1. 删除对 Microsoft.mshtml 的引用(如果您的项目中有引用)
2. 单击“添加引用”,然后不要选择“扩展”而是“浏览”并指向“C:\Program Files ( x86)\Microsoft.NET\Primary Interop Assemblies”(对于 .64 位机器) - 该版本已签名。
3. 编辑属性(选择 microsoft.mshtml 引用并按 F4)以设置:
Embed Interop Types=false
Copy Local=true
4. 重建您的项目