作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在设置一个新的解决方案,我想在其中使用最新的 Autofac (3.4) 和 PostSharp 3.1.42。引用 NuGet 包后出现以下错误,我无法弄清楚发生了什么。我从未选择 Autofac 3.3.0 包。
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 日志:
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 中。
最佳答案
好的,所以我已经找到答案了。 PostSharp 以某种方式在错误的位置寻找错误的程序集。只需将其添加到您的 csproj 文件中即可修复它:
<PostSharpHostConfigurationFile>$(SolutionDir)path\to\your\web.config</PostSharpHostConfigurationFile>
关于c# - PostSharp AssemblyLoadException Autofac,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23968550/
我正在设置一个新的解决方案,我想在其中使用最新的 Autofac (3.4) 和 PostSharp 3.1.42。引用 NuGet 包后出现以下错误,我无法弄清楚发生了什么。我从未选择 Autofa
我有几个项目都包含 json.net 6.0.3 NuGet 包。当我添加时: using Newtonsoft.Json; 构建时出现以下错误: 1>F:\TwinkyTalk\TwinkyTalk
我刚开始使用 postsharp/AOP。我想为 C# 制作一些工具来跟踪我为某个软件编写的一些插件的使用情况。 我正在尝试使用 OnMethodBoundaryAspect 类来记录调用方法时某些参
我是一名优秀的程序员,十分优秀!