Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Error updating plugin assembly - 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...

(1) ShareShare
ReportReport
Posted on by 1,579

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?

 

  • Suggested answer
    ACECORP Profile Picture
    ACECORP 1,579 on at
    RE: Error updating plugin assembly - 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 is resolved and appears to be a strange nuance that resolves itself as described below:

    1. Attempt to load the .dll file in Plug-in Registration Tool which causes the error.
    2. Quit and wait 60 seconds, then restart Plug-in Registration Tool, then re-attempt to load the assembly in Plug-in Registration Tool again, the error does not happen.

    So for some reason, I now have to attempt to load, get the error, close the plugin registration tool, wait 60 seconds, re-open it, re-register, and it works. 

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees!

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December!

Congratulations to our December super stars! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,622 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans