7

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.

4

1 に答える 1

5

以下を指定することにより、他のアセンブリのメソッドをトレースできます。

[assembly: Trace("MyCategory",
                 AttributeTargetAssemblies="xyz",
                 AttributeTargetTypes = "My.BusinessLayer.*")]

ただし、外部アセンブリは変更されません。現在のプロジェクトから外部アセンブリへの呼び出しのみを変更できます。

現在、ソースがないアセンブリを変更するのは簡単ではありません。これは可能ですが、高度なシナリオと見なされ、カスタムコーディングが必要です。

于 2010-07-07T17:40:48.427 に答える