简体   繁体   English

如何给.net中的DLL提供访问限制

[英]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. 我有一个三层应用程序(UI,业务层,数据层)。我的要求是我的数据层只能由业务层访问,而业务层应该只能由UI层访问。

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. 这意味着即使我在UI层中添加了adtalayer的引用,它也不能访问Datalayer中的方法。

I should be able to create DLL's with access protection. 我应该能够创建具有访问保护的DLL。

please suggest a solution for this? 请为此提出解决方案?

Thanks 谢谢

SC SC

您可以标记键类或方法在您的业务和数据层的构造函数internal ,然后使用InternalVisibleTo属性扩展,获得相应的组件。

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. 我不确定这是最简单还是最好的方法,但是PostSharp会做您想要的。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM