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.
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:
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 a while 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 that you start getting errors related to that. What you need to do is add a small configuration value to the config files.
Add the following to your config files:
<runtime>
<loadFromRemoteSources enabled="true" />
</runtime>
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.