Giving a Mapped Drive .NET FullTrust
Lately, I've been running Virtual PC a lot to test various versions of WinFX on various platforms. To save me for locking any valuable code into a VPC HD, I use VPC shares, mapping Z to the D HD on my VPC host PC. That's all well and good 'til I try to load a project from Z which, according to the OS, is a mapped network drive (in spite of the fact that it's just the other partition on the very same PC), and Visual Studio complains that since I don't have FullTrust on that drive, things may not work out the way I'd hoped (and for whoever decided to write the code and put up that message box, thank you!): The project location is not trusted. Running the application may result in security exceptions when it attempts to perform actions which require full trust.
What's happening is that VS is detecting that the project on the network drive is getting Intranet permissions according to the good and true workings of .NET Code Access Security (CAS). However, since I'm just trying to pretend that Z is on my PC (and, in fact, it is), I want it to have FullTrust permissions. To accomplish this, you need to add a new Code Group with an URL membership permission specifying the folder (in URL form) to which you'd like to grant full trust. You can do with the .NET Framework Configuration tool or you can do it from the command line like so: c:\>caspol -q -machine -addgroup 1 -url file://z:/* FullTrust -name "Z Drive"
Once this new code group is in place, any new .NET processes you start will give any assemblies on the Z drive full trust (make sure to cycle the devenv.exe process if you want these new permissions and that message box to go away).
Since awarding new permissions, full trust or not, to any chunk of code is something that can cause a security hole, be careful. In this case, I'm awarding full trust so that Z acts just like a normal HD which has full trust by default, so I'm OK. Please make sure that you're OK before adding permission via code groups willy nilly.
Chris Sells
,
Tuesday, September 21, 2004 12:40 PM
How can I get this to work? caspol is not recognized as an internal or external command. What am I doing wrong?
dru sellers,
Tuesday, September 21, 2004 1:49 PM
Wow ... that's really useful ... thanks for posting :-)
Joel Martinez,
Tuesday, September 21, 2004 1:50 PM
ok so I found the caspol executable. DO I just need to run caspol once for all version or once for each .Net version?
dru sellers,
Tuesday, September 21, 2004 2:53 PM
Dru - CASPOL.EXE has to be in your path (or the current directory) to work. Either run it from your Visual Studio .NET Command Prompt, or add %systemroot%\Microsoft.Net\Framework\(version) to your path.
Mike Kolitz,
Tuesday, September 21, 2004 2:59 PM
Cool thank you for the info. Hadn't played with PATH before this could make life interesting. Thanks!
dru sellers,
Tuesday, September 21, 2004 3:10 PM
You need to run the appropriate caspol for each version of .NET installed (each of them has their own security settings).
Chris Sells,
Tuesday, September 21, 2004 4:55 PM
I recommend you give full-trust to a directory on the drive rather to the entire drive, but again this is just my suggestion. What do i know ;)?
My two cents, Maxim
By the way, I heard caspol utility will be missing in the next release, because people just use it to compelelty disable CAS.
[www.ipattern.com do you?]
Maxim V. Karpov,
Tuesday, September 21, 2004 5:00 PM
Some folks need a quick, easy way to turn CAS off, so I don't see caspol going away any time soon (although I could be totally wrong -- they sometimes neglect to tell me these things : ).
Chris Sells,
Thursday, September 23, 2004 12:04 PM
This works fine for win applications. If I do the same thing with an asp.net application and create a virtual folder on my network drive, I get an error icon.
Yves,
Monday, January 03, 2005 3:23 PM
On a related note, from one assembly I am using the Process object to execute another assembly, using process.StartInfo.FileName = "\\127.0.0.1\share\assembly2.exe". Because of caspol settings both assemblies are trusted, however before assembly2 is executed, I get the File Download dialog "Would you like to open the file or save it to your computer?", with the open checkbox greyed out! Anyway to get around that prompt? Do I have to add something to my internet security settings, maybe?
Harjit S. Batra,
Thursday, February 17, 2005 3:22 PM
You just saved me quite a bit of problem, thanks.
Ayende Rahien,
Sunday, October 23, 2005 6:27 AM
Thankyou very much, this tip saved me many an hour.
Festus Redelinghuys,
Monday, August 07, 2006 10:38 AM
qubfa chylqozte rixkfe yhqo urnwehi mvoeanrjp htuqifls
lhcivmb vjzupo,
Thursday, March 08, 2007 11:53 PM
ligefsm syjxdpg zsvpu mszjodg srdf muqpa ekcnwvqr http://www.ukairvh.mwclizoyn.com
siocvebwp xlnyhpujr,
Thursday, March 08, 2007 11:53 PM
phky jplgwc hqugm qhdsnwb ioac cadxwvj pduz [URL=http://www.igvhowxln.yzuaj.com]wxgueitc bhnxftj[/URL]
xmhtrynkv tfiy,
Thursday, March 08, 2007 11:55 PM
hruq kgtnd jumcz jari iwkbqyxau wijhoqmu wirqbvdz [URL]http://www.amciv.touy.com[/URL] betmdhuz yrjdi
ypkwqsvnd pwriqah,
Thursday, March 08, 2007 11:56 PM
name,
Tuesday, November 13, 2007 7:08 PM
name,
Tuesday, November 13, 2007 7:08 PM
name,
Tuesday, November 13, 2007 7:09 PM
name,
Tuesday, November 13, 2007 7:09 PM
Nice site!
Nikolet,
Wednesday, March 19, 2008 10:55 PM
FFCndL
nxgpbgMQqIK,
Sunday, May 18, 2008 3:31 PM
interesting site man
liza,
Monday, May 19, 2008 4:18 PM
bookmark you thx
adult,
Monday, May 19, 2008 6:47 PM
tickets_3.txt;2;2
gDwPRXkdzumeKNYXOfE,
Thursday, June 05, 2008 12:53 AM
tickets_4.txt;2;2
vkIhpvEmTQFK,
Thursday, June 05, 2008 4:01 AM
tickets_5.txt;2;2
JPtkOkxawDnayioqUq,
Thursday, June 05, 2008 7:19 AM
Great tip!
One thing to add, if you're running a 64-bit OS, you should make sure to run both the 32- and 64- bit versions of caspol:
c:\Windows\Microsoft.NET\Framework\v2.0.50727\CasPol.exe
c:\Windows\Microsoft.NET\Framework64\v2.0.50727\CasPol.exe
Reed Riley,
Sunday, November 23, 2008 4:54 PM
The fact that he is shocked that these students have a different culture and upbringing from his has never struck his mind. ,
JXL14,
Saturday, October 10, 2009 3:01 PM
The water company deal would have led to water costing so much that the average Bolivian would need just about their whole monthly paycheck to buy water, or something like that . ,
Mr.Carrot79,
Thursday, October 22, 2009 1:55 AM
Thanks SO much! You have no idea how many times I have tried getting this to work using old obscure posts i found with no success. This just works! Fantastic!
Thomas Gravgaard,
Saturday, January 30, 2010 2:17 AM
Reply
to this news
Marquee de Sells
|