c# - 使用 System.Reflection 时验证异常时出错

标签 c# sharepoint sharepoint-online validationerror sandbox-solution

我们正在 Visual Studio 2013 中为 SharePoint Online 开发一个 SharePoint webpart 作为沙盒解决方案。我们使用外部 dll 库 iTextSharp 来读取和写入 PDF。激活我们的解决方案时遇到问题。

我们的错误信息是:

Error validating assembly itextsharp.dll.

此解决方案引用了禁止的类型 System.Reflection.BindingFlags,不能用于此网站集。

最佳答案

你自己已经回答了这个问题:

This solution references prohibited type System.Reflection.BindingFlags and cannot be used on this site collection.

您不能将 System.Reflection 命名空间用于 SharePoint Online 解决方案(大部分情况下)。 System.Reflection 中唯一允许的成员是:

  • 获取值名称
  • 获取自定义属性
  • 属性类型
  • 获取值设置值

我建议查看 Microsoft 用于开发 SharePoint Online 解决方案的文档 (link),因为有很多以前可用于 SharePoint 开发的命名空间现在已被禁止。

Microsoft 对此的看法如下:

Because it is a multi-tenant environment, when you upload a sandboxed solution to the Solution Gallery, SharePoint Online performs a further round of validation checks, in addition to those performed by on-premise SharePoint installations. A sandboxed solution cannot be activated if it contains code calling any of the following namespaces:

下面是禁止命名空间的列表(请参阅所有异常(exception)情况的文档):

  • 微软.SqlServer
  • 微软.Win32
  • 系统.Data.Sql
  • 系统.Data.SqlClient
  • System.Data.SqlTypes
  • System.IO.Pipes
  • System.IO.Ports
  • 系统.反射
  • System.Runtime.InteropServices
  • 系统.运行时.Remoting
  • 系统线程
  • Array.CreateInstance()
  • 系统代理
  • Type.GetType(字符串)
  • Type.InvokeMember()

关于c# - 使用 System.Reflection 时验证异常时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31048768/

相关文章:

c# - 我无法停止线程

c# - Azure网站本地调用WebException

angular - 在Sharepoint上在线部署Angular2项目

sharepoint-2013 - 使用 SharePoint REST API 将值设置为多值托管元数据字段类型时出错

c# - 选择后 ListViewItem 文本被截断 - Compact Framework

通过网络的 C#/mySQL 数据检索问题

javascript - SharePoint 2010 和 "get_groups"方法

SharePoint 工作流 : how to update the item without triggering the workflow again

Sharepoint 2010 客户端对象模块获取站点 url 列表

javascript - 表单提交后无法阻止页面重定向