问题描述
在他们网站上的示例中,PostSharp 有一个在主系统程序集中拦截调用的演示.我已经尝试了几次在我没有源代码的程序集上设置和复制上述拦截调用,但没有成功.
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.
类似:
[程序集:Trace("MyCategory", AttributeTargetTypes = "My.BusinessLayer.*")]
[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...
谢谢.
推荐答案
您可以通过指定来跟踪其他程序集的方法:
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.
这篇关于PostSharp 关于我没有来源的程序集的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!