我没有源代码的程序集上的 PostSharp

发布于 2024-09-08 16:32:47 字数 319 浏览 8 评论 0原文

在其网站上的示例中,PostSharp 有一个拦截主系统程序集中调用的演示。我曾多次尝试在没有源代码的程序集上设置和复制所述拦截调用,但没有成功。

我的方法是简单地放置针对我想要检测的命名空间和方法的程序集级别属性。这对我来说从来没有用过。

类似于:

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

我在这里遗漏了什么吗?如果我没有为其拉入源代码,我是否可以不对程序集进行仪器方面的运行时注入?我以为我可以进行运行时注入...

谢谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

怀念你的温柔 2024-09-15 16:32:47

您可以通过指定来跟踪其他程序集的方法:

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

但是,外部程序集不会被修改!只能修改从当前项目到外部程序集的调用。

目前,修改没有源代码的程序集并不容易。这是可能的,但被认为是高级场景并且需要自定义编码。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文