SharePoint 2010 沙盒解决方案不适用于第三方 DLL

SharePoint 2010 Sand box solution does not work with third party DLL

我在 SharePoint 2010 可视化 Web 部件沙盒解决方案中使用第三方库。

我已经按照此处的说明使用“高级”选项卡将程序集添加到包中 https://msdn.microsoft.com/en-us/library/vstudio/ee231595(v=vs.120).aspx

然后我使用 Visual Studio 2013 将其部署到我的本地服务器场。

如果我将部署目标设置为 WebApplication

Error 2 Error occurred in deployment step 'Add Solution': This solution contains invalid markup or elements that cannot be deployed as part of a sandboxed solution. Solution manifest for solution '54d81981-d8ba-4eca-96a7-a766b4b7fbd1' failed validation, file manifest.xml, line 4, character 65: The 'DeploymentTarget' attribute is invalid - The value 'WebApplication' is invalid according to its datatype 'http://schemas.microsoft.com/sharepoint/:SolutionDeploymentTargetType'

如果我选择 GlobalAssemblyCache,它可以工作,但在 运行 Web 部件上,会引发此错误

An exception of type 'System.IO.FileLoadException' occurred in CustomFormBuilder.dll but was not handled in user code Additional information: Could not load file or assembly 'KellermanSoftware.NET-SFTP-Library, Version=4.5.0.0, Culture=neutral, PublicKeyToken=dccbd7ce7d6a58c0' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417)

完全例外

System.IO.FileLoadException was unhandled by user code Message=Could not load file or assembly 'KellermanSoftware.NET-SFTP-Library, Version=4.5.0.0, Culture=neutral, PublicKeyToken=dccbd7ce7d6a58c0' or one of its dependencies. Failed to grant minimum permission requests. (Exception from HRESULT: 0x80131417) Source=CustomFormBuilder
FileName=KellermanSoftware.NET-SFTP-Library, Version=4.5.0.0, Culture=neutral, PublicKeyToken=dccbd7ce7d6a58c0 StackTrace: at CustomFormBuilder.VisualWebPart1.VisualWebPart1.Upload() at CustomFormBuilder.VisualWebPart1.VisualWebPart1.ConfirmBtn_OnClick(Object sender, EventArgs e) at System.Web.UI.WebControls.LinkButton.OnClick(EventArgs e) at System.Web.UI.WebControls.LinkButton.RaisePostBackEvent(String eventArgument) at System.Web.UI.WebControls.LinkButton.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) at System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
InnerException: System.Security.Policy.PolicyException Message=Required permissions cannot be acquired. Source=mscorlib StackTrace: at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Boolean checkExecutionPermission) at System.Security.SecurityManager.ResolvePolicy(Evidence evidence, PermissionSet reqdPset, PermissionSet optPset, PermissionSet denyPset, PermissionSet& denied, Int32& securitySpecialFlags, Boolean checkExecutionPermission) InnerException:

沙盒解决方案无法将 DLL 部署到任何位置(包括 GAC)。错误是设计使然。沙盒的目的是为 运行 SharePoint 内部的代码提供一种安全的方式,而不会危及整个服务器场的健康。沙盒解决方案可以通过 "users" 上传。沙盒内的任何代码都仅限于一组精简的 SharePoint 功能。

使用传统的完全信任代码解决方案并通过您最喜欢的 SharePoint 管理员在您的环境中进行部署。 Visual Webpart 团队也应该在此模型中可用。

从 MSDN 查看此参考资料:

https://msdn.microsoft.com/en-us/library/office/gg615464(v=office.14).aspx

Component - Assembly

Refers to assemblies whose source code is part of the Microsoft Visual Studio sandboxed solution project. Non-SharePoint assemblies cannot be deployed in a sandboxed solution. Assemblies in sandboxed solutions are persisted in the content database inside the solution package (.wsp) file. When called, they are unpacked and temporarily stored in the file system of the front-end web server. For more information, see Where are Assemblies in Sandboxed Solutions Deployed?.

关于 sandbiox 解决方案的更多有用信息