本文介绍了PostSharp AssemblyLoadException Autofac的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我建立的,我想用最新的Autofac(3.4)和PostSharp 3.1.42新的解决方案。引用的NuGet包后,我得到了下面的错误,我无法弄清楚到底是怎么回事。我从来没有选择Autofac 3.3.0包。

packages.config:

 <包ID =Autofac版本=3.4.0targetFramework =net451/>
  <包ID =Autofac.Extras.Multitenant版本=3.1.1targetFramework =net451/>
  <包ID =Autofac.Mvc5版本=3.3.0targetFramework =net451/>
  <包ID =PostSharp版本=3.1.42targetFramework =net451/>
 

的MSBuild日志:

 错误3未处理的异常(3.1.43.0,32位,CLR 4.5版本)。PostSharp.Sdk codeModel.AssemblyLoadException:无法找到程序集​​autofac,版本= 3.3 .0.0,文化=中性公钥= 17863af14b0044da。 [版本不匹配]

============ PostSharp组件加载登录===================

日志:寻找组装结合身份autofac,版本= 3.3.0.0,文化=中性公钥= 17863af14b0044da。

日志:找到文件'D:\网络\项目\包\ Autofac.3.4.0 \ lib目录\ net40 \ Autofac.dll'身份'autofac,版本= 3.4.0.0,文化=中性公钥= 17863af14b0044da,的ProcessorArchitecture = MSIL 。

日志:参考不匹配D:\网络\项目\包\ Autofac.3.4.0 \ lib目录\ net40 \ Autofac.dll[VersionMismatch。

日志:探测位置C:\ ProgramData \ PostSharp \ 3.1.43 \ bin.Release \ Autofac.exe,因为该目录中明确添加到搜索路径[文件未找到。

日志:探测位置C:\ ProgramData \ PostSharp \ 3.1.43 \ bin.Release \ Autofac.dll,因为该目录中明确添加到搜索路径[文件未找到。

日志:探测位置C:\ ProgramData \ PostSharp \ 3.1.43 \ bin.Release \ Autofac.winmd,因为该目录中明确添加到搜索路径[文件未找到。

日志:探测位置D:\网络\项目的\ src \框架\ BLL \ BIN \ Autofac.exe,因为该目录中明确添加到搜索路径[文件未找到。

日志:找到文件'D:\网络\项目的\ src \框架\ BLL \ BIN \ Autofac.dll'身份'autofac,版本= 3.4.0.0,文化=中性公钥= 17863af14b0044da,的ProcessorArchitecture = MSIL。日志:参考不匹配D:\网络\项目的\ src \框架\ BLL \ BIN \ Autofac.dll[VersionMismatch。

日志:探测位置D:\网络\项目的\ src \框架\ BLL \ BIN \ Autofac.winmd,因为该目录中明确添加到搜索路径[文件未找到。

日志:探测位置D:\网络\项目的\ src \框架\ BLL \ OBJ \ o \ Autofac.exe,因为该目录中明确添加到搜索路径[文件未找到。

日志:探测位置D:\网络\项目的\ src \框架\ BLL \ OBJ \ o \ Autofac.dll,因为该目录中明确添加到搜索路径[文件未找到。

日志:探测位置D:\网络\项目的\ src \框架\ BLL \ OBJ \ o \ Autofac.winmd,因为该目录中明确添加到搜索路径[文件未找到。

日志:探测位置C:\ Program Files文件(x86)的\参考大会\微软\框架\ .NETFramework \ V4.5.1 \ Autofac.exe,因为该目录中明确添加到搜索路径[文件未找到。

日志:探测位置C:\ Program Files文件(x86)的\参考大会\微软\框架\ .NETFramework \ V4.5.1 \ Autofac.dll,因为该目录中明确添加到搜索路径[文件未找到。

日志:探测位置C:\ Program Files文件(x86)的\参考大会\微软\框架\ .NETFramework \ V4.5.1 \ Autofac.winmd,因为该目录中明确添加到搜索路径[文件未找到。

日志:探测位置C:\ Program Files文件(x86)的\参考大会\微软\框架\ .NETFramework \ V4.5.1 \外立面\ Autofac.exe,因为该目录中明确添加到搜索路径[文件未找到。

日志:探测位置C:\ Program Files文件(x86)的\参考大会\微软\框架\ .NETFramework \ V4.5.1 \外立面\ Autofac.dll,因为该目录中明确添加到搜索路径[文件未找到。

日志:探测位置C:\ Program Files文件(x86)的\参考大会\微软\框架\ .NETFramework \ V4.5.1 \外立面\ Autofac.winmd,因为该目录中明确添加到搜索路径[文件未找到。

日志:展望GAC的Autofac,版本= 3.3.0.0,文化=中性公钥= 17863af14b0044da,的ProcessorArchitecture = 86。

日志:展望GAC的Autofac,版本= 3.3.0.0,文化=中性公钥= 17863af14b0044da,的ProcessorArchitecture = MSIL。

日志:展望GAC的Autofac,版本= 3.3.0.0,文化=中性公钥= 17863af14b0044da。

日志:程序集autofac,版本= 3.3.0.0,文化=中性公钥= 17863af14b0044da'没有被发现。

================================================== =============

   在PostSharp.Sdk。codeModel.Domain.GetAssembly(IAssemblyName的AssemblyName,BindingOptions bindingOptions)

   在PostSharp.Sdk。codeModel.AssemblyRefDeclaration。^ 5YpB0scd(BindingOptions
_0)

   在

PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask ^ SgrhoGlQ(AssemblyRefDeclaration
_0)

   在PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask ^ + GwnKh4ZYHu3()在PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.Execute()在PostSharp.Sdk.Extensibility.Project.ExecutePhase(字符串相)在PostSharp.Sdk.Extensibility .Project.Execute()在PostSharp.Hosting.PostSharpObject.ExecuteProjects()在PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation)。 D:\网络\项目的\ src \框架\ BLL \ BLL.csproj BLL
 

有谁知道这是哪里来的,我怎么能解决这个问题?在过去,我创建了一些项目,Autofac 3.3.0。难道这是一些缓存? PostSharp和Autofac是不是在我的GAC。

解决方案

好了,我已经找到了答案。不知怎的,PostSharp是找错了装配在错误的位置。只需添加到您的csproj文件来解决它:

<$p$p><$c$c><PostSharpHostConfigurationFile>$(SolutionDir)path\to\your\web.config</PostSharpHostConfigurationFile>

I am setting up a new solution in which I want to use the latest Autofac (3.4) and PostSharp 3.1.42. After referencing the NuGet packages I get the following error and I can't figure out what is going on. I never selected Autofac 3.3.0 package.

packages.config:

  <package id="Autofac" version="3.4.0" targetFramework="net451" />
  <package id="Autofac.Extras.Multitenant" version="3.1.1" targetFramework="net451" />
  <package id="Autofac.Mvc5" version="3.3.0" targetFramework="net451" />
  <package id="PostSharp" version="3.1.42" targetFramework="net451" />

MSBuild log:

Error   3   Unhandled exception (3.1.43.0, 32 bit, CLR 4.5, Release): PostSharp.Sdk.CodeModel.AssemblyLoadException: Cannot find assembly 'autofac, version=3.3.0.0, culture=neutral, publickeytoken=17863af14b0044da'. [Version mismatch]

============ PostSharp Assembly Loading Log ===================

LOG: Finding the assembly with binding identity 'autofac, version=3.3.0.0, culture=neutral, publickeytoken=17863af14b0044da'.

LOG: Found file 'D:\web\Project\packages\Autofac.3.4.0\lib\net40\Autofac.dll' with identity 'autofac, version=3.4.0.0, culture=neutral, publickeytoken=17863af14b0044da, processorarchitecture=msil'.

LOG: Reference mismatch for 'D:\web\Project\packages\Autofac.3.4.0\lib\net40\Autofac.dll' [VersionMismatch].

LOG: Probing location 'C:\ProgramData\PostSharp\3.1.43\bin.Release\Autofac.exe' because this directory was explicitly added to the search path [File Not Found].

LOG: Probing location 'C:\ProgramData\PostSharp\3.1.43\bin.Release\Autofac.dll' because this directory was explicitly added to the search path [File Not Found].

LOG: Probing location 'C:\ProgramData\PostSharp\3.1.43\bin.Release\Autofac.winmd' because this directory was explicitly added to the search path [File Not Found].

LOG: Probing location 'D:\web\Project\src\Framework\BLL\bin\Autofac.exe' because this directory was explicitly added to the search path [File Not Found].

LOG: Found file 'D:\web\Project\src\Framework\BLL\bin\Autofac.dll' with identity 'autofac, version=3.4.0.0, culture=neutral, publickeytoken=17863af14b0044da, processorarchitecture=msil'. LOG: Reference mismatch for 'D:\web\Project\src\Framework\BLL\bin\Autofac.dll' [VersionMismatch].

LOG: Probing location 'D:\web\Project\src\Framework\BLL\bin\Autofac.winmd' because this directory was explicitly added to the search path [File Not Found].

LOG: Probing location 'D:\web\Project\src\Framework\BLL\obj\O\Autofac.exe' because this directory was explicitly added to the search path [File Not Found].

LOG: Probing location 'D:\web\Project\src\Framework\BLL\obj\O\Autofac.dll' because this directory was explicitly added to the search path [File Not Found].

LOG: Probing location 'D:\web\Project\src\Framework\BLL\obj\O\Autofac.winmd' because this directory was explicitly added to the search path [File Not Found].

LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Autofac.exe' because this directory was explicitly added to the search path [File Not Found].

LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Autofac.dll' because this directory was explicitly added to the search path [File Not Found].

LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Autofac.winmd' because this directory was explicitly added to the search path [File Not Found].

LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\Autofac.exe' because this directory was explicitly added to the search path [File Not Found].

LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\Autofac.dll' because this directory was explicitly added to the search path [File Not Found].

LOG: Probing location 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\Facades\Autofac.winmd' because this directory was explicitly added to the search path [File Not Found].

LOG: Looking in GAC for Autofac, Version=3.3.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=x86.

LOG: Looking in GAC for Autofac, Version=3.3.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=msil.

LOG: Looking in GAC for Autofac, Version=3.3.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da.

LOG: The assembly 'autofac, version=3.3.0.0, culture=neutral, publickeytoken=17863af14b0044da' was not found.

===============================================================

   at PostSharp.Sdk.CodeModel.Domain.GetAssembly(IAssemblyName assemblyName, BindingOptions bindingOptions)

   at PostSharp.Sdk.CodeModel.AssemblyRefDeclaration.^5YpB0scd(BindingOptions
_0)

   at

PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^SgrhoGlQ(AssemblyRefDeclaration
_0)

   at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.^+GwnKh4ZYHu3() at PostSharp.Sdk.Extensibility.Tasks.MulticastAttributeTask.Execute()  at PostSharp.Sdk.Extensibility.Project.ExecutePhase(String phase)    at PostSharp.Sdk.Extensibility.Project.Execute()    at PostSharp.Hosting.PostSharpObject.ExecuteProjects()    at PostSharp.Hosting.PostSharpObject.InvokeProject(ProjectInvocation projectInvocation).   D:\web\Project\src\Framework\BLL\BLL.csproj BLL

Does anybody know where this is coming from and how I can fix this? In the past I created some projects with Autofac 3.3.0. Could this be some cache? PostSharp and Autofac are not in my GAC.

解决方案

Okay, so I already found the answer. Somehow PostSharp is looking for the wrong assembly in the wrong location. Just add this to your csproj file to fix it:

<PostSharpHostConfigurationFile>$(SolutionDir)path\to\your\web.config</PostSharpHostConfigurationFile>

这篇关于PostSharp AssemblyLoadException Autofac的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-05 19:21