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 http://go.microsoft.com/fwlink/?LinkId=179545 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 http://msdn.microsoft.com/en-us/library/dd409252%28VS.100%29.aspx, 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.
- 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).
- 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.
- Directly under this line add the following line
- Save the changed file.
- 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.
- Restart Visual Studio and it works.