Closed Sago92 closed 3 years ago
Hi,
events are not methods (event handlers are), so they can not be intercepted, unfortunately.
I think you misunderstood my question. I don't want do put the advice directly on the event definition. I want to use an advice on a event handler method. As you mentioned event handlers are methods, but why does the method advice do not work on them?
Oops sorry! It should work on event handlers, declared as named methods (I may have disabled it on labmdas). Do you have a small sample of the problem?
I'll build a test application and I can't explain it myself, but everything seems to work fine in a test console application. I tried it with named methods in a static, non static and async context. I'll need to further investigate the issue in my application and will come back to you if I'll find the issue (either in MrAdvice or my application). Thanks for your fast responses for now!
I'll found the issue ... My solution has 2 projects. 1x Repostiory project (contains entity and non business logic classes) 1x Main project (web application with MVC structure) In the repository project I installed the MrAdvice Nuget Package and developed the advice. All tested methods (non event handler) worked because they were located at the repostiory projekt. All event handler I tested were located at the main project. And in the web projekt I didn't installed the MrAdvice Nuget Package. After installing the Nuget Package in the web project the advice worked perfectly. Again, thank you very much for the fast responses and I am sorry for the inconvenient. Greetings
Good news, then!
Good evening,
today I tried to create an advice that measures the execution time. For normal (IMethodAdvice) and async methods (IMethodAsyncAdvice) I already got it working. My application uses a lot of event driven handler. For thoose handlers the normal IMethodAdvice don't work. Is it possiable to create an advice for event handlers? Are there any examples where I could take a look into?
Thanks in advance for any help Greetings