无法加载文件或程序集’Microsoft.mshtml …强名称validation失败

我制作了一个WPF / C#程序,我使用互联网控件进行所见即所得的HTML编辑。

它是一个常规的可执行程序。

它适用于大多数计算机,但有些计算机给我以下错误。

无法加载文件或程序集’Microsoft.mshtml,Version = 7.0.3300.0,Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a’或其依赖项之一。 强名称validation失败。

“Microsoft.mshtml.dll”文件随程序一起分发。 它与exe文件在同一文件夹中的所有其他必需的dll。


这是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. 

谢谢

validation随程序一起分发的“Microsoft.mshtml.dll”文件是PIA文件而不是Office文件。 一些站点声称Office文件是“延迟签名”,PIA文件(与VS安装一起安装)是签名副本。 在我的电脑上我有3个不同版本的’Microsoft.mshtml.dll’文件,(文件大小相同,但内容不同):

  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”

从项目中删除“Microsoft.mshtml.dll”引用。 使用“添加引用”,“。Net”选项卡,选择PIA文件,使用“copy loacal”选项。 (它对我有用……)

Atara

来自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)以设置:

嵌入Interop Types = false
复制Local = true

4.重建您的项目

追踪此问题的第一步是确定它是否真的是Mcirosoft.mshtml.dll或其中一个依赖项。 执行此操作的最佳方法是使用fuslogvw跟踪assembly负载故障。 它将提供有关哪个组件发生故障的详细信息。

一旦确定哪个组件出现故障,请回复结果。

编辑

该警告信息表明该操作最终成功。 它似乎没有错误。

我也有同样的问题,但我的问题是使用TFS Build 2008.提示路径是相对的,必须更改为确切的路径。 否则在构建期间它会继续拾取Office mshtml.dll

..\..\..\..\..\..\..\..\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll

 C:\Program Files\Microsoft.NET\Primary Interop Assemblies\Microsoft.mshtml.dll