[英]Controlling Access to .NET Assemblies
I have a group of dlls for WCF services. 我有一组用于WCF服务的dll。 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 these features.
包含合同,接口等。我想在API(客户端)中重用此代码,但不希望API的使用者使用这些功能。
Is there a way to say core.dll can only be used by clientcore.dll? 有没有办法说core.dll只能由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
. 好了,您可以为
core.dll
的所有成员提供internal
访问修饰符,然后使用InternalsVisibleToAttribute
授予对clientcore.dll
访问clientcore.dll
。
To make life easier for your clients, you might actually want to merge core.dll
into clientcore.dll
using ILmerge . 为了使客户的生活更轻松,您实际上可能希望使用ILmerge将
core.dll
合并到clientcore.dll
中。 That way your callers don't need to copy a DLL they never use directly. 这样,您的调用者就无需复制从未直接使用过的DLL。
是的,将您的类型设置为内部,然后使用好友组装机制 (通过InternalsVisibleToAttribute类)。
sure, it's called: 当然,它叫做:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.