无法加载文件或程序集' EasyXLS,版本= 8.4.0.0,文化=中立,PublicKeyToken = 632c31013494909a'或其中一个依赖项

时间:2015-04-07 08:27:25

标签: c# .net-4.5

我们在.Net 4.5 Framework中有项目。最近我使用了第三方dll EasyXls(64位)。我的机器也是基于64位。我的运行时错误如下所示。

  

"无法加载文件或程序集' EasyXLS,版本= 8.4.0.0,   Culture = neutral,PublicKeyToken = 632c31013494909a'或其中一个   依赖。尝试加载程序不正确   。格式"

注意:当我使用.net 4构建解决方案时,我没有遇到任何运行时错误。在我的项目属性中,我将平台目标设置为"任何CPU"

你能指点一下解决这个问题吗?

堆栈追踪:

  

无法加载文件或程序集' EasyXLS'或其中一个依赖项。   试图加载格式不正确的程序。

     

描述:执行期间发生了未处理的异常   当前的网络请求。请查看堆栈跟踪了解更多信息   有关错误的信息以及它在代码中的起源。

     

异常详细信息:System.BadImageFormatException:无法加载文件   或组装' EasyXLS'或其中一个依赖项。一次尝试   加载格式不正确的程序。

来源错误:

  

执行期间生成了未处理的异常   当前的网络请求。有关的来源和位置的信息   可以使用下面的异常堆栈跟踪来识别异常。

     

装配加载跟踪:以下信息可能对您有所帮助   确定装配的原因' EasyXLS'无法加载。

===预绑定状态信息===

  

日志:DisplayName = EasyXLS(部分)警告:部分绑定信息   为装配提供:WRN:装配名称:EasyXLS |域名ID:   2 WRN:仅显示部件的一部分时发生部分绑定   提供名称。警告:这可能导致活页夹加载   组装不正确。警告:建议完全提供   组件的指定文本标识,WRN:由组件组成   简单名称,版本,文化和公钥令牌。警告:见   白皮书http://go.microsoft.com/fwlink/?LinkId=109270了解更多信息   这个问题的信息和常见解决方案。日志:Appbase =   file:/// C:/ MarketPlace / Market Place / Source   Code / Trasix.MarketPlace / MP.Services / LOG:Initial PrivatePath =   C:\ MarketPlace \ Market Place \ Source   Code \ Trasix.MarketPlace \ MP.Services \ bin调用程序集:(未知)。   ===日志:此绑定在默认加载上下文中启动。日志:使用应用程序配置文件:C:\ MarketPlace \ Market Place \ Source   Code \ Trasix.MarketPlace \ MP.Services \ web.config日志:使用主机   配置文件:   C:\ Users \ Rakesh \ Documents \ IISExpress \ config \ aspnet.config日志:使用   来自的机器配置文件   C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ CONFIG \ machine.config中。   日志:此时政策未适用于参考(私人,   自定义,部分或基于位置的程序集绑定)。日志:正在尝试   下载新的URL   file:/// C:/ Users / Rakesh / AppData / Local / Temp / Temporary ASP.NET   文件/ VS / 012c8e97 / a400721c / EasyXLS.DLL。日志:尝试下载   新的URL文件:/// C:/ Users / Rakesh / AppData / Local / Temp / Temporary ASP.NET   文件/ VS / 012c8e97 / a400721c / EasyXLS / EasyXLS.DLL。日志:正在尝试   下载新的URL文件:/// C:/ MarketPlace / Market Place / Source   代码/ Trasix.MarketPlace / MP.Services /斌/ EasyXLS.DLL。错误:失败   完成装配设置(hr = 0x8007000b)。探测终止。

堆栈追踪:

  

[BadImageFormatException:无法加载文件或程序集' EasyXLS'要么   其中一个依赖项。尝试加载带有的程序   格式不正确。]
  System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,String   codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,   StackCrawlMark&安培; stackMark,IntPtr pPrivHostBinder,Boolean   throwOnFileNotFound,Boolean forIntrospection,Boolean   suppressSecurityChecks)+0
  System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName,String   codeBase,Evidence assemblySecurity,RuntimeAssembly locationHint,   StackCrawlMark&安培; stackMark,IntPtr pPrivHostBinder,Boolean   throwOnFileNotFound,Boolean forIntrospection,Boolean   suppressSecurityChecks)+34
  System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(的AssemblyName   assemblyRef,Evidence assemblySecurity,RuntimeAssembly reqAssembly,   StackCrawlMark&安培; stackMark,IntPtr pPrivHostBinder,Boolean   throwOnFileNotFound,Boolean forIntrospection,Boolean   suppressSecurityChecks)+152
  System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,   证据集合安全,StackCrawlMark& stackMark,IntPtr   pPrivHostBinder,Boolean forIntrospection)+77
  System.Reflection.RuntimeAssembly.InternalLoad(String assemblyString,   证据集合安全,StackCrawlMark& stackMark,布尔   forIntrospection)+16 System.Reflection.Assembly.Load(String   assemblyString)+28
  System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串   assemblyName,布尔starDirective)+38

     

[ConfigurationErrorsException:无法加载文件或程序集   ' EasyXLS'或其中一个依赖项。试图加载一个   节目格式不正确。]
  System.Web.Configuration.CompilationSection.LoadAssemblyHelper(字符串   assemblyName,布尔starDirective)+736
  System.Web.Configuration.CompilationSection.LoadAllAssembliesFromAppDomainBinDirectory()   +217 System.Web.Configuration.CompilationSection.LoadAssembly(AssemblyInfo   ai)+130
  System.Web.Compilation.BuildManager.GetReferencedAssemblies(CompilationSection   compConfig)+170
  System.Web.Compilation.BuildManager.GetPreStartInitMethodsFromReferencedAssemblies()   +91 System.Web.Compilation.BuildManager.CallPreStartInitMethods(String   preStartInitListPath,Boolean& isRefAssemblyLoaded)+284
  System.Web.Compilation.BuildManager.ExecutePreAppStart()+153
  System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager   appManager,IApplicationHost appHost,IConfigMapPathFactory   configMapPathFactory,HostingEnvironmentParameters hostingParameters,   PolicyLevel policyLevel,Exception appDomainCreationException)+521

     

[HttpException(0x80004005):无法加载文件或程序集' EasyXLS'   或其中一个依赖项。尝试加载程序   格式不正确。]
  System.Web.HttpRuntime.FirstRequestInit(HttpContext context)+9930568   System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context)   +101 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest)   wr,HttpContext context)+254

     

版本信息:Microsoft .NET Framework版本:4.0.30319;   ASP.NET版本:4.0.30319.34212

=== Web.config ===

<?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=169433
  -->
<configuration>
  <configSections>
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
  </configSections>
  <connectionStrings>


  </connectionStrings>
  <appSettings>
    <add key="webpages:Version" value="2.0.0.0" />
    <add key="webpages:Enabled" value="false" />
    <add key="PreserveLoginUrl" value="true" />
    <add key="ClientValidationEnabled" value="true" />
    <add key="UnobtrusiveJavaScriptEnabled" value="true" />
    <add key="ExcelHeaderStartIndex" value="1"/>
    <add key="ExcelRowDataIndex" value="2"/>
  </appSettings>
  <system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" />
    <authentication mode="None" />
    <pages>
      <namespaces>
        <add namespace="System.Web.Helpers" />
        <add namespace="System.Web.Mvc" />
        <add namespace="System.Web.Mvc.Ajax" />
        <add namespace="System.Web.Mvc.Html" />
        <add namespace="System.Web.Optimization" />
        <add namespace="System.Web.Routing" />
        <add namespace="System.Web.WebPages" />
      </namespaces>
    </pages>
    <profile defaultProvider="DefaultProfileProvider">
      <providers>
        <add name="DefaultProfileProvider" type="System.Web.Providers.DefaultProfileProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
      </providers>
    </profile>
    <membership defaultProvider="DefaultMembershipProvider">
      <providers>
        <add name="DefaultMembershipProvider" type="System.Web.Providers.DefaultMembershipProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" />
      </providers>
    </membership>
    <roleManager defaultProvider="DefaultRoleProvider">
      <providers>
        <add name="DefaultRoleProvider" type="System.Web.Providers.DefaultRoleProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" applicationName="/" />
      </providers>
    </roleManager>
    <!--
            If you are deploying to a cloud environment that has multiple web server instances,
            you should change session state mode from "InProc" to "Custom". In addition,
            change the connection string named "DefaultConnection" to connect to an instance
            of SQL Server (including SQL Azure and SQL  Compact) instead of to SQL Server Express.
      -->
    <sessionState mode="InProc" customProvider="DefaultSessionProvider">
      <providers>
        <add name="DefaultSessionProvider" type="System.Web.Providers.DefaultSessionStateProvider, System.Web.Providers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" connectionStringName="DefaultConnection" />
      </providers>
    </sessionState>
  </system.web>
  <system.webServer>
    <validation validateIntegratedModeConfiguration="false" />

  <handlers>
      <remove name="ExtensionlessUrlHandler-Integrated-4.0" />
      <remove name="OPTIONSVerbHandler" />
      <remove name="TRACEVerbHandler" />
      <add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="*" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
    </handlers></system.webServer>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="EntityFramework" publicKeyToken="b77a5c561934e089" />
        <bindingRedirect oldVersion="0.0.0.0-5.0.0.0" newVersion="5.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Microsoft.Practices.ServiceLocation" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Http" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
      </dependentAssembly>
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http.Formatting" publicKeyToken="31bf3856ad364e35" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-5.2.2.0" newVersion="5.2.2.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
  <entityFramework>
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework">
      <parameters>
        <parameter value="v11.0" />
      </parameters>
    </defaultConnectionFactory>
  </entityFramework>
</configuration>

1 个答案:

答案 0 :(得分:0)

您可能正在x64应用程序上加载x32 dll库。尝试更改&#34;启用32位应用程序&#34; to&#34; true&#34;。

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

同时检查平台目标: http://www.codeproject.com/Articles/383138/BadImageFormatException-x-i-x

您的问题是您使用IIS Express(32位)进行调试,并且无法在IIS Express上使用该DLL(调试)。将您的DLL更改为32位或更改项目属性 - &gt;服务器 - &gt;本地IIS(如果您的机器当然是64位)

enter image description here

相关问题