How Do I Allow my Visual Studio .NET Projects to Run from a Network Location?

When you try to create a new project in Visual Studio .NET 2003 on a network drive, you might get the following error:

The project location is not fully trusted by the .NET runtime. This is usually because it is either a network share or mapped to a network share not on the local machine. If the output path is under the project location, your code will not execute as fully trusted and you may receive unexpected security exceptions. Click OK to ignore and continue. Click CANCEL to choose a different project location.

You get this error because by default .NET framework does not fully trust network locations. It's easy, however, to grant this trust to your projects, or your entire Visual Studio Projects folder.

To grant permission to all your projects in your Visual Studio Projects folder located on the network, follow these 8 steps:

  1. Open Microsoft .NET Framework 1.1 Configuration which you'll find under Administrative Tools in the Control Panel.
  2. Expand Runtime Security Policy | Machine, | Code Groups | All_Code | LocalIntranet_Zone
  3. In the right-hand pane, click Add a Child Code Group.
  4. In the dialog that follows choose Create a new code group and fill in a Name like Visual Studio Projects.
  5. Optionally, provide a Description for the Code Group. (You'll see the description when you click a Code Group in the left tree, helping you identify the various Code Groups you may have) .
  6. In the Condition Type drop down, choose URL
  7. For the URL field, type something like this:

    file://YourServer/My Documents/Visual Studio Projects/*

  8. Under Use existing permission set, choose FullTrust (that is, if you trust your own applications. If you don't, choose a different permission set or create a new one).

That's it; from now on, you can successfully open existing or create new applications on in the folder Visual Studio Projects on your network drive.

Note that the name LocalIntranet_Zone is a bit misleading. It seems that this only relates to the security settings as found in Internet Explorer. However, this is not the case; these settings will apply to projects (and applications) you try to open from the network .

If you keep getting the same error, even after you configured your machine, take a look at this post as suggested by Stonie. There's a fair chance your project has been marked as "downloaded from the Internet" which can result in the same error.


Where to Next?

Wonder where to go next? You can read existing comments below or you can post a comment yourself on this article .


Consider making a donation
Please consider making a donation using PayPal. Your donation helps me to pay the bills so I can keep running Imar.Spaanjaars.Com, providing fresh content as often as possible.



Feedback by Other Visitors of Imar.Spaanjaars.Com

On Friday, March 04, 2005 2:37:43 AM Alan said:
any idea why this would happen for local projects?
On Friday, March 04, 2005 7:28:52 AM Imar Spaanjaars said:
No, not really. Did you (or a system admin) add the local disk to a zone with low trust?
On Friday, April 15, 2005 2:54:16 PM william said:
vs2003.  All was well until a got to the part about adding child ...  in the right pane.  The option did not exist.
On Friday, April 15, 2005 4:30:44 PM Imar Spaanjaars said:
What OS are you using? And what happens when you right click the LocalIntranet_Zone node in the tree on the left?

Imar
On Friday, April 15, 2005 4:46:20 PM william said:
I am using WinXP Professional
On Friday, April 15, 2005 6:24:02 PM Imar Spaanjaars said:
Hmmm, then as far as I know, the option should be there. Did you try right-clicking?
On Sunday, April 24, 2005 2:01:56 AM Stonie said:
Have a look here, seems to be a problem with XP sp2:
http://robz.homedns.org:8080/blog/archive/2005/03/02/402.aspx
On Friday, April 21, 2006 1:02:05 PM ArunKishore.K said:
Hi Imar,

When I try to open an ASP.NET Project I am getting the Message Similar to...

Visual Studio.Net cannot create or open the Application.The Likeliest Problem is that required components are not installed on the local web server.Run Visual Studio.Net setup and add the Web Development component.

How to Overcome this?

Thanks,
ArunKishore.K
On Saturday, April 22, 2006 9:46:34 AM Imar Spaanjaars said:
Well, did you run Visual Studio.Net setup and add the Web Development component??

Sounds like a useful error message to me... ;-)

Imar
On Saturday, April 22, 2006 10:00:27 AM ArunKishore.K said:
Hi Imar,

Thanks for Your reply.

Yes I did so,Still I have a Problem.
On Sunday, April 23, 2006 11:05:54 AM Imar Spaanjaars said:
Did you install IIS after you installed Visual Studio?? Then go to

http://p2p.wrox.com/ and search the forums for aspnet_regiis

This command line tool registers ASP.NET with IIS, and might fix your problem.

Imar
On Thursday, June 07, 2007 2:41:56 PM Alfred said:
I spend 4 hours fooling arround with local security policies and full trust settings for my newly created application (on a network share). All along this was the solution. Thanks.
On Wednesday, February 25, 2009 9:25:30 PM Chris V V said:
I had alot of trouble getting this working, but it finally did when I used this command:
caspol -q -machine -addgroup 1 -url file://z:/* FullTrust -name "Z Drive"

---------------
caspol.exe is located at C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727
also you need to restart devenv.exe after doing this.
On Thursday, July 23, 2009 11:54:39 AM GC said:
Thank you so much!
On Friday, July 24, 2009 4:52:51 AM pradeep kumar yadav said:
When I try to open an ASP.NET Project I am getting the Message Similar to...

Visual Studio.Net cannot create or open the Application.The Likeliest Problem is that required components are not installed on the local web server.Run Visual Studio.Net setup and add the Web Development component.


How to Overcome from this error ? pls help me with proper solution.

Thanks,
Pradeep,Kunda,PBH
On Friday, July 24, 2009 7:17:53 AM Imar Spaanjaars said:
Hi pradeep,

How is this related to the original subject of running .NET applications from the network.

Anyway, isn't the error message saying it all? Apparently you're trying to open a project type that is not supported by your current installation options of Visual Studio. Run the installer and install the necessary components.

Cheers,

Imar
On Friday, September 11, 2009 9:34:54 PM SkewedPerceptions said:
When I build an ASP.NET 2.0 project on a local install, everything works as advertised, no errors, no warnings, no problems.  

If I move my project onto a network share so things can comply with business rules (nothing should be on local drives, all development should be done on a shared\mapped drive), then I no longer can build the website nor compile.

When I try your change using the .NET 2.0 config - I do not get any change of behavior - I still can't build or publish.  The error:

Request for permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed

If I move the project back to another location on my local C: drive, everything is again fine, and will compile, publish, etc.  

So, I'm stumped...  How do I "really" allow VS.NET Projects (I'm using VS 2005 Pro) build and run from a network drive?

--skewed
On Friday, September 11, 2009 9:40:21 PM Imar Spaanjaars said:
Hi SkewedPerceptions

A 0.1 second search on Google brings up this:

http://weblogs.asp.net/jgaylord/archive/2007/02/13/system-web-aspnethostingpermission-when-accessing-network-or-intranet-projects-using-visual-studio-2005.aspx

Time to reconsider company policies ;-)
Developing locally makes your life a *lot* easier. Hook up your system to a solid Source Control System lime TFS and all code can be centrally managed and backed up while you still have the benefits of local development.

Good luck!

Cheers,

Imar
On Friday, September 11, 2009 11:19:45 PM SkewedPerceptions said:
Well...  I'm going to ignore your comment about company policy.  I have no control over this and I personally use SVN on my local machine and on my laptop, so I already know about the benefits of local development - but, we're in a team development environment...  And, we must conform or be assimilated by the BORG!

Anyway...

This stuff didn't work because of the AJAX tools.  After reviewing a few of the comments on your referenced search (I have googled for a couple of days and never ran into the reference you posted - from there I was able to figure out what I was doing wrong).  All my previous searches for enlightenment pointed to actions you mention and Jason's blog mentioned - but none of them seemed to help.  I found references to MSDN blogs and forum posts where folks discussed usage of the CASPOL utility.  But, my previous attempts never were successful.  I finally figured out the problem - I wasn't typing the path correctly; I was using TWO forward slashes after the "file:" url monicker - I needed to have FOUR!!!

For example, on my development machine, I created a connection to my laptop whose computer name is “lazacer” and attached to the “e$” drive.  I placed the Proj files in the following path:

E:\temp\Proj\CME_Project\...

So my first attempt (er…  that’s my first attempt after getting this stuff to work while I’m sitting here documenting it):

C: >>  cd \Windows\Microsoft.NET\Framework\v2.0.50727\

C$:\Windows\Microsoft.NET\Framework\v2.0.50727\ >> caspol –m –ag 1 –url file:////\\lazacer\e$\temp\Proj\CME_Project\* FullTrust –d “Proj_CME FullTrust Permission” –n “Proj_CME FullTrust Permission”

Then, I opened Visual Studio and load the CME project by navigating via the UNC method (traversing local network,etc, not by navigating the mapped share).  

>>  Build project...  >> SUCCESS <<

Now, I tried for a mapped share rather than the precise UNC path where I have \\lazacer\e$\temp mapped as my Z drive:

C$:\Windows\Microsoft.NET\Framework\v2.0.50727\ >> caspol –m –ag 1 –url file:////z:\Proj\CME_Project\* FullTrust –d “Proj_CME FullTrust Permission” –n “Proj_CME Z-Map FullTrust Permission”

>>  Build project…  >> SUCCESS <<    Published!!!

AWESOME!!!  Now I can have a good weekend.  My wife has already called me asking when I’m coming home…

THANKS FOR HELPING ME FINISH MY ADVENTURE du Jour  :)

-- Skewed
On Saturday, September 12, 2009 11:11:18 AM Imar Spaanjaars said:
Hi SkewedPerceptions,

Sorry, didn't mean to tell you how to do your job. But you'd be amazed at the number of developers / companies I see that work on a network share because "it's safe" without using source control.

Weird that you didn't find the article I mentioned. It's the "I Feel Lucky" result for "'System.Web.AspNetHostingPermission" on Google.com.

Anyway, thanks for the follow up. Hopefully some other reader will benefit from this in the future.

Cheers,

Imar
On Tuesday, June 08, 2010 5:48:16 PM Scott said:
Thanks for the tips, I've been having problems on a project moved to a network share. I had to make the recommended changes to both 1.1 and 2.0.  Worked like a charm.

Scott
On Thursday, December 08, 2011 11:29:25 PM Juan Garcia said:
Greets all.  I'm sure this thread may have died, I still wanted to chime in.  While my circumstance was about running an application from a network, ours was trying to open a project FROM a network location instead of a project solution sitting locally.

For my solution, I changed the Setting Option from Tools menu | Settings | Projects | Unckeck option:  [Warn User when project location is not trusted].

Background:
Our automated build process revolves around IBM Rational's ClearCase and the code (for those of you familiar with CC and the UCM model) for the build process is on a network drive.  When I attempted to kick off the build, it failed.  In opening the project manually, this message appeared.  It seemed to some from a recent upgrade of IE8 since no other software changed between a previous build and my recent failed build.

I hope this helps somebody.

Cheers!

-J

Talk Back! Comment on Imar.Spaanjaars.Com

I am interested in what you have to say about this article. Feel free to post any comments, remarks or questions you may have about this article. The Talk Back feature is not meant for technical questions that are not directly related to this article. So, a post like "Hey, can you tell me how I can upload files to a MySQL database in PHP?" is likely to be removed. Also spam and unrealistic job offers will be deleted immediately.

When you post a comment, you have to provide your name and the comment. Your e-mail address is optional and you only need to provide it if you want me to contact you. It will not be displayed along with your comment. I got sick and tired of the comment spam I was receiving, so I have protected this page with a simple calculation exercise. This means that if you want to leave a comment, you'll need to complete the calculation before you hit the Post Comment button.

If you want to object to a comment made by another visitor, be sure to contact me and I'll look into it ASAP. Don't forget to mention the page link, or the QuickDocId of the document.

For more information about the Talk Back feature, check out this news item.