Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top