tags:

views:

99

answers:

3

Hi,

We have an application (written in C# on .NET Framework 3.5) that is licensed using our custom licensing mechanism. In the current implementation, in each method we first check for if the machine has valid license or not. To me, it is little bit awkward. Is there any way to let the runtime check for the license before creating the object or excuting a method? Will writing a custom attribute solves this problem?

Any ideas or solutions are greatly appreciated.

Thank you, Suresh

+1  A: 

Maybe static constructor will help you

Nagg
A: 

You can either check in main method/static constructor.

If it does not suit you (license is for year and it is a server which can be run years without restart - unlikely for Windows but still possible) check if AOP is not what you want. This would be a direct one-to-one refactoring (however much cleaner).

Maciej Piechotka
A: 

Perhaps you could check to make sure that the person has a valid licence when the code is imported. Say, it will decrypt the libraries when the proper licence is there.

Leif Andersen