Question

I write in-house software for a company.

I always want to leverage OOP techniques as best as I can. In this thinking, I want to create a Data Access Layer (DAL) isolated in its own .DLL.

What can I do to limit the access of the DAL DLL to only my business logic layer DLL?

The last thing I need is someone in the company with a little programming knowledge plus access to the system (via Active Directory) to install .NET Express, reference my .DLL, and start firing off data access code outside of the real system. Are there any .NET mechanisms I can employ to limit a DLL to be used only by a pre-selected host application/DLL?

Was it helpful?

Solution

The easiest way to limit access from a code perspective is to use friend assemblies. You can make all of the types in your Data Access Layer DLL Friend / Internal. Then only add your Business Logic Layer components as friends and they will be able to use the types. Anyone else in the company will not since they don't have DLL's with internal access.

Documentation - http://msdn.microsoft.com/en-us/library/bb384772.aspx

OTHER TIPS

You could probably make use of the Application Licensing framework build into .NET using the LicenseProvider class. Depending on how you implemented it, having a DLL would not be enough to use your library... they would also need some sort of license file, or provide a license key. Here is a good article on how to start using it.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top