如何从动态crm插件中的sharepoint文件URL获取文件流?

时间:2017-08-17 14:22:29

标签: sharepoint dynamics-crm dynamics-crm-online sharepoint-online

我要求获取共享点文件的文件流,因为我有共享点文件URL。

https://mysite.sharepoint.com/sites/documents/contact/test/Beat01_07262017.pdf

我正在尝试从CRM Online中的插件中连接到SharePoint Online(使用CSOM)。为此,我将SharePoint Client和Client.Runtime DLL与ilmerge.exe合并到我的插件DLL中。但是只要下面的代码:

ClientContext clientContext = new ClientContext(server);
clientContext.Credentials = new SharePointOnlineCredentials(UserId, Password); // This line throws an below exception:
  

请求类型的许可   'System.Security.Permissions.RegistryPermission,mscorlib,   Version = 4.0.0.0,Culture = neutral,PublicKeyToken = b77a5c561934e089'   失败。

有什么方法可以让它发挥作用吗?

我已与SharePoint Integration from CRM Online Workflow/Plugin核实但无法使其正常运作 并获得如下错误

  

例外:调用目标引发了异常。

     System.RuntimeMethodHandle.InvokeMethod上的

堆栈跟踪(对象目标,对象[]   arguments,Signature sig,Boolean constructor)
               在System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj,   Object []参数,Object []参数)
               在System.Delegate.DynamicInvokeImpl(Object [] args)
               在Microsoft.Xrm.Sdk.Linq.QueryProvider.DynamicInvoke(委托项目,   对象[] args)
               在Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateExpressionToConditionValue(Expression   exp,ParameterExpression []参数)
               在Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhereCondition(BinaryExpression)   是,FilterExpressionWrapper parentFilter,Func 2 getFilter,Func 2   getLinkLookup,布尔否定)
               在Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhere(String   parameterName,BinaryExpression be,FilterExpressionWrapper   parentFilter,Func 2 getFilter,List 1 linkLookups,Boolean   否定)
               在Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhereBoolean(String   parameterName,Expression exp,FilterExpressionWrapper parentFilter,   Func 2 getFilter,List 1 linkLookups,BinaryExpression parent,Boolean   否定)
               在Microsoft.Xrm.Sdk.Linq.QueryProvider.TranslateWhere(QueryExpression   qe,String parameterName,Expression exp,List 1 linkLookups)
               在Microsoft.Xrm.Sdk.Linq.QueryProvider.GetQueryExpression(表达式   表达式,布尔& throwIfSequenceIsEmpty,Boolean&   throwIfSequenceNotSingle,Projection&投影,   NavigationSource&安培;来源,清单1& linkLookups)
               在Microsoft.Xrm.Sdk.Linq.QueryProvider.Execute [TElement](表达式   表达)
               在Microsoft.Xrm.Sdk.Linq.QueryProvider.System.Linq.IQueryProvider.Execute [TResult](表达式   表达)
               在System.Linq.Queryable.FirstOrDefault [TSource](IQueryable 1   源)
               at CRMPluginProject1._365Immo.Laurus.SharePoint.DocumentLocationHelper.GetDocumentLocationPath(SharePointDocumentLocation)   parentLocation)
               在CRMPluginProject1._365Immo.Laurus.SharePoint.DocumentLocationHelper.CreateDocumentLocation(实体)   site,String documentLibraryName,EntityReference   regardingRecord)
               在CRMPluginProject1._365Immo.Laurus.Plugins.GetSharePointFile.Execute(IServiceProvider)   的ServiceProvider)

     

内部例外:   由于在创建匿名托管期间捕获的代码访问安全性信息,需求失败   动态方法。为了使此操作成功,请确保这一点   在创建方法时,需求会成功。   有关详情,请参阅http://go.microsoft.com/fwlink/?LinkId=288746   信息。

     

Stack Trace:在lambda_method(Closure)

1 个答案:

答案 0 :(得分:1)

SharePoint客户端库显然需要访问Windows注册表。沙盒CRM插件中不允许这样做。

在沙盒插件中,只允许使用http或https协议访问Web上的资源。 (也不允许使用IP地址。)