Bill Morefield My thoughts, discoveries, and occasional rambiings.

June 27, 2012

Fixing Error when Building Windows Phone Apps on Network Drive

Filed under: development — Tags: , — Bill Morefield @ 6:31 pm

I’m working on building a Windows Phone application and ran into an interesting error that took some time to track down and I thought I’d share the fix here. I normally develop on a Windows virtual machine running on my MacBook. To make backups simpler and to sharing files between machines easier, I map the documents of the virtual machine to the MacBook’s documents folder. This means that my documents folder inside the VM appears to be on a network drive.

When I tried to compile my phone app for the first time I got an error similar to this:
Error : Could not load the assembly
Path to Assembly\MyApplication.dll.
This assembly may have been downloaded from the Web. If an assembly has been downloaded from the Web, it is flagged by Windows as being a Web file, even if it resides on the local computer. This may prevent it from being used in your project. You can change this designation by changing the file properties. Only unblock assemblies that you trust. See for more information.

This belongs on the all time list of bad Microsoft error messages in that it not only is wrong, it’s downright misleading. the article discusses assemblies downloaded from the web. In my case the problem couldn’t have anything to do with the assembly being downloaded form the web. First the assembly in question is one that I’m trying to compile. There is no option to unblock as the article suggests as a fix.

I finally figured out the problem comes from the assembly, and my whole project, resides on a network drive as far as Windows is concerned. The first and most common fix I found was to move the project to the local hard drive. That wasn’t my first option so I looked into alternatives.

I finally found an article on Microsoft’s web site that gives a fix at, but even this article has problems. It tells you to ignore it in the header and refers to the other article in spite of it being the actual fix for what’s probably a more common problem (purely my speculation, but I feel more people are probably accessing assemblies on a network drive than downloading them from the Internet). It also doesn’t really tell you where to apply the fix. The change needs to go into the devenv.exe.config file under C:\Program Files\Microsoft Visual Studio 10.0\Common7\IDE (or C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\IDE if you’re running a 64 bit OS). Under Windows 7 the file and folder are protected making the file a bit tricky to edit so here’s the process I used.

  1. Copy the devenv.exe.config file from the appropriate IDE path for your OS to a directory you have full rights to (your documents folder for example).
  2. Open the copy of the file in a text editor (Notepad for example) and look for the line
    which will be close to the top of the file.
  3. Directly under this line add the following line
    <loadFromRemoteSources enabled=”true”/>
  4. Save the changed file.
  5. Now copy the edited file from your temporary directory back to the directory you moved it from. You will be told it requires admin rights and have to grant them. Do so.
  6. Restart Visual Studio and it works.

Powered by WordPress