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