Securing against dynamic linking in .NET [closed]
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Clo开发者_如何学Csed 7 years ago.
Improve this questionI want to deploy an application with a license attached. However, I want to prevent that my dll can be easily referenced in visual studio.
What are the usual ways of doing this? I was thinking about ngen-ing the application to prevent this, however, then the code becomes architecture dependent. Im not targetting any other architecture/platform besides windows, however, ngen-ing the application after making a release build seems like a workaround to me. Are there any other techniques to achieve this?
You can't ship an ngen-ed image, Ngen.exe must run on the target machine. There's a dedicated service, installed by the .NET installer that takes care of it. It doesn't help protect anything anyway, the original assembly must still be present as well.
.NET has built-in support for licensing but it only works for designable classes. System.ComponentModel.License is the base class declaration. LicFileLicenseProvider is a concrete implementation of it.
You can buy something 3rd party, dongles are unbeatable. Either way, the only true protection you'll get for your IP is in a court of law. Claim copyright in a visible place, ensure your user goes through an explicit license agreement step before using your code.
Code access security (CAS). You can enforce a LinkDemand, all the way down a chain of inheritence or methods or assemblies, that requires that all assemblies linking have the same strong name key and other evidence as you require.
If you are using an installer, you can ngen during installation. SQL Server does this.
You can also obfuscate. It doesn't prevent linking per se, but it does make it difficult to know what the dll does, reducing its "usefulness" to other processes.
What if you change the scope of your classes to Friend
精彩评论