【问题标题】:3rd Party Encryption Managed Assembly won’t load in Windows 7 Pro x643rd 方加密托管程序集不会在 Windows 7 Pro x64 中加载
【发布时间】:2012-01-17 14:13:30
【问题描述】:

我是一名 C# 新手,2010 年在 VS 2010 C# 中编写了一个程序,使用第三方托管程序集 (EncryptionManager.DLL) 加密/解密数据。 程序在安装了 .Net 3.5 SP1 的 XP Pro SP3 中运行良好。 在启用 .NET 3.5 的 Windows 7 Pro x64 上,程序失败并出现以下错误:

System.BadImageFormatException:无法加载文件或程序集“EncryptionManager,版本=1.0.2978.16361,Culture=neutral,PublicKeyToken=53b6ffdb4dc98f0f”或其依赖项之一。试图加载格式不正确的程序。 文件名:'EncryptionManager, Version=1.0.2978.16361, Culture=neutral, PublicKeyToken=53b6ffdb4dc98f0f'

DLL 安装在 GAC 中,并且在程序搜索路径中。
DLL 被隐式加载(参考编译)。
清单和 DLL 系统版本匹配:

<dependency>
  <dependentAssembly dependencyType="install" allowDelayedBinding="true" codebase="EncryptionManager.dll" size="25896">
    <assemblyIdentity name="EncryptionManager" version="1.0.2978.16361" publicKeyToken="53B6FFDB4DC98F0F" language="neutral" processorArchitecture="x86" />
    <hash>
      <dsig:Transforms>
        <dsig:Transform Algorithm="urn:schemas-microsoft-com:HashTransforms.Identity" />
      </dsig:Transforms>
      <dsig:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
      <dsig:DigestValue>qAxbPPkBK+n8/jtJ8pnjvJg/E2A=</dsig:DigestValue>
    </hash>
  </dependentAssembly>
</dependency>

我需要做些什么才能让它在 Windows 7 上运行?

【问题讨论】:

标签: c# dll


【解决方案1】:

将您的项目设置为使用 x86 而不是 Any CPU 作为目标。

【讨论】:

  • 补充一点,如果您的项目设置为任何 CPU,那么 .Net 将在 64 位机器上将字节码编译为 x64。 64 位可执行文件无法引用 32 位 DLL,因为引用/指针的大小不同。
  • 就是这样!非常感谢。编译为 x86 解决了这个问题。
猜你喜欢
  • 2012-01-24
  • 2015-09-24
  • 1970-01-01
  • 2012-11-14
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-11-25
  • 1970-01-01
相关资源
最近更新 更多