Je suis un utilisateur avide de PostSharp et j'utilise sa licence "Essentials". J'essaie de mettre à jour mon code DotNetCore de 1.1 à 2.0 et PostSharp ne fonctionne plus comme prévu. J'ai créé une application simple de la console qui fonctionne lorsqu'il est 1.1 et quand je passe à 2.0, il lance une exception non gérée avec l'erreur suivantePostsharp 5.0.31.0 dans Dot Net Core 2.0 - Impossible de trouver une méthode nommée get_Assembly dans le type System.Reflection.TypeInfo correspondant au prédicat donné
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
L'exemple de code est droite assez en avant
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");
}
}
}
est-il quelque chose qui me manque? J'ai même effacé le dossier "C: \ ProgramData \ Postsharp" mais rien ne fonctionne.
Est-ce un problème de licence? Est-ce que quelqu'un d'autre a eu du succès avec une mise à niveau vers DotNetCore 2.0 de 1.1?
J'ai même désinstallée et réinstallée PostSharp 5.0.31.0 ...
La prise en charge de .NET Standard 2.0 et .NET Core 2.0 est prévue pour PostSharp 5.1. –