jaklucky
jaklucky

Reputation: 163

License Check before executing

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

Upvotes: 0

Views: 1346

Answers (3)

Leif Andersen
Leif Andersen

Reputation: 22342

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.

Upvotes: 0

Maja Piechotka
Maja Piechotka

Reputation: 7216

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).

Upvotes: 0

EgorBo
EgorBo

Reputation: 6152

Maybe static constructor will help you

Upvotes: 1

Related Questions