Fervent Coder

Coding Towards Utopia...by Rob Reynolds
posts - 278 , comments - 431 , trackbacks - 0

My Links


Rob Reynolds

Subscribe to Fervent Coder RSS
Subscribe to Fervent Coder by Email

About Me

I manage several open source projects. Need...
   ...package management for Windows?
   ...automated builds?
   ...database change management (migrations)?
   ...your application to check email?
   ...a monitoring utility?

I also write for

Like what you are reading? Want to buy me a cup of coffee?
PayPal - The safer, easier way to pay online!


Post Categories


HowTo: Use .NET Code on a Network Share From Windows

If you use VMWare/VirtualPC and you want to offload your source code repositories to your host OS and code from it inside the VM, you need to do a few things to fully trust the share.

I’ve found that I keep heading out and searching on this every time I need it so I thought I would write it down this time to save myself the trouble next time.

CasPol Changes

Save the following as caspol.bat:

%WINDIR%\Microsoft.NET\Framework\v2.0.50727\caspol -q -machine -ag 1.2 -url file://e:/* FullTrust
%WINDIR%\Microsoft.NET\Framework\v4.0.30319\caspol -q -machine -ag 1.2 -url file://e:/* FullTrust
%WINDIR%\Microsoft.NET\Framework64\v2.0.50727\caspol -q -machine -ag 1.2 -url file://e:/* FullTrust
%WINDIR%\Microsoft.NET\Framework64\v2.0.50727\caspol -q -machine -ag 1.2 -url file://e:/* FullTrust

%WINDIR%\Microsoft.NET\Framework\v2.0.50727\caspol -q -machine -ag 1.2 -url file://\\vmware-host\* FullTrust
%WINDIR%\Microsoft.NET\Framework\v4.0.30319\caspol -q -machine -ag 1.2 -url file://\\vmware-host\* FullTrust
%WINDIR%\Microsoft.NET\Framework64\v2.0.50727\caspol -q -machine -ag 1.2 -url file://\\vmware-host\* FullTrust
%WINDIR%\Microsoft.NET\Framework64\v2.0.50727\caspol -q -machine -ag 1.2 -url file://\\vmware-host\* FullTrust

Make sure you replace the file locations appropriately. Then run it as an administrator.

This will do the first part of allowing your code to execute without security exceptions. Credit to Chris Sells for the most comprehensive article on this: http://www.sellsbrothers.com/Posts/Details/1519 

Make VMWare Share Part of the Local Intranet

This is one I’ve found to get stuff to build that I didn’t find anywhere else. Even after running caspol I still couldn’t run executables on the share. That is, until I made the share part of the Local Intranet.

  • Open Internet Explorer, then open Internet Options.
  • Find the Security Tab
  • Open Local Intranet by selecting Local Intranet and pushing the Sites button
  • Click Advanced
  • Now add file://vwmare-host to this file
  • Click Close when completed
  • There is a picture below for reference

Setting Local Intranet


This will allow for executables to start working. All but the ones built and run from Visual Studio.

.NET Built Executables/Services No Longer Work

It may be awhile before you run into this one. You may have a console application you are building. You will notice once you move over to the share, you start getting errors related to that. What you need to do is add a small configuration value to the the config files.

Add the following to your config files:

  <loadFromRemoteSources enabled="true" />

This will allow it to be loaded into memory, otherwise it will not run from a network share.

Caveats to Network Share

Caveats to think about when developing against a share:

  • Visual Studio has trouble noticing updates to files if you update them outside of Visual Studio.
  • If you run the local built in web server for web development, don’t expect it to catch the files updating automatically.
  • If you do any kind of restoring a database from a backup, you may want to consider copying that database to a local drive first.

Print | posted on Wednesday, December 12, 2012 1:08 AM | Filed Under [ Code ]


Comments are closed.
Comments have been closed on this topic.

Powered by: