Restricting .DLL access
<p>Lets say I have two .dlls, Dll1 and Dll2. </p>

<p>DLL1 uses or makes calls into DLL2.  </p>

<p>Is there a way I can ensure that it is DLL1 and only DLL1 who's making the calls into DLL2? </p>

<p><strong>UPDATE 1</strong>  </p>

<p>The reason behind this is:  </p>

<p>I have a WinForms solution, and to keep it simple, it consists of a  view project and a controllers project (which generates a seperate .dll). After installing the application on a client machine, I realise it is possible to view the application .dlls in it's "Program Files" folder.  Somebody could potentially add a reference to the controller's .dll. I'd like to avoid this so that it's the view project and only the view project who's making the calls.</p>

<p><strong>UPDATE 2</strong><br>
One of the reasons I like separating controllers into a separate project is that I could potentially have many different view projects calling into and using the same controllers.  I then would only need to maintain one controller project for all views. For instance a win forms application and a test project or even a web site using the same controller project.    But taking this approach , I would then be faced with the security problem I mention (avoiding and controlling improper use of my dll). </p>

<p>So I have one approach,  compiling to one .dll, by using different folders, which I believe is correct and solves my security problem, but it conditions me to only having one view.</p>

<p>On the other hand if I have separate projects I am faced with the security issue.  </p>

<p>I am still dubious as to how I should go about this as I would still like to continue using different projects for the reasons I mention.  </p>

<p><strong>UPDATE 3</strong><br>
Any suggestions on using the StrongNameIdentityPermission permission demand?<br>
<a href="http://msdn.microsoft.com/en-us/library/ff648663.aspx" rel="nofollow">http://msdn.microsoft.com/en-us/library/ff648663.aspx</a>   (see: Restrict Which Code Can Call Your Code)<br>
<a href="http://msmvps.com/blogs/manoj/archive/2004/10/20/16208.aspx" rel="nofollow">http://msmvps.com/blogs/manoj/archive/2004/10/20/16208.aspx</a>  <a href="http://www.morganskinner.com/Articles/StrongNameIdentityPermission/" rel="nofollow">http://www.morganskinner.com/Articles/StrongNameIdentityPermission/</a></p>

<p>Thanks</p>
