0

This code works in console app but not in sandbox visual webpart built using vvs 2012,

        ClientContext context = new ClientContext("http://www.SomeSite.com/sites/test1");
        Web web = context.Web;
        context.Load(web);
        context.ExecuteQuery();

        WebCreationInformation WCI = new WebCreationInformation();
        WCI.Title = "Abc3";
        WCI.Language = 1033;
        WCI.UseSamePermissionsAsParentSite = true;
        WCI.WebTemplate = GetCustomTemplate(web, context).Name;
        WCI.Url = "abc3";


        web.Webs.Add(WCI);

        context.ExecuteQuery();

        Console.WriteLine(web.Id);

I get security error on this line,

ClientContext context = new ClientContext("http://www.SomeSite.com/sites/test1");
3
  • Does the web part work without this code? I had a problem in sandbox when the SharePoint 2013 is installed to AD controller.
    – Alexander
    Commented Apr 2, 2014 at 8:16
  • it's office 365.... Commented Apr 2, 2014 at 13:05
  • In office 365 sandbox is configured correctly
    – Alexander
    Commented Apr 2, 2014 at 21:57

1 Answer 1

0

You will get the error because the running of custom code is not supported in sandbox solutions. You will be getting error as "Web Part Error: Sandboxed code execution request failed. This is because of custom code. It works in console application because you are running the console on your local machine.

Not the answer you're looking for? Browse other questions tagged or ask your own question.