SNA
SNA

Reputation: 7728

How to give access restriction to DLL's in .net

I have a 3 layer application(UI,Business Layer,Data Layer).My requirement is my datalayer should be only accessible by business layer,and the business layer should be only accessible by UI layer.

That means even if i add a reference of adtalayer in the UI layer,it should not be able to access the methods in Datalayer.

I should be able to create DLL's with access protection.

please suggest a solution for this?

Thanks

SC

Upvotes: 0

Views: 139

Answers (2)

Joel Coehoorn
Joel Coehoorn

Reputation: 415735

You can mark the constructors of key classes or methods in your business and data layers as internal and then use the InternalVisibleTo attribute to extend that access to the appropriate assemblies.

Upvotes: 1

Chris McCall
Chris McCall

Reputation: 10397

Sounds to me like what you're looking for is called "policy injection". I'm not sure if this is the easiest or best way, but PostSharp will do what you want.

Upvotes: 0

Related Questions