Trusting Network Shares with Visual Studio 2010 / .NET Framework v4.0

If you are like me and you store all your code on a server, you will have likely learned about trusting a network share using CasPol.exe. However, when moving from Visual Studio 2008 (.NET Framework 2.0/3.0/3.5) over to Visual Studio 2010 (.NET Framework 4.0), you may find yourself scratching your head.

If you are used to using the Visual Studio Command Prompt to quickly get to CasPol, you may find that some of your projects will not seem to respect your new FullTrust settings. The reason is that, unless you are carefully paying attention, the Visual Studio Command Prompt defaults to adding the .NET Framework 4.0 folder to its path. If your project is still running under .NET Framework 2.0/3.0/3.5, it will require setting CasPol for those versions as well. Just a note, I have also personally had more success with using 1 as a code group instead of 1.2.

To trust a network share for all versions of the .NET Framework, simply call CasPol for each version using the full path as below:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\CasPol -m -ag 1 -url file://YourSharePath\* FullTrust
C:\Windows\Microsoft.NET\Framework\v4.0.30319\CasPol -m -ag 1 -url file://YourSharePath\* FullTrust

4 thoughts on “Trusting Network Shares with Visual Studio 2010 / .NET Framework v4.0

  1. TnT

    Have you run into the issue of Security Warnings that now popup when running an application off of a network share. With framework 2. If you used caspol to add sn key to the machine level as fulltrust, you could launch that assembly (exe) off the network share w/out a Security Warning prompt. But with framework 4 (assemblies compiled to use it), since cas policy is turned off, there seems no way to avoid that prompt. Have you run into this? or figured it out? i’m at a loss as to how to get this working without the message popping up. I figure there has to be some way to add the sn key to group policy (or something) of the machine (local workstation running the app off the share)? in order for all exes with that sn key to be deemed ‘safe’ and not prompt the user.

  2. Robin

    Thanks a lot! I was migrating my VS2008 dev environment to a Win7 virtual machine on a Win8 Hyper-V host-system, on which the projects are located. All works perfect now!

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>