I have a execution project and a library project. The lib proj targets netstandard20 and contains classes with weavers, while the exe proj is targeting netcore21.
Some aspect attributes have a enum property, but below exception is thrown when invoking the annotated method.
Unhandled Exception: System.TypeLoadException: Could not load type 'System.ConsoleColor' from assembly 'MrAdviceSamples.Lib, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
ps. everything works fine if the enum is a constructor argument.
ps.. also fine when class Bean defined in the exe proj.
[AttributeUsage(validOn: AttributeTargets.Method)]
public class MyProudAdvice : Attribute, IMethodAdvice
{
public MyProudAdvice()
{
}
public MyProudAdvice(ConsoleColor option)
{
Option = option;
}
public ConsoleColor Option { get; set; }
public void Advise(MethodAdviceContext context)
{
Console.WriteLine("before");
context.Proceed();
Console.WriteLine("after");
}
}
public class Bean
{
[MyProudAdvice(Option = ConsoleColor.Black)] // this fails
//[MyProudAdvice(ConsoleColor.Black)] // this works
public void MyProudMethod()
{
Console.WriteLine("do");
}
}
Hi,
I have a execution project and a library project. The lib proj targets netstandard20 and contains classes with weavers, while the exe proj is targeting netcore21. Some aspect attributes have a enum property, but below exception is thrown when invoking the annotated method.
ps. everything works fine if the enum is a constructor argument. ps.. also fine when class Bean defined in the exe proj.