【问题标题】:What cause to error: Could not load file or assembly '' or one of its dependencies导致错误的原因:无法加载文件或程序集“”或其依赖项之一
【发布时间】:2017-01-15 08:54:07
【问题描述】:

我从事网络项目,我使用 VS2013。在解决方案中,我有 2 个项目,解决方案中所有项目的构建平台目标是 Any CPU。

当我在 Global.asax 文件中的某个位置启动解决方案时,我收到此错误:

Could not load file or assembly 'MapGuideDotNetApi' or one of its dependencies. An attempt was made to load a program with an incorrect format.

虽然所有 DLL 和依赖项都在 bin 文件夹中。

如果在 Visual Studio 中我检查了工具->选项->项目和解决方案->Web 项目-> Use the 64 bit version of IIS 中的选项,我没有收到任何错误。

我的问题是知道为什么会出现上述错误吗?

【问题讨论】:

  • 什么是 MapGuideDotNetApi ?
  • @YashveerSingh 这是我使用的开源 dll。
  • 你有那个 DLL 的 32 位版本吗?我怀疑不是。
  • @CodyGray 它们都是 64 位的
  • 好吧,那就是问题所在。如果您明确使用 64 位版本的 IIS,您会说一切正常。但除此之外,它会启动 32 位版本的 IIS,找不到所需 DLL 的 32 位版本,结果失败。

标签: c# .net dll x86 64-bit


【解决方案1】:

请检查您的 web.config,它应该包含 runtime xml 节点中的程序集

<?xml version="1.0" encoding="utf-8"?>
<!--
  For more information on how to configure your ASP.NET application, please visit
  http://go.microsoft.com/fwlink/?LinkId=301880
  -->
<configuration> 
<!--whatever goes here-->
<runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="MapGuideDotNetApi" publicKeyToken="some token" />
        <bindingRedirect oldVersion="some old version" newVersion="some new version" />
      </dependentAssembly>
      <!--other assemblies-->
    </assemblyBinding>
    <!--whatever-->
</runtime>
<!--whatever goes here-->
</configuration>

为了让程序集出现在这里,我建议删除并添加已损坏的引用。

【讨论】:

  • 当我将块 添加到 webconfig 时,我收到此错误:应用程序配置文件“Web.config”无效。 assemblyIdentity 元素的某些属性不正确。
  • 添加项目引用时应该自动添加
  • 您能提供更多信息吗?堆栈跟踪可能吗?怎么用,有什么功能?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-12-12
  • 2012-01-14
  • 1970-01-01
相关资源
最近更新 更多