问题
Since I run my stuff in a VM I like to save my data on shares on the host. But then running and debugging (web) applications and tests from within Visual Studio has problems. How can I configure everything to run with FullTrust when it's started in Visual Studio?
Or how to just configure full trust for all network drives?
I have turned off UAC.
回答1:
You'll have to use the caspol command-line command.
Open up a console-window, and type this command:
caspol -machine -addgroup <group_param> -url file://yournetworkdriveletter/* FullTrust -name somename
Note: the group_param
is the group to which you want to add your new zone, which will be 'Local Intranet'. You can execute caspol -lg
to see what the number of the local-intranet zone is on your system.
On my system, it is 1.2
So, the command you have to execute is:
caspol -machine -addgroup 1.2 -url file://driveletter/* FullTrust -name MyNewZoneName
回答2:
I'm not sure why, but using caspol with the -url option didn't work for me (perhaps because subdirectories are not included).
My setup is a Windows XP guest machine inside VirtualBox, with .net 2.0 executables running from shared folders. This is the command that allowed them to run:
C:\Windows\Microsoft.NET\Framework\v2.0.50727\caspol -ag 1 -allcode FullTrust
BTW, If you want to reset permissions to .NET defaults, use caspol -reset
.
回答3:
What version of the framework are you using?
You can use "caspol.exe" to provide extra trust for shares that you specify, but with .NET 3.5 SP1 installed, network shares get the same trust anyway: see here:
Managed applications that are opened from network shares have the same behavior as native applications by running with full trust.
I can't remember whether that applies equally to mapped shares (F:) and UNC shares (\\myserver\someshare), but it would be easy to test.
You could also consider ClickOnce, which is IMO the easiest way to deploy full .NET applications to network / web locations.
来源:https://stackoverflow.com/questions/974612/edit-and-run-net-projects-from-network-shares