PostSharp 和 EntityFramework 5 不能一起工作



我正在尝试将我的MVC 3项目升级到MVC 4,当我安装EF5时,PostSharp不允许编译该项目。我在下面收到错误。花几个小时尝试解决问题,没有任何运气。PostSharp指的是entityframework, version=4.3.1.0但是我的项目中没有这样的版本,我只留下了5.0 version.即使使用外部文本编辑器搜索所有项目文件也不会给出"4.3.1.0"的任何搜索结果。所以我不知道PostSharp从哪里捡到它。有什么建议如何解决问题吗?

Error   2   Unhandled exception (2.1.7.28, 32 bit, CLR 4.0, Release): PostSharp.Sdk.CodeModel.AssemblyLoadException: Cannot find assembly 'entityframework, version=4.3.1.0, culture=neutral, publickeytoken=b77a5c561934e089'. [Version mismatch]
============ PostSharp Assembly Loading Log ===================
LOG: Finding the assembly with binding identity 'entityframework, version=4.3.1.0, culture=neutral, publickeytoken=b77a5c561934e089'.
LOG: Probing location 'C:UsersAdministratorProjectsPCtrunkpackagesEntityFramework.5.0.0libnet45EntityFramework.dll' because this file was explicitly added to the search path.
LOG: File 'C:UsersAdministratorProjectsPCtrunkpackagesEntityFramework.5.0.0libnet45EntityFramework.dll' has identity 'entityframework, version=5.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089, processorarchitecture=msil'.
LOG: File 'C:UsersAdministratorProjectsPCtrunkpackagesEntityFramework.5.0.0libnet45EntityFramework.dll' does not match the reference.
LOG: Probing location 'C:UsersAdministratorProjectsPCtrunkpackagesPostSharp.2.1.7.28toolsReleaseEntityFramework.exe' because this directory was explicitly added to the search path.
LOG: The file 'C:UsersAdministratorProjectsPCtrunkpackagesPostSharp.2.1.7.28toolsReleaseEntityFramework.exe' could not be found.
LOG: Probing location 'C:UsersAdministratorProjectsPCtrunkpackagesPostSharp.2.1.7.28toolsReleaseEntityFramework.dll' because this directory was explicitly added to the search path.
LOG: The file 'C:UsersAdministratorProjectsPCtrunkpackagesPostSharp.2.1.7.28toolsReleaseEntityFramework.dll' could not be found.
LOG: Probing location 'C:UsersAdministratorProjectsPCtrunkPCEntityFramework.exe' because this directory was explicitly added to the search path.
LOG: The file 'C:UsersAdministratorProjectsPCtrunkPCEntityFramework.exe' could not be found.
LOG: Probing location 'C:UsersAdministratorProjectsPCtrunkPCEntityFramework.dll' because this directory was explicitly added to the search path.
LOG: The file 'C:UsersAdministratorProjectsPCtrunkPCEntityFramework.dll' could not be found.
LOG: Probing location 'C:UsersAdministratorProjectsPCtrunkPCbinEntityFramework.exe' because this directory was explicitly added to the search path.
LOG: The file 'C:UsersAdministratorProjectsPCtrunkPCbinEntityFramework.exe' could not be found.
LOG: Probing location 'C:UsersAdministratorProjectsPCtrunkPCbinEntityFramework.dll' because this directory was explicitly added to the search path.
LOG: File 'C:UsersAdministratorProjectsPCtrunkPCbinEntityFramework.dll' has identity 'entityframework, version=5.0.0.0, culture=neutral, publickeytoken=b77a5c561934e089, processorarchitecture=msil'.
LOG: File 'C:UsersAdministratorProjectsPCtrunkPCbinEntityFramework.dll' does not match the reference.
LOG: Probing location 'C:UsersAdministratorProjectsPCtrunkPCobjDebugEntityFramework.exe' because this directory was explicitly added to the search path.
LOG: The file 'C:UsersAdministratorProjectsPCtrunkPCobjDebugEntityFramework.exe' could not be found.
LOG: Probing location 'C:UsersAdministratorProjectsPCtrunkPCobjDebugEntityFramework.dll' because this directory was explicitly added to the search path.
LOG: The file 'C:UsersAdministratorProjectsPCtrunkPCobjDebugEntityFramework.dll' could not be found.
LOG: Probing location 'C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5EntityFramework.exe' because this directory was explicitly added to the search path.
LOG: The file 'C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5EntityFramework.exe' could not be found.
LOG: Probing location 'C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5EntityFramework.dll' because this directory was explicitly added to the search path.
LOG: The file 'C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5EntityFramework.dll' could not be found.
LOG: Probing location 'C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesEntityFramework.exe' because this directory was explicitly added to the search path.
LOG: The file 'C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesEntityFramework.exe' could not be found.
LOG: Probing location 'C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesEntityFramework.dll' because this directory was explicitly added to the search path.
LOG: The file 'C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.5FacadesEntityFramework.dll' could not be found.
LOG: Looking in GAC for EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=x86.
LOG: Looking in GAC for EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=msil.
LOG: Looking in GAC for EntityFramework, Version=4.3.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089.
LOG: The assembly 'EntityFramework_28' was not found.
===============================================================
   at PostSharp.Sdk.CodeModel.Domain.GetAssembly(IAssemblyName assemblyName, BindingOptions bindingOptions)
   at PostSharp.Sdk.CodeModel.AssemblyRefDeclaration.GetAssemblyEnvelope()
   at PostSharp.Sdk.CodeModel.TypeRefDeclaration.GetTypeDefinition(BindingOptions bindingOptions)
   at PostSharp.Sdk.CodeModel.TypeRefDeclaration.GetTypeDefinition()
   at ^I3av2ouCqwmI.^4+F3cylo(INamedType _0, INamedType _1, BindingOptions _2)
   at PostSharp.Sdk.CodeModel.TypeRefDeclaration.^A9yFoe2uB3TC(ITypeSignature _0, BindingOptions _1)
   at ^I3av2ouCqwmI.^4+F3cylo(IMethodSignature _0, IMethodSignature _1, BindingOptions _2)
   at PostSharp.Sdk.CodeModel.Binding.MethodSignatureComparer.Equals(IMethodSignature x, IMethodSignature y)
   at System.Collections.Generic.Dictionary`2.FindEntry(TKey key)
   at System.Collections.Generic.Dictionary`2.TryGetValue(TKey key, TValue& value)
   at ^/vWxD3eYDOIx.^wdkNIZCy[??0](^/fRRnkiTvxqu _0, ??0 _1, ^EyL1LQX01Ck8 _2, ^0RC0kpHqS6Uy _3, Dictionary`2 _4, Int32 _5, Int32 _6)
   at PostSharp.Sdk.Binary.ModuleWriter.SetMemberSignatureIndex(MemberRefDeclaration _0, ^EyL1LQX01Ck8 _1, ^0RC0kpHqS6Uy _2)
   at PostSharp.Sdk.Binary.ModuleWriter.WriteMemberRef(MemberRefDeclaration _0, MetadataToken _1)
   at PostSharp.Sdk.Binary.ModuleWriter.GetMappedDeclarationToken(MetadataDeclaration _0)
   at PostSharp.Sdk.Binary.ModuleWriter.SetMappedMetadataToken(MetadataDeclaration _0, UInt32* _1)
   at ^R00FfLNj7vE0.^rk33N/hO(OpCodeNumber _0, MetadataDeclaration _1)
   at ^R00FfLNj7vE0.EmitInstructionMethod(OpCodeNumber _0, IMethod _1)
   at PostSharp.Sdk.CodeModel.Instruction.Write(BaseInstructionWriter writer, InstructionPrefixes allowedPrefixes)
   at ^zpGNRK5nUM9z.^x98p/iJs13L+(InstructionReader _0)
   at PostSharp.Sdk.CodeModel.MethodBodyDeclaration.^uPrQJ6gs(InstructionBlock _0, IMethodBodyVisitor[] _1, MethodBodyVisitLevel _2, InstructionAction _3, InstructionReader _4, InstructionBlockExceptionHandlingKind _5)
   at PostSharp.Sdk.CodeModel.MethodBodyDeclaration.^uPrQJ6gs(InstructionBlock _0, IMethodBodyVisitor[] _1, MethodBodyVisitLevel _2, InstructionAction _3, InstructionReader _4, InstructionBlockExceptionHandlingKind _5)
   at ^zpGNRK5nUM9z.^e2BtLyuT(^Kh85h0nXrulm& _0, Int32& _1)
   at ^zpGNRK5nUM9z.^SkiT(^ceSOybcTEumb _0)
   at PostSharp.Sdk.Binary.ModuleWriter.WriteMethodBodies(^ceSOybcTEumb _0, UInt32 _1)
   at ^Up6wxUIUnN6a.^VfvrABjR()
   at ^Up6wxUIUnN6a.^SkiT()
   at ^cyC/TYSlPGB/.^wvPm(^RtksFin57NJ8 _0, ^8gP93Xsl+Imn _1)
   at PostSharp.Sdk.Extensibility.Tasks.CompileTask.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)  C:UsersAdministratorProjectsPCtrunkPCPOSTSHARP   PC

我认为您可能在app.config中有一些程序集绑定策略,这使得CLR寻找v5.0而不是v4.3.1。PostSharp不支持app.config中的绑定策略,而只支持系统范围的绑定策略(例如将.NET 1.0重定向到2.0的策略)。

PostSharp 3 支持app.config中的绑定策略,但在撰写本文时,此功能尚未记录,PostSharp 3 仍然是 CTP。

目前唯一的解决方案是确保项目的所有组件和引用都具有指向 v5.0 的引用(链接),因此不需要绑定策略。

最新更新