Error adding reference to assembly downloaded from internet

If you download a .Net assembly from internet and then add reference to it in your .Net project, you will run into the following compile time error. This happens when you do it in VS2010 and using .Net 4.0 framework. The reason behind this is described in description of <loadFromRemoteSources> in MSDN documentation.


The "ValidateXaml" task failed unexpectedly.
System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Projects\xyz.dll'
or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515
File name: 'file:///C:\Projects\xyz.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 http://go.microsoft.com/fwlink/?LinkId=155569 
for more information.
   at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName,
 String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, 
StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection,
Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, 
Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, 
 Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, 
Evidence assemblySecurity, StackCrawlMark& stackMark, 
Boolean forIntrospection, Boolean suppressSecurityChecks)
   at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, 
Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, 
Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark)
   at System.Reflection.Assembly.LoadFrom(String assemblyFile)
   at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute(ITask task)
   at Microsoft.Silverlight.Build.Tasks.ValidateXaml.XamlValidator.Execute(ITask task)
   at Microsoft.Silverlight.Build.Tasks.ValidateXaml.Execute()
   at Microsoft.Build.BackEnd.TaskExecutionHost.Microsoft.Build.BackEnd.ITaskExecutionHost.
Execute()

Solution

Just right click on that assembly and click on Unblock button in bottom right of the dialog box. That should take care of this error.

comments powered by Disqus

Search

Social

Weather

21.4 °C / 70.5 °F

weather conditions Clear

Monthly Posts

Blog Tags