0
我是PostSharp的狂熱用戶,我正在使用他們的「Essentials」許可證。我試圖將我的DotNetCore代碼從1.1升級到2.0,並且PostSharp不再按預期工作。我創建了一個簡單的控制檯應用程序時,它是1.1,當我切換到2.0,它拋出,出現以下錯誤未處理的異常的作品Post URL在Dot Net Core 2.0中的5.0.31.0 - 在System.Reflection.TypeInfo類型中找不到名爲get_Assembly的方法,它與給定的謂詞匹配
Unhandled exception (5.0.31.0, postsharp-net40-x86-srv.exe, CLR 4.0.30319.460798, Release): PostSharp.Sdk.CodeModel.BindingException: Cannot find a method named get_Assembly in type System.Reflection.TypeInfo matching the given predicate.
at PostSharp.Sdk.CodeModel.ModuleDeclaration.FindMethod(TypeDefDeclaration typeDef, String methodName, BindingOptions bindingOptions, Predicate`1 predicate)
at PostSharp.Sdk.CodeModel.InstructionWriterExtensions.EmitAssemblyOf(BaseInstructionWriter writer, ITypeSignature type, TargetFramework targetFramework)
at ^RIeE65/59SwT.^Pzwdu7KO.Emit(InstructionWriter _0, InstructionBlock _1, TypeInitializationClientScopes _2)
at PostSharp.Sdk.AspectInfrastructure.TypeInitializationManager.^m\.QsIzuy.^B00Ft6I1yuz9(WeavingContext _0, InstructionBlock _1)
at PostSharp.Sdk.CodeWeaver.Weaver.^MNbVhYZw(MethodDefDeclaration _0)
at PostSharp.Sdk.CodeWeaver.Weaver.Weave()
at PostSharp.Sdk.AspectInfrastructure.TypeInitializationManager.^r4DISfQ8()
at ^YRTd8AcBbva/.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)
Context:
Weaver.WeaveMethod({PostSharp.ImplementationDetails_84298fea.<>z__a_2.#cctor}). ConsoleApp1 C:\Users\cselbert\.nuget\packages\postsharp\5.0.31\build\PostSharp.targets 329
的示例代碼是直線前進足夠
using System;
using PostSharp.Aspects;
using PostSharp.Serialization;
namespace ConsoleApp1
{
class Program
{
static void Main(string[] args)
{
var aspectTest = new AspectTest();
aspectTest.ThrowException();
Console.ReadLine();
}
}
[PSerializable]
public sealed class HandleExceptionAttribute : OnExceptionAspect
{
public override void OnException(MethodExecutionArgs eventArgs)
{
Console.WriteLine(eventArgs.Instance);
eventArgs.FlowBehavior = FlowBehavior.Return;
}
}
[HandleException]
public class AspectTest
{
public void ThrowException()
{
throw new Exception("Throwing Exception");
}
}
}
有沒有我錯過了什麼?我甚至清除了「C:\ ProgramData \ Postsharp」文件夾,但沒有任何工作。
這是授權問題嗎?有沒有人從1.1升級到DotNetCore 2.0?
我甚至卸載並重新安裝PostSharp 5.0.31.0 ...
計劃在PostSharp 5.1中支持.NET Standard 2.0和.NET Core 2.0。 –