Reputation: 777
I am a avid user of PostSharp and I am using their "Essentials" license. I am trying to upgrade my DotNetCore code from 1.1 to 2.0 and PostSharp is no longer working as expected. I created a simple console application that works when it is 1.1 and when I switch to 2.0 it throws an Unhandled exception with the following error
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
The sample code is straight forward enough
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");
}
}
}
Is there something I am missing? I have even cleared the "C:\ProgramData\Postsharp" folder but nothing is working.
Is this is License Issue? Has anyone else had success with an upgrade to DotNetCore 2.0 from 1.1?
I even uninstalled and re-installed PostSharp 5.0.31.0...
Upvotes: 0
Views: 318
Reputation: 552
The current 5.0 version of PostSharp looks like it is not compatible with .NET Core 2.0 and .Net Standard 2.0
Upvotes: 1