Hot answers tagged

20

Can you check that ou have enabled and configured the user code service on your farm and started it? Look for user code service in service applications and create one if it is not there. Then go to Central Administration > System Settings > Manage Services on Server > check that “Microsoft SharePoint Foundation Sandboxed Code Service” service is running


17

Not out-of-the-box AFAIK. You could check it like this: if(AppDomain.CurrentDomain.FriendlyName == "Sandboxed Code Execution Partially Trusted Asp.net AppDomain") { // I'm playing in the sandbox! }


15

AFAIK there is no foolproof way to do this unfortunately. I know Microsoft's SharePoint Patterns & Practices team are using: AppDomain.CurrentDomain.FriendlyName.Contains("Sandbox") So if that's the best they've come up with, it's fair to say that's as good as it gets. Obviously some static helper method is the way to go rather than having this check ...


11

Sandbox mode implies you'll have to do it all at a site level. Personally I'd be going with a CDN link, and additionally I'd be checking to see if it's already been loaded elsewhere in the page - useful in the case of a jquery-dependent webpart which may be included two or three times in a page: https://gist.github.com/902090 Of course, if the solution ...


9

You are not allowed to call ANYTHING outside of the Sandbox. A call to listdata.svc is a call outside the sandbox, requiring System.Net.WebPermissions. This is prohibited by the CAS policies on the Sandbox. You basically have three ways to get around this: Use client side code (JavaScript) Use a farm solution Build a Sandbox Full-Trust proxy solution


9

I ultimately ended up just using a foreach loop to iterate through the SPWeb.Lists collection and then check each list's BaseTemplate value to get all the picture and asset libraries. Code provided below: private void PopulateImageLibraryDropDownList() { base.EnsureChildControls(); _dropDownList.Items.Clear(); ...


8

By default, code access security denies WebPermission to code running in a sandboxed solution (see Restrictions on Sandboxed Solutions in SharePoint 2010) However, you can create a full-trust proxy operation that will enable you to call the services. (see Sandboxed Solutions in Partnership with Full-Trust Proxies in SharePoint 2010)


8

Create a plain ol Web Part that stores the info in the appropriate location (property bags, custom list etc).


7

The System.Net.Mail namespace works with on-premise Sandbox solutions but does not work with Office 365, so there is no way to send email from code. The "Send Email" activitiy in SharePoint Designer workflows in Office 365 does work, so yes, you can use workflow to send email.


7

No you cannot set cookies in the sandbox, the data are not transferred back between the sandbox and the IIS. The Sandbox lives in it's own process and the HttpContext.Current is different from the HttpContext.Current in ASP.NET (that lives in IIS and the w3wp.exe process) For more limitations see: ...


7

I read that sandbox solution is not preferred in SharePoint 2013 and we should use the app model. So is creating artifacts an available approach to do inside SharePoint apps? Yes there are multiple available approaches. The one I use the most is (for provider hosted add-ins) to use a remote event receiver on AppInstalledevent. In the event receiver you can ...


6

It’s better to use the Delete() method of SPWeb.Lists instead of using the Delete() method on the SPList because the latter doesn't delete lists properly sometimes. Try something like: SPWeb mySite= SPContext.Current.Web; SPList myCustomList = mySite.Lists["MyCustomList"]; mySite.Lists.Delete(myCustomList.ID); mySite.Update();


5

You best chance is to try at least four things while debugging: Use logging library "SharePoint Sandbox Logging" to log errors on feature activation, as you probably know logging capabilities on Sandbox are limited. Have Correlation Id with your error? contact Microsoft support Review SharePoint logs for on-premises Sandbox to check for any errors, ...


5

The Page object you're getting in the Sandboxed webpart isn't the real page, so this in one of the things that won't work. Option 1: Render in RenderContents You can manually render your script include in RenderContents: protected override void RenderContents(HtmlTextWriter writer) { string jQuerySrc = Page.ClientScript.GetWebResourceUrl(this.GetType(), ...


5

You should be able to create content types with sandbox solutions http://msdn.microsoft.com/en-us/library/ff798382.aspx What Can I Do with Sandboxed Solutions? Create a content type: Sandbox = Tick This may help you http://sharepointbuzzer.wordpress.com/2010/10/21/list-definition-using-sandbox-in-sharepoint-2010/


5

No there is unfortunatley no possibility to do that.


5

The quota is set in Central Administration -> Applications -> Site Collections -> Quotas and locks. You can set the limit for the site collection and the level at which an email is sent to the admin. You can set it to a very high value. You can also set the resource quotas by using PowerShell, and also set the metrics used to arrive at the resource point ...


5

check if the 'Microsoft SharePoint Foundation Sandboxed Code Service' service is started SharePoint 2010 Central Administration -> System Settings -> Manage Services on Server


5

If you want to send a document as an attachment, you will need to write custom code. Use a feature to create a custom action that adds the "Send as attachment" link to the ECM. <UrlAction Url="~site/_layouts/MyApp/MyCustomPage.aspx?ItemId={ItemId}&amp;ListId={ListId}" /> Clicking this menu item navigates to a custom application page where the ...


5

This is how to check for sandbox: if(System.AppDomain.CurrentDomain.FriendlyName.Contains("Sandbox")) { // I'm in a SandPit } This is how to check for SPO: if(SPContext.Current.Web.siteClientTag.contains("$$16")) { // I'm in the clouds } Mystery solved!?!


4

You have to be a bit tricky to include codebehind for your custom pages in sandbox solutions. Here's a little tutorial on how to do it: http://www.wictorwilen.se/Post/Custom-application-pages-in-the-SharePoint-2010-Sandbox.aspx For example, here's my custom ASPX page: <%@ Page language="C#" MasterPageFile="~masterurl/default.master" ...


4

The code compiles and runs fine for me as long as there is a reference to Microsoft.SharePoint (2010). Are you building a console application? In that case make sure you are using the .NET 3.5 framework (not compact or anything else) and set the platform target to Any CPU in the build section of the project properties. BTW. note that you are leaking a site ...


4

It's related to the sandbox, because you cannot use SPFolder.ContentTypeOrder and SPFolder.UniqueContentTypeOrder in sandbox :\ Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll) Available in Sandboxed Solutions: No Edit: If it's just to order, the code posted as an answer by James in this question might work.


4

You cannot use the SharePoint root folder, nor any of its sub folders. However, you can deploy an aspx file to the content database using a module. Look at the solution here: http://spkbase.codeplex.com That solution also uses the SPUserCodeWebPart to run server-side code on those aspx pages.


4

As you have discovered SPLimitedWebPartManager is not availabe on Sandboxed solutions. Snippet from Waldek Mastykarz blog: Inconvenient provisioning Web Parts instances from Sandboxed Solutions One of the challenges when working with Sandboxed Solutions is how to provision Web Parts instances to pages. If you have done this before in a Farm ...


4

This sort of task is more suited to an event receiver. The itemAdded approach will certainly give you access to the ID. An event receiver does not have the typical delay you see with Workflows, it fires right away. One issue you can experience with ItemAdded events is that they run asynchronously. What this means is that the control is returned to the UI ...


4

Using a pure Sandboxed solution this is not possible. A sandboxed solution has absolutely no access outside the current site collection, that's the whole point of sandboxed solutions. On-premises If you're solution is developed for on-premises SharePoint where it's "just" politics which require the solution to be Sandboxed. Then there is the possibility of ...


4

Don't forget that you also need membership of the SharePoint_Shell_Access role to use PowerShell cmdlets that interact with the content database. Use the Add-SPShellAdmin cmdlet to enable this.


4

I asked that question at the SharePoint Conference and they said there shouldn't be any performance difference. I agree with you though, I would think that unpackaging the wsp, opening a new process, and returning the result would means slower page loads on whatever is using that functionality.


4

There should be almost no difference. In any case the extra time required for interprocess communication is very small compared with getting data from the database. There are two main reasons to use a sandboxed solution: You plan to deploy it to the cloud (SharePoint Online Services) To improve managability and security There are many situtations where ...



Only top voted, non community-wiki answers of a minimum length are eligible