.NET 'Private' Application
I create a .NET (WPF) Application, and compile it to .EXE. Then I create a second project, and add a reference to the compiled .exe, I can see all开发者_Python百科 the classes and forms, and can use them for automation, etc.
I want to prevent other people from using my compiled .exe as a .dll, so I changed all my classes to 'Friend' instead of 'Public', but this doesn't work for the (wpf) forms. And every time I create a new class, I must remember to change it to 'Friend'.
So, is there a better solution for preventing your app to be used as a DLL?
UPDATE: I am aware that .NET is easily decompilable, and that the access modifiers can be modified by a determined 'cracker'. But I only want to make it a little harder, than just adding a reference.
Maybe i should have stated my question differently: How can I make all forms/classes in my project 'Friend', without specifying it for every item.
There's little you can do, ultimately; reflection will let you get around any access declarations you make.
You could obfuscate your code to make it more difficult to understand and therefore use, but it won't protect against a determined intrusion.
The best way to do this is to put something in the end-user license agreement saying that its not allowed.
Changing a class to friend will not prevent someone using it if they really want to. All they have to do is to modify the DLL to make the class public and your protection system has failed.
精彩评论