views:

26

answers:

1

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?

+1  A: 

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.

Hans Passant
I don't understand. If I can use a class constructor for "Setup" and AppDomain.ProcessExit event for "TearDown", why isn't that enough? Why do I need the retail edition?
brickner
Well, maybe it will work. Have you tried?
Hans Passant
This seems to work. I still don't see any runs in CodePlex, but this might take a while. I also can't access my PreEmptive account - do you know how do I get a username and password after I register?
brickner
No. I could research it, but the odds that you'll recognize my efforts with a helpful vote have been zero this month. Strange, considering its cost.
Hans Passant
To access the PreEmptive portal, go to your project stats page (http://pcapdotnet.codeplex.com/stats) and click on "visit the Runtime Intelligence Portal". No login is necessary.
jwanagel
Thanks. Anyways, it seems to work. I have simply put the entire PreEmptive usage in one dll, compiled it, dotfuscated it, resigned it and used it in other dlls.
brickner