For the last few days I’ve been fighting a strange error while porting an application to Silverlight 3 …

Obviously, I had to use Visual Studio 2010 for the work – why not, I’m trying one beta technology, might as well make life interesting eh?
Actually, there are technical reasons why you would want to use VS 2010 for the SL3 development, but I’m not going to discuss them here at this point in time – they have been beaten to death elsewhere on the net.

Anyway, I hit this error message:

Error   3        The "ValidateXaml" task failed unexpectedly.

System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Development\{Project}\{Assembly}.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

File name: 'file:///C:\Development\{Project}\{Assembly}.dll' ---> System.NotSupportedException: An attempt was made to load an assembly from a network location which would have caused the assembly to be sandboxed in previous versions of the .NET Framework.  This release of the .NET Framework does not enable CAS policy by default, so this load may be dangerous.  If this load is not intended to sandbox the assembly, please enable the loadFromRemoteSources switch. See for more information.

Note that I have hidden the project name and assembly name, as it’s for something that I don’t want to expose yet!

The path is not a network path, its local, and it’s a trusted location. I have full admin rights on the machine, so I knew it wasn’t permissions related, but I checked that too just in case.

I was stumped.

Then something hit me this morning. I wonder if it’s a flag on the assemblies themselves. These particular assemblies are 3rd party libraries, and everything we had developed internally was working fine, so I went digging.

Turns out that they had the “block” flag set – this is set by Windows for files that are downloaded from the internet, and apply a restrict set of permissions in some applications such as Internet Explorer, Explorer, HTML Help viewer etc. And it seems Visual Studio / .NET 4.0 beta compiler.

It would be far more useful if the error text actually mentioned it.