症状
当您使用沙盒解决方案或 Web 部件时,您可能会在 SharePoint 统一记录系统 (ULS) 日志中收到类似于以下内容的错误消息。 这些消息表明某些沙盒解决方案或 Web 部件被阻止。
对于安装了 2022 年 5 月安全更新的 SharePoint Foundation 2013 和 SharePoint Enterprise Server 2016:
事件 ID |
消息 |
ajrme |
ExecuteRequestInSandBox 调用失败。 System.ArgumentException:在 |
ajlz0 |
获取异常 System.ArgumentException 错误消息:在 |
对于安装了 2022 年 6 月安全更新或更高版本的安全更新的 SharePoint Foundation 2013,以及安装了 2022 年 7 月安全更新或更高版本的安全更新的 SharePoint Enterprise Server 2016:
事件 ID |
消息 |
6k389 |
SPUserCodeSerializationBinder 中,无效类型:类型 = XXXXX;程序集 = YYYYY。 请访问 https://go.microsoft.com/fwlink/?LinkId=2196531 了解更多信息并了解如何解决此错误。 |
ajrme |
ExecuteRequestInSandBox 调用失败。 System.ArgumentException:在 |
ajlz0 |
获取异常 System.ArgumentException 错误消息:在 |
原因
从 2022 年 5 月的安全更新开始,SharePoint 沙盒服务进一步限制了默认情况下允许运行的类型和程序集。
解决方法
要解决此问题,您必须注册 SharePoint 沙盒服务将允许运行的第三方类型或程序集。 为此,请按照下列步骤操作:
-
对于 SharePoint Foundation 2013,安装 2022 年 6 月的安全更新或更高版本的安全更新。 对于 SharePoint EnterpriseServer 2016,安装 2022 年 7 月的安全更新或更高版本的安全更新。
-
使用受影响的沙盒解决方案或 Web 部件来触发问题。
-
打开 SharePoint ULS 日志并查找事件 ID“6K389”。 您将找到带有该事件 ID 的以下消息:
SPUserCodeSerializationBinder 中,无效类型:类型 = XXXXX;程序集 = YYYYY。 请访问 https://go.microsoft.com/fwlink/?LinkId=2196531 了解更多信息并了解如何解决此错误。
-
注意被阻止的类型和程序集。
-
打开沙盒解决方案或 Web 部件所在的 Web 应用程序的 web.config 文件。 web.config 的路径通常如下所示:
C:\inetpub\wwwroot\wss\VirtualDirectories\<Web 应用程序端口> -
在 configuration/SharePoint/SafeMode 部分添加 AllowedListItems 元素。
-
在 AllowedListItems 元素内,添加一个 AllowedItem 元素,并将 Name 属性设置为 AllowedSandboxType,格式如下:
-
要取消阻止特定类型,请使用 Type 属性添加元素,如下所示:
<AllowedItem Name="AllowedSandboxType" Type="XXXXX"/> -
要取消阻止特定程序集,请使用 Assembly 属性添加元素,如下所示:
<AllowedItem Name="AllowedSandboxType" Assembly="YYYYY"/>
下面是一个示例:
<SafeMode
MaxControls = "200"
CallStack = "false"
DirectFileDependencies ="10"
TotalFileDependencies = "250"
AllowPageLevelTrace = "false"
ControlCompatMode="false"
>
<PageParserPaths>
</PageParserPaths>
<AllowedListItems>
<AllowedItem Name="AllowedSandboxType" Type="Microsoft.SharePoint.Portal.WebControls.RSSAggregatorWebPart, Microsoft.SharePoint.Portal, Version=15.0.0.0, Culture=neutral, PublicKeyToken=xxxxxx"/>
<AllowedItem Name="AllowedSandboxType" Assembly="System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=xxxxxx"/>
</AllowedListItems>
</SafeMode>