tags:

views:

46

answers:

2

Hi,

I have an assembly and want to restrict the assemblies and applications that can call/use this assemblies functionality. Can anyone provide detailed information on how this can be achieved ?

From what I have read on the internet this is not possible because any "fully trusted" assembly will automatically be granted access.

I am using .NET 2.0 and 3.5 and the solution needs to be compatible with both versions of the framework.

Thanks in advance ;-)

+1  A: 

I asked something similar maybe the answer will be of some help: http://stackoverflow.com/questions/2852812/c-ensuring-an-assembly-is-called-via-a-specified-assembly

Adam Driscoll
Thanks guys both solutions work well in different circumstances. InternalsVisibleTo is an easy way to make sure that a single calling assembly has permission to my assembly. While the solution provided by Adam is much easier to implement where I want multiple assemblies signed with the same snk to have access to my assembly. Thanks for the help!
A: 

I like Adam's answer (from link), but want to add one more way. you can make everything internal instead of public, then use attribute InternalsVisibleTo attribute ( http://msdn.microsoft.com/en-us/library/system.runtime.compilerservices.internalsvisibletoattribute.aspx )

Andrey