Quantcast
Channel: SharePoint 2013 - Development and Programming forum
Viewing all articles
Browse latest Browse all 7589

SPListItem.Update() => Thread was being aborted.

$
0
0

Hello,

I currently have a problem to update a mysite list item.

This code is working very well on my dev environment but in the production it's not working :/

My logs end with : 

  • ...
  • Item added
  • Error: Thread was being aborted.
  • Nok: Thread was being aborted

Anyone have an idea? (on prod the mysites are in a separate web application. that's the only difference)

Thanks

public static object Add(String User, String Title, String Text) 
        {
            try
            {
                String AuthorLoginName = SPContext.Current.Web.CurrentUser.LoginName;
                SuiteBarLog("Sender: " + AuthorLoginName); 
                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SuiteBarLog("RunWithElevatedPrivileges");
                    using (SPWeb Web = new SPSite(new PeopleManager().GetPropertiesFor(User).PersonalUrl).RootWeb)
                    {
                        SuiteBarLog("Open Web: " + Web.Url);
                        Web.AllowUnsafeUpdates = true;

                        SPUser Author = Web.EnsureUser(AuthorLoginName);

                        try
                        {
                            SPList List = Web.Lists[LISTNAME];
                            
                            SPListItem Item = List.AddItem();
                            SuiteBarLog("Item added");
                            Item["Title"] = Title;
                            Item["Text"] = Text;
                            Item["Read"] = false;
                            Item["Author"] = Author.ID + ";#" + Author.Name;
                            Item.SystemUpdate();
                            SuiteBarLog("Notification Updated");
                            List.Update();
                            SuiteBarLog("List Updated");
                        }
                        catch (Exception ex) 
                        {
                            SuiteBarLog("Error: " + ex.Message);
                        }

                        Web.AllowUnsafeUpdates = false;
                    }
                });
                return "ok";
            }
            catch(Exception ex)
            {
                SuiteBarLog("Nok : " + ex.Message);
                return "Nok : " + ex.Message;                
            }
        }

Viewing all articles
Browse latest Browse all 7589

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>