首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >PostSharp AssemblyLoadException Autofac

PostSharp AssemblyLoadException Autofac
EN

Stack Overflow用户
提问于 2014-05-31 09:44:53
回答 1查看 2.1K关注 0票数 2

我正在设置一个新的解决方案,其中我想使用最新的Autofac (3.4)和PostSharp 3.1.42。在引用了NuGet包之后,我得到了下面的错误,我不知道发生了什么。我从未选择过Autofac 3.3.0软件包。

packages.config:

代码语言:javascript
复制
  <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日志:

代码语言:javascript
复制
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

有人知道这是从哪里来的吗?我怎样才能解决这个问题?在过去,我用Autofac 3.3.0创建了一些项目。这可能是一些缓存吗?PostSharp和Autofac不在我的GAC中。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-05-31 09:53:00

好吧,我已经找到答案了。不知怎么的,PostSharp正在寻找错误的装配在错误的位置。只需将此添加到csproj文件以修复它:

代码语言:javascript
复制
<PostSharpHostConfigurationFile>$(SolutionDir)path\to\your\web.config</PostSharpHostConfigurationFile>
票数 7
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/23968550

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档