无法加载文件或程序集'Microsoft.mshtml ...强名称验证失败

Rab*_*bbi 18 c# interop mshtml

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

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

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

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

"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.
Run Code Online (Sandbox Code Playgroud)

谢谢

Ata*_*ara 19

验证随程序一起分发的"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


Hrv*_*tić 6

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. 重建您的项目