Sandbox solution gives me error :

Unhandled exception was thrown by the sandboxed code wrapper’s Execute method in the partial trust app domain: An unexpected error has occurred

from below code.


  public override void FeatureActivated(SPFeatureReceiverProperties properties)
                SPFieldLookup fldLookupField = null;
                SPList SourceList = null;
                SPWeb RootWeb = null;

                    object obj = properties.Feature.Parent;

                    if (obj is SPWeb)
                        SPWeb web = obj as SPWeb;

                        // Getting Clients List 
                        SourceList = web.Lists["Source List"];
                        fldLookupField = (SPFieldLookup)web.Site.RootWeb.Fields.GetFieldByInternalName("lookUP column");
                        var c = fldLookupField.SchemaXml.ToString();
                        fldLookupField.SchemaXml = fldLookupField.SchemaXml.Replace("List=\"{00000000-0000-0000-0000-000000000000}\"", string.Format("List=\"{0}\"", SourceList.ID.ToString("B")));
                        c = fldLookupField.SchemaXml.ToString();
                        fldLookupField.LookupWebId = SourceList.ParentWeb.ID;

                catch (Exception ex)
                    throw new Exception(ex.Message);

Not getting exception in catch also. Code working good but on share point page gives error.

Can any one help me out as soon as possible ?

  • 1
    May be not related but RootWeb is always null and Dispose is called on it in finally. – Prakash Dec 24 '15 at 9:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.