Cottleston Pie

Fernando Felman’s thoughts on software development

Setting Full Trust to Mapped Shared Folders

Posted by Fernando Felman on March 5, 2007

The project I’m involved on at the moment uses a shared folder as the base mapping point. That is, we use the drive letter W to map to a shared folder that has the sources and the builds. One of the issues with this configuration is that, by default, shared folders are only partially trusted by the .Net and so when I added some MSTests they failed to initiate (MSTest , like many unit test frameworks, extensively uses Reflection which require Full Trust in order to run). The way this issue has been solved is by redirecting the builds to the C: drive (local drives are full trusted by default).

Another way to solve this issue would be by full trusting the assemblies from drive W. This can be done by adding a new code group to the Machine level of the Runtime Security Manager (the CAS util) with Full Trust permissions and a URL matching pattern with the URL notation of the local drive, e.g.: file://W:/*

Alternatively, you can use CAS Policy utility to do the same from the command line:
caspol -m -ag All_Code -url file://w:/* FullTrust -n Drive_W -d "Grants Full Access to the development W drive"

Explanation:
-m: modifies the machine level
-ag: adds a new code group
All_Code: the name of the parent code group (you can also use the label ‘1’ instead of the name)
-url file://w:/* : the new code group will affect any assembly matching the URL file://w:/* which means “any assembly running from the W drive”
FullTrust: All matching assemblies will have full trust settings
-n Drive_W: the name of the new code group will be Drive_W
-d “…”: the description of the new code group

When scripting, use the -q (for quite) in order to suppress the verification messages.

Advertisements

One Response to “Setting Full Trust to Mapped Shared Folders”

  1. Jaimie said

    Nice post Fernando. I will use this in future for letting developers know how to do this.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: