Tag Info

Hot answers tagged

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 ...


10

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


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


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

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 ...


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: ...


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

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

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

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, ...


4

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 ...


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 ...


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

Regardless of what code, or lack thereof, is contained in the solutuion SharePoint will still execute the user/sandobexed soultion inside the sandbox, i.e. it is run but the User Code Service. I'd take a look at the setup of the User Code Serivce and verify that it is correct, this blog posting may help: ...


4

You will need to use the appropriate Resource. In your case, it's in core.resx, resource key "webpartgalleryList". Note that the Web Part Gallery is always at the root of the site collection, so for maximum portability you should access it using web.Site.RootWeb, not web. Also, SPListCollection[string listName] will already throw an exception if the list is ...


4

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(), ...


4

You can't use AppGlobalResource or <%$Resources:RESXFILE,RESOURCEKEY%> in Sandboxed solutions. See Localization in SharePoint 2010 Sandbox Solutions for how to use resources in Sandboxed solutions.


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

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

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

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

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 ...


3

Another equally hacky approach would be to try to do something that isn't allowed in the sandbox and catch the resulting exception. Something like this: static bool? _isSandboxed; static bool IsSandboxed() { if(!_isSandboxed.HasValue) { try { SPSecurity.RunWithElevatedPrivileges(delegate { }); _isSandboxed = false; ...


3

Regarding cookie support in Sandbox Solutions, let me break it into two parts: Write a cookie : Not Supported via HTTPContext(Unless you set and use cookie in same sandbox webpart and in same request- which will obviouly not be the case :-)) Read a cookie : You are free to consume cookies in Sandbox Solutions! Assume, you have a cookie which is set ...


3

MSDN says: Please note that CustomActionGroups cannot be added through a Sandboxed feature in SharePoint 2010. This requires a farm solution in order to be shown (it doesn't provide an error if it is a sandbox). CustomActions can be added to existing SharePoint 2010 groups in a sandboxed feature. Also you should keep in mind that Sandbox solution ...


3

There are different approaches on creating SubSites in your Office 365 SharePoint Online environment. Using a EventReceiver (Which can be a FeatureReceiver). U still need to create a template for the specific subsite, then use the receiver to create the subsite from that template using this: http://msdn.microsoft.com/en-us/library/ms411806.aspx Be aware ...


3

The ~Site and ~SiteCollection tokens are part of the Publishing dll which is not allowed in the Sandbox. So they cannot be referenced from your code or aspx pages. However, the tokens can be used with the Elements.xml. I have used them in the following way: <CustomAction Location="ScriptLink" ScriptSrc="~Site/SiteAssets/myScript.js"/>


3

This is indeed by design. Seeing as sandbox solutions are not allowed to deploy to the file system and content type / field (or any non- aspx / ascx resource, i.e. anything created declaratively through XML) can only be localized using Resource files stored in the RESOURCES folder in the 14 hive, this will not work. Features titles and descriptions CAN be ...


3

I would advise you to have two separate assemblies: MyCustomer.SharePoint.Common MyCustomer.SharePoint.Common.Farm Assembly 1 involves code relevant to both sandbox and farm solutions, while the second assembly is specifically for farm specific code. As the first assembly will be used by both farm and sandbox, you can leave it at ...


3

Here's a link to an article that I found useful when writing an Office365 web part where debugging is virtually impossible. MVPs for SharePoint 2010: Debugging Techniques for SharePoint Online Applications



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