Monday, 18 February 2013

An attempt was made to load an assembly from a network location


When trying to register an assembly (This assembly was extracted from existing unmanaged solution) through plugin registeration tool, i was getting following error

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'file:///C:\Users\svccrmcapdev\Desktop\<<assembly name>>-<<guid>>\<<assembly name>>-<<guid>>\<<assembly name>>.dll' or one of its dependencies. Operation is not supported. (Exception from HRESULT: 0x80131515)

   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.Crm.Tools.PluginRegistration.AssemblyReader.LoadAssembly(String path)

   at Microsoft.Crm.Tools.PluginRegistration.AssemblyReader.RetrievePluginsFromAssembly(String path)

   at Microsoft.Crm.Tools.PluginRegistration.AssemblyReader.RetrievePluginsFromAssembly(String path)

   at Microsoft.Crm.Tools.PluginRegistration.RegistrationHelper.RetrievePluginsFromAssembly(String pathToAssembly)

   at Microsoft.Crm.Tools.PluginRegistration.PluginRegistrationForm.btnLoadAssembly_Click(Object sender, EventArgs e)

Inner Exception: 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.

--------

Resolutions: Right click on assembly and go to properties, In General tab, next to security label following message would be shown "This file came from another computer and might be block to help protect this computer". Click on Unblock to register this assembly through plugin registeration tool. 


2 comments: