Can we use SPOfficialFileHost class in a SharePoint Sandbox Solution webpart?
I am getting the following error
Somebody help me plz
Web Part Error: Unhandled exception was thrown by the sandboxed code wrapper's
Execute method in the partial trust app domain:
An unexpected error has occurred.
- Edited by SharePoint2016 Thursday, November 29, 2012 12:10 PM
Based on your error and the fact that MSDN says it "Represents an external connection to which users and services can send files" I would say that its not allowed in a sandboxed solution. The MSDN article does not specify one way or the other, but the real test is the fact that you're seeing the error.
You can also look into the SharePoint Developer Tools for Visual Studio 2010: http://sharepointdevtools.codeplex.com/documentation
It includes a Sandbox Compile option to catch these sorts of things.
Your best bet in using non-sandbox classes is to create a Sandbox Proxy. This is code that can be called from your sandboxed code and will run in full trust.
Here is the MSDN article on creating and using a Sandbox Proxy: http://msdn.microsoft.com/en-us/library/ff798427.aspx
Thanks Atkinson,looks like it should fit to my solution.Can you please let me know where can I change my code to call SPOfficialFileHost class
following is my code
SPWebApplication webapp = site.WebApplication; SPOfficialFileHost newhost = new SPOfficialFileHost(true); newhost.OfficialFileUrl = new Uri(site.Url + "/records/_vti_bin/officialfile.asmx"); newhost.OfficialFileName = "Records Center"; newhost.ShowOnSendToMenu = true; newhost.Action = SPOfficialFileAction.Move; webapp.OfficialFileHosts.Add(newhost); webapp.Update();
- Edited by SharePoint2016 Monday, December 03, 2012 7:28 AM
I have only site collection permissions and I can able to deploy it as a sandbox solutions.Then why Administrator comes into picture and how he will write code and give that assembly references to me ?
why Microsoft introduced this kind of concept?