Dot Net Core 2.0 中的 Postsharp 5.0.31.0 - 在 System.Reflection



我是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:Userscselbert.nugetpackagespostsharp5.0.31buildPostSharp.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.0 版本看起来与 .NET Core 2.0 和 .Net Standard 2.0 不兼容

。不兼容

相关内容

最新更新