I am using a third party library in my SharePoint 2010 Visual Web Part sand box solution.
I have already added the assembly to the Package using the Advance tab as instructed here https://msdn.microsoft.com/en-us/library/vstudio/ee231595(v=vs.120).aspx
I then use Visual Studio 2013 to deploy it to my local farm.
If I set Deployment Target to 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'
If I choose GlobalAssemblyCache, it works but upon running the web part, this error is thrown
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)
Full exception
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:
A sandbox solution can not deploy DLL's to any location (including the GAC). The error is by design. The purpose of the sandbox is to provide a safe way to run code inside of SharePoint without risking the overall farm health. Sandbox solution can be uploaded by "users". Any code inside a sandbox is limited to a reduced set of SharePoint features.
Use a traditional full trust code solution and deploy through your favorit SharePoint admin on your environment. The Visual Webpart teample should also be available in this model.
Check out this refernece from 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?.
More usefull information regarding sandbiox solution
User contributions licensed under CC BY-SA 3.0