Two weeks ago, I updated a plugin Assembly in my D365 Development instance and everything was working properly.
I then exported the solution with the plugin assembly and SDK message processing entries and pushed it to my test environment. All good.
Roughly 7 to 10 days later, users are now testing and got some strange errors that required the addition of some trace log entries.
After adding the trace log code, I re-built the assembly and went to re-upload it via the plugin via the plugin registration tool only to get the following error.
Unhandled Exception: System.IO.FileLoadException: Could not load file or assembly 'file:///Z:\MainOne\ProPlugin.Crm.Plugins\ProPlugin.Crm.Plugins\bin\Debug\merged\ProPlugin.Crm.Plugins.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, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, 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.Libraries.CrmAssemblyReader.LoadAssembly(String path) at Microsoft.Crm.Tools.Libraries.CrmAssemblyReader.RetrievePluginsFromAssembly(String path) at Microsoft.Crm.Tools.Libraries.CrmAssemblyReader.RetrievePluginsFromAssembly(String path) at Microsoft.Crm.Tools.Libraries.RegistrationHelper.RetrievePluginsFromAssembly(String pathToAssembly, String appPath) at Microsoft.Crm.Tools.AssemblyRegistration.PluginRegistrationViewModel.BtnLoadAssemblyClicked() 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.
The source of the error seems to be the following, but I have never encountered this before and am not entirely sure what to do.
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.
The plugin is supposed to be sandboxed and I do not understand why there is a message about sandboxing and previous versions of .net.
I used the Xrm Toolbox Assembly Recovery Tool to pull the original dll from our production instance, which would have been the same version as the one in the development instance before the update two weeks ago.
However, when I tried to restore/update the development environment with the freshly exported .dll that was pulled from production, the same error occurred, which was not expected.
How can a plugin assembly that is running in our production instance, error out during registration/update in the development instance?
The bottom line is that I need to get the new assembly built via Visual Studio installed into our development instance ASAP because this is holding up a major production release.
The material listed at https://nishantrana.me/2012/10/23/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-while-regi/ is not relevant to this issue as none of the assembly files have the problem described, already checked them.
What do I need to do?
How can I determine what the problem is and fix it?