为库而不是应用程序添加运行时智能应用程序分析
我想添加我在 CodePlex 上编写的 .NET 4.0 库的使用情况统计信息。
我尝试按照此处描述的步骤进行操作,但我的问题在于我编写的是一个库并且不是一个应用程序。
步骤之一是放置 Setup
和 Teardown
属性。我考虑过在静态构造函数或每次使用库时运行一次的不同位置添加 Setup
属性。我的问题在于 Teardown
属性,该属性应该放置在结束使用的代码上。我不知道该把这个属性放在哪里。
是否可以获得图书馆的使用统计信息?
也许我可以注册一个在应用程序卸载 dll 时触发的事件?
I want to add usage statistics for a .NET 4.0 library I write on CodePlex.
I try to follow the step described here but my problem lies with the fact that what I write is a library and not an application.
One of the steps is put the Setup
and Teardown
attributes. I thought about adding the Setup
attribute on a static constructor or a different place that will run once per usage of the library. My problem lies with the Teardown
attribute that should be placed on code that ends the usage. I don't know where to put this attribute.
Is it possible to get usage statistics on a library?
Maybe I can register on an event that will fire when the application unloads the dll?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这看起来像是典型的蜜罐赠品,旨在让您使用其混淆器的零售版。这是一项艰巨的任务,很少有人能比先发制人玩得更好。是的,使用属性对于库来说是行不通的。唯一可能的候选人是终结者。并且您不希望您的代码在终结器线程运行时联系某些网站。
看看他们产品的零售版。我敢打赌它有一种方法可以调用通常由混淆器直接注入的方法。类构造函数显然是“Setup”的候选者。 AppDomain.ProcessExit 事件的事件处理程序可能是“Teardown”调用的可能位置。这也可能避免运行混淆器,这在开源项目中并非不可取。
This looks like a typical honeypot giveaway, designed to commit you to the retail edition of their obfuscator. It's a tough business, few play this game better than Preemptive. Yes, using attributes is not going work for a library. The only possible candidate would be a finalizer. And you do not want your code to contact some website while the finalizer thread is running.
Take a look at the retail edition of their product. I bet it has a way to invoke the methods that are normally injected by their obfuscator directly. The class constructor is an obvious candidate for "Setup". An event handler for the AppDomain.ProcessExit event could be a possible location for the "Teardown" call. This also might avoid having to run the obfuscator at all, not undesirable in an open source project.