开发者

Controlling Access to .NET Assemblies

开发者 https://www.devze.com 2023-03-26 09:10 出处:网络
I have a group of dlls for WCF services. The contain contracts, interfaces etc. I would like to reuse this code in the API (client side) but don\'t want the consumers of the API to use thes开发者_JAVA

I have a group of dlls for WCF services. The contain contracts, interfaces etc. I would like to reuse this code in the API (client side) but don't want the consumers of the API to use thes开发者_JAVA技巧e features.

Is there a way to say core.dll can only be used by clientcore.dll?


Well, you can give all the members of core.dll an access modifier of internal and then use InternalsVisibleToAttribute to give access to clientcore.dll.

To make life easier for your clients, you might actually want to merge core.dll into clientcore.dll using ILmerge. That way your callers don't need to copy a DLL they never use directly.


Yes, make your types internal and then use the friend assembly mechanism (via the InternalsVisibleToAttribute class).


sure, it's called:

Code Access Security

0

精彩评论

暂无评论...
验证码 换一张
取 消