Dot Net Core 2.0 中的 Postsharp 5.0.31.0 - 在类型 System.Reflection.TypeInfo 中找不到与给定谓词匹配的名为 get_Assembly 的方法
Postsharp 5.0.31.0 in Dot Net Core 2.0 - Cannot find a method named get_Assembly in type System.Reflection.TypeInfo matching the given predicate
我是 PostSharp 的狂热用户,我正在使用他们的 "Essentials" 许可证。我正在尝试将我的 DotNetCore 代码从 1.1 升级到 2.0,而 PostSharp 不再按预期工作。我创建了一个简单的控制台应用程序,它在 1.1 时可以运行,当我切换到 2.0 时,它会抛出一个未处理的异常并出现以下错误
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.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...
当前 5.0 版本的 PostSharp 似乎与 .NET Core 2.0 和 .Net Standard 2.0 不兼容
我是 PostSharp 的狂热用户,我正在使用他们的 "Essentials" 许可证。我正在尝试将我的 DotNetCore 代码从 1.1 升级到 2.0,而 PostSharp 不再按预期工作。我创建了一个简单的控制台应用程序,它在 1.1 时可以运行,当我切换到 2.0 时,它会抛出一个未处理的异常并出现以下错误
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.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...
当前 5.0 版本的 PostSharp 似乎与 .NET Core 2.0 和 .Net Standard 2.0 不兼容