In the examples on their website, PostSharp has a demo of intercepting calls in main system assemblies. I have tried a few times to setup and replicate said intercept calls on assemblies I don't have the source code for with no success.
My approach was to simply place the assembly level attribute targeting the namespace and method I wanted to instrument. This has never worked for me.
something like:
[assembly: Trace("MyCategory", AttributeTargetTypes = "My.BusinessLayer.*")]
Am I missing something here? Can I not do a runtime injection of my instrumentation aspect on a assembly if I don't have the source pulled in for it? I thought I could do runtime injections...
Thanks.
You can trace methods of other assemblies by specifying:
[assembly: Trace("MyCategory",
AttributeTargetAssemblies="xyz",
AttributeTargetTypes = "My.BusinessLayer.*")]
However, the external assembly will not be modified! Only calls from the current project to the external assembly can be modified.
It is currently not easy to modify assemblies you don't have the source of. This is possible, but is considered an advanced scenario and requires custom coding.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With