Tags

, , ,

Hello Everyone,

Today I wrote a plugin and tested it in my testing server, everything went smooth and it was working fine. I then copied that .dll to my development server through remote session. But while trying to load the assembly through the Plugin Registration Tool, it Failed with the following Error: Unable to load the specified Plugin Assembly.

I downloaded the Error log file which says: 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.

Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'file:///C:xyz.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 PluginRegistrationTool.AssemblyReader.LoadAssembly(String path)
 at PluginRegistrationTool.AssemblyReader.RetrievePluginsFromAssembly(String path)
 at PluginRegistrationTool.AssemblyReader.RetrievePluginsFromAssembly(String path)
 at PluginRegistrationTool.RegistrationHelper.RetrievePluginsFromAssembly(String pathToAssembly)
 at PluginRegistrationTool.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.

OK,, now this was interesting.  I checked the .NET Framework versions of both the systems and it seemed to be same. This time I went closely through the error file and noticed the Microsoft Link which it was pointing to.

http://go.microsoft.com/fwlink/?LinkId=155569

It clearly mentioned that  if you loaded an assembly from a remote location, or if an application has been copied from the web, it is flagged by Windows as being a web application, even if it resides on the local computer and the assembly would run partially trusted. You can change that designation by changing the file properties, to grant the assembly full trust. 

Resolution: Kindly go to the properties of the particular .dll and in General Tab Unblock the option “This file came from another computer and might be blocked to help protect this computer.”

Once Unblocked, the option will be grayed out !!!

Click Apply and you will be able to use the .dll file to load the Assembly in PLugin Registration Tool back again.

Hope that was Helpful.

Thanks !!!

😀