Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Limiting Access to a DLL in .NET

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?

like image 502
HardCode Avatar asked Feb 27 '23 14:02

HardCode


1 Answers

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

like image 120
JaredPar Avatar answered Mar 08 '23 01:03

JaredPar