<p>When I try to run a .NET assembly (<code>boo.exe</code>) from a network share (mapped to a drive), it fails since it's only partially trusted:</p>

<pre><code>Unhandled Exception: System.Security.SecurityException: That assembly does not allow partially trusted callers.
   at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(Assembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandle rmh, SecurityAction action, Object demand, IPermission permThatFailed)
   at BooCommandLine..ctor()
   at Program..ctor()
   at ProgramModule.Main(String[] argv)
The action that failed was:
LinkDemand
The assembly or AppDomain that failed was:
boo, Version=0.0.0.0, Culture=neutral, PublicKeyToken=32c39770e9a21a67
The Zone of the assembly that failed was:
Intranet
The Url of the assembly that failed was:
file:///H:/boo-svn/bin/boo.exe
</code></pre>

<p>With instructions from <a href="http://www.georgewesolowski.com/blog/PermaLink,guid,4cc5fcdf-cc68-4cf0-a083-b22a8bdc92d6.aspx" rel="nofollow noreferrer">a blog post</a>, I added a policy to the .NET Configuration fully trusting all assemblies with <code>file:///H:/*</code> as their URL. I verified this by entering the URL <code>file:///H:/boo-svn/bin/boo.exe</code> into the <em>Evaluate Assembly</em> tool in the .NET Configuration and noting that boo.exe had the <em>Unrestricted</em> permission (which it didn't have before the policy).</p>

<p>Even with the permission, <code>boo.exe</code> does not run. I still get the same error message.</p>

<p>What can I do to debug this problem? Is there another way to run "partially trusted" assemblies from network shares without having to change something for every assembly I want to run?</p>

[{'answer_id': 24477, 'author': 'Judah Gabriel Himango', 'author_id': 536, 'author_profile': 'https://Stackoverflow.com/users/536', 'pm_score': 4, 'selected': True, 'text': '<p>With .NET 3.5 SP1, .NET assemblies running from UNC shares have full permissions. </p>\n\n<p>See Brad Abrams\'s <a href="http://blogs.msdn.com/brada/archive/2007/10/26/adhoc-poll-allowing-net-exes-to-run-off-a-network-share.aspx" rel="noreferrer">Allow .exes to be run off a network shares</a> for workaround and discussions, and finally the follow up <a href="http://blogs.msdn.com/brada/archive/2008/08/13/net-framework-3-5-sp1-allows-managed-code-to-be-launched-from-a-network-share.aspx" rel="noreferrer">.NET 3.5 SP1 allows managed code to be launched from a network share</a>.</p>\n'}, {'answer_id': 24480, 'author': 'Mike Powell', 'author_id': 205, 'author_profile': 'https://Stackoverflow.com/users/205', 'pm_score': 0, 'selected': False, 'text': '<p>I think you want to add the <a href="http://msdn.microsoft.com/en-us/library/system.security.allowpartiallytrustedcallersattribute.aspx" rel="nofollow noreferrer">AllowPartiallyTrustedCallers</a> attribute to your assembly.  The error message implies that something that\'s calling into your boo.exe assembly is not fully trusted, and boo.exe doesn\'t have this attribute allowing it.</p>\n'}, {'answer_id': 24484, 'author': 'Tim Cochran', 'author_id': 2626, 'author_profile': 'https://Stackoverflow.com/users/2626', 'pm_score': 2, 'selected': False, 'text': "<p>Take a look at the 'caspol.exe' program (provided with .NET runtimes).  You will have to do this on the machine you are trying to run the application from.  I wasn't able to 'mark' and assembly (probably just me).  However, using caspol and setting up the proper permission for my app, LocalIntranet_Zone, fix my similar issue.</p>\n\n<p>I have heard (but haven't tried it yet), that .NET 3.5 sp1 removed this tighten security requirement (not allowing .NET assemblies to reside on a share by default).</p>\n"}, {'answer_id': 26376, 'author': 'Tomi Kyöstilä', 'author_id': 616, 'author_profile': 'https://Stackoverflow.com/users/616', 'pm_score': 2, 'selected': False, 'text': '<p>I resolved the problem by using <a href="http://msdn.microsoft.com/en-us/library/cb6t8dtz%28VS.80%29.aspx" rel="nofollow noreferrer"><code>caspol</code></a> as instructed in Johnny Hughes\' blog post <a href="http://johnnynine.com/blog/RunningANetApplicationFromANetworkShare.aspx" rel="nofollow noreferrer">Running a .Net application from a network share</a>:</p>\n\n<pre><code>caspol -addgroup 1.2 -url file:///H:/* FullTrust\n</code></pre>\n\n<p>It seems the .NET Configuration GUI for managing the policies simply doesn\'t work.</p>\n'}]
['https://Stackoverflow.com/questions/24468', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/616/']