SharePoint troubleshooting: SharePoint Online Assemblies load abnormally

51CTO blog address: https://blog.51cto.com/13969817blog
garden blog address: https://www.cnblogs.com/bxapollo

Today, I encountered the method of calling Microsoft.SharePoint.Client.dll to obtain data. An exception occurred when executing Powershell to load SharePoint Online Assemblies. The following Powershell commands were executed:

  • Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
  • Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"

The error exception is shown in the figure below:

SharePoint troubleshooting: SharePoint Online Assemblies load abnormally

Troubleshooting: I checked the corresponding directory and found that the dll file exists, so why is there an exception?

SharePoint troubleshooting: SharePoint Online Assemblies load abnormally

Solution: After searching a lot of information, I found that this may be a bug in .net 4.0. By default, the function of executing code in assemblies loaded from remote locations is disabled, so the following methods can be used to solve the problem: [System.Reflection .Assembly]::LoadFrom(), as shown in the figure below:

SharePoint troubleshooting: SharePoint Online Assemblies load abnormally

Related information link:

Assembly.LoadFrom 方法

Summarize the solution to this problem, hoping to help other friends who have problems, thank you for reading.

Guess you like

Origin blog.51cto.com/13969817/2590476