SPListItem.Update() = Thread was being aborted.

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;

Thanks, but it solves nothing. I have no error to open the website. The error appears once I update my item in the list.
I tried your code but as I thinked it's always the same error.
public static object Add(String User, String Title, String Text)
try
SuiteBarLog("Add Notification to " + User);
String AuthorLoginName = SPContext.Current.Web.CurrentUser.LoginName;
SuiteBarLog("Sender: " + AuthorLoginName);
String PersonalURL = new PeopleManager().GetPropertiesFor(User).PersonalUrl;
SPSecurity.RunWithElevatedPrivileges(delegate()
SuiteBarLog("RunWithElevatedPrivileges");
using (SPSite Site = new SPSite(PersonalURL))
using (SPWeb Web = Site.OpenWeb())
SuiteBarLog("Open Web: " + Web.Url);
Web.AllowUnsafeUpdates = true;
SPUser Author = Web.EnsureUser(AuthorLoginName);
SuiteBarLog("Author confirmed: " + Author.Email);
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;

Similar Messages

  • Thread was being aborted Exception while creating large number of Sites in SharePoint 2013

    Hi All,
    I am getting threading exception while creating a large extent of sites in SharePoint 2013. I am reading data from an excel file and then looping each row. The sites are creating for first two rows then i am getting exception. This code working fine in dev
    server but not in UAT server. I tried with changing maxRequestLength in web.config but not working. And also followed the below link.
    http://support.microsoft.com/kb/928756
    My code as follows-
    private void CreateSites(DataRow dr)
                try
                    using (SPSite site = new SPSite(OtherSiteCollection)) // I am creating sites in another site collection
                        using (SPWeb web = site.OpenWeb())
                                SPWeb newWeb = null;
                                SPWebTemplateCollection templates = site.RootWeb.GetAvailableWebTemplates(1033);
                                SPWebTemplate template = (from SPWebTemplate m in
                                                              templates
                                                          where m.Title == "SiteTemplate"
                                                          select m).FirstOrDefault(); //Here i am using custom template
        string siteName = dr["Site Name"].ToString();
                                newWeb = web.Webs.Add(siteTitle, siteTitle, siteDescription, 1033, template, true, false); //Getting exception here.
                                newWeb.Update();
                                newWeb.Dispose();
                catch (Exception ex)
                    lblMsg.Text = "Exception in create sites : " + ex.Message + ";" + ex.StackTrace + ";" + ex.ToString()
    I am getting error as-
    Exception in create sites: Thread was being aborted.;   at Microsoft.SharePoint.Library.SPRequestInternalClass.ApplyWebTemplate(String bstrUrl, String bstrWebTemplateContent, Int32 fWebTemplateContentFromSubweb, Int32 fDeleteGlobalListsWithWebTemplateContent,
    String& bstrWebTemplate, Int32& plWebTemplateId)
       at Microsoft.SharePoint.Library.SPRequest.ApplyWebTemplate(String bstrUrl, String bstrWebTemplateContent, Int32 fWebTemplateContentFromSubweb, Int32 fDeleteGlobalListsWithWebTemplateContent, String& bstrWebTemplate, Int32& plWebTemplateId)
       at Microsoft.SharePoint.SPWeb.ProvisionWebTemplate(SPWebTemplate webTemplate, String webTemplateToUse, SPFeatureWebTemplate featureWebTemplate)
       at Microsoft.SharePoint.SPWeb.ApplyWebTemplate(SPWebTemplate webTemplate)
       at Microsoft.SharePoint.SPWeb.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere, Guid appInstanceId)
       at Microsoft.SharePoint.SPWeb.SPWebCollectionProvider.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere, Guid appInstanceId)
       at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere, Guid appInstanceId)
       at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, SPWebTemplate WebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere)
       System.Threading.ThreadAbortException: Thread was being aborted.
       at Microsoft.SharePoint.Library.SPRequestInternalClass.ApplyWebTemplate(String bstrUrl, String bstrWebTemplateContent, Int32 fWebTemplateContentFromSubweb, Int32 fDeleteGlobalListsWithWebTemplateContent, String& bstrWebTemplate, Int32&
    plWebTemplateId)
       at Microsoft.SharePoint.Library.SPRequest.ApplyWebTemplate(String bstrUrl, String bstrWebTemplateContent, Int32 fWebTemplateContentFromSubweb, Int32 fDeleteGlobalListsWithWebTemplateContent, String& bstrWebTemplate, Int32& plWebTemplateId)
       at Microsoft.SharePoint.SPWeb.ProvisionWebTemplate(SPWebTemplate webTemplate, String webTemplateToUse, SPFeatureWebTemplate featureWebTemplate)
       at Microsoft.SharePoint.SPWeb.ApplyWebTemplate(SPWebTemplate webTemplate)
       at Microsoft.SharePoint.SPWeb.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere, Guid appInstanceId)
       at Microsoft.SharePoint.SPWeb.SPWebCollectionProvider.CreateWeb(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean bCreateUniqueSubweb, Boolean bConvertIfThere, Guid appInstanceId)
       at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, String strWebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere, Guid appInstanceId)
       at Microsoft.SharePoint.SPWebCollection.Add(String strWebUrl, String strTitle, String strDescription, UInt32 nLCID, SPWebTemplate WebTemplate, Boolean useUniquePermissions, Boolean bConvertIfThere)
    Thread was being aborted.;   at System.Threading.ThreadAbortException: Thread was being aborted.
    Can anyone please help. Thanks!
    dinesh

    If you do this from a Console application, does it succeed?
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • Thread was being aborted

    I am getting error like in my asp.net website
    System.Threading.ThreadAbortException: Thread was being aborted.
    at System.String.wstrcpy(Char* dmem, Char* smem, Int32 charCount)
    at System.String.FillStringChecked(String dest, Int32 destPos, String src)
    at System.String.Concat(String str0, String str1)
    at reporterror.Page_Load(Object sender, EventArgs e)
    In that procedure i do perform concatenation of two large strings. 
    Can anyone help to know why this error comes? Why Thread was being aborted error comes?

    Hello,
    For ASP.NET projects please consider asking your question here
    http://forums.asp.net/
    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem.

  • Workflow is Canceled instantly - System.Threading.ThreadAbortException: Thread was being aborted.

    Hi,
    I am trying to solve some issues and strange behaviour with an important workflow hooked up with an InfoPath 2010 list in SharePoint 2010. Everything worked fine until now.
    One workflow item has ended prematurely with the workflow history messages "An error has occurred in workflowname" followed by some init text message I added, and finally "Could not start workflowname"
    (not sure of the exact translation but something like that). Status is still "On Going" (again not sure of translation).
    The workflows after this has gotten the status "Canceled" with no further error messages. However the first init text I added is visible in their workflow history but no other messages are displayed, neither my custom ones nor
    the built in.
    Please help me out, any hints or pointers to help debug this is very appreciated! I do not have other than "view" access so I will have to tell the IT-department to check logs and perform changes if needed.
    /Jesper Wilfing
    Edit: The IT guys sent me the error message from the log file:
    Workflow Infrastructure       72fq
     Unexpected Start Workflow: System.Threading.ThreadAbortException: Thread was being aborted.

    Hi,
    Thank you for sharing and it will help others who meet the same issue.
    Best regards,
    Victoria
    Forum Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Victoria Xia
    TechNet Community Support

  • SPUtility.GetPrincipalsInGroup method throws Thread was being aborted error when SPGroup Name is passed

    Hello,
    I am getting 'Thread was being aborted - Unable to evaluate expression because
    the code is optimized or a native frame is on top of the call stack' error
    when I use 'SPUtility.GetPrincipalsInGroup' method.
    bool bReachedMaxCount = false;
    SPPrincipalInfo[] _spPrincInfoColl = SPUtility.GetPrincipalsInGroup(web, groupName, Int32.MaxValue - 1, out bReachedMaxCount);
    We have both SharePoint groups (SPGroup) & Active Directory groups in our site.
    I am checking if logged in user has access to the group name that I am passing here as 'groupName'.
    Code works without any error when I pass 'domain name' as 'groupName' e.g. (Domain\\usergroup) but the same throws error when I pass SharePoint groups (SPGroup) name.
    Both type of these groups have at least 'Read' permission on site.
    I have this code inside 'try-catch' block and hence I am able to catch that thread aborted error.
    What could be the reason for this error? I don't get any call stack and all other properties of exception object are either null or with garbage values.
    I am having SP2010 foundation, VS2012 and .Net4.5 installed on my machine.
    Kindly suggest on this. Thank you.
    Sagar S.

    I think the RunWithElevatedPrivilages is not working correctly. I believe that the new site and web objects need to be opened within elevatedprivilages to work. it looks like the way your code is working the SPsite and SPweb objects are getting opened before
    the RunWithElevatedPrivilages give this a try and see if your result changes.
    bool IsUserInGroup = false;
    try
    SPSecurity.RunWithElevatedPrivileges(() =>
    Guid siteId = SPContext.Current.Site.ID;
    Guid webId = SPContext.Current.Web.ID;
    using (SPSite newSite = new SPSite(siteId)) {
    using (SPWeb newWeb = newSite.OpenWeb(webId)){
    bool bReachedMaxCount = false;
    SPPrincipalInfo[] _spPrincInfoColl = SPUtility.GetPrincipalsInGroup(newWeb, "TestGroup", Int32.MaxValue - 1, out bReachedMaxCount);
    if (_spPrincInfoColl.Where(a => a.LoginName == username).Count() > 0)
    IsUserInGroup = true;
    }//close web
    }//close site
    catch (Exception ex)
    LogManager.LogMessage(ex.Message.ToString());
    Alex

  • SPLongOperation throws error "Thread was being aborted"

    Recently we have migrated our SharePoint application from 2010 to 2013, we have upgraded our solution from VS 2012 to VS 2013 and deployed it successfully in newly installed SharePoint 2013 prior to content DB migrate and all.
    In our solution, we had requirement to implement lengthy operation which create site from site template, copying documents from one library to another, creating user groups and so on. To achieve these, we have used
    SPLongOperation which is taking care for not to abort thread and complete operation without and time constraint, which is working fine 2010 environment. 
    After upgrading to 2013, we started facing problem with "Thread was being aborted", which seems SPLongOperation is not working.
    Have I missed any configuration?
    Help appreciated.
    Arpan Shah MSFT Mark as Answer if it solves your problem. Vote As Helpful if the post is helpful for you.

    Hi,
     According to your description, I suggest you debug your code in the test
    environment and check if the method of SPLongOperation.End throw the exception.
    The code snippet below for your reference:
    //Long Operation Code
    using (SPLongOperation longOperation = new SPLongOperation(this.Page))
    //Start the long operation
    longOperation.Begin();
    //Your Long Operation Code Goes Here...
    //End the long operation
    longOperation.End("http://localhost/_layouts/success.aspx", Microsoft.SharePoint.Utilities.SPRedirectFlags.DoNotEndResponse, HttpContext.Current, "");
    More information:
    http://snahta.blogspot.com/2009/10/splongoperation-class.html
    Thanks,
    Dennis Guo
    TechNet Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help. If you have feedback for TechNet Subscriber Support, contact
    [email protected]
    Dennis Guo
    TechNet Community Support

  • CRVS2010 Beta thread was being aborted

    Hi,
    I am attempting to upgrade from CR 11.5 to CR 2010 Beta2  (with VS 2010, net 4) to see how the reports and applications do in the new environment. All of the reports have sql parameters and connect to sql server 2008r2 stored procedures. I am experiencing one strange issue.
    In the crystal viewer toolbar, if I print the report, after the printer dialog box is opened, the page and report won't work. (it doens't matter if you close the dialog or actually print the report) So, if there are parameter fields or a generate report button, nothing works after the print dialog has been shown. The CrystalDecisions.Web.ErrorEventArgs error says "Thread was being aborted". In order to have access to the web page, the user now needs to refresh the page. Why is this happening? Everything worked fine in both CR 11.5 and CR 2008 Also, if the export button is clicked instead of the print button, everything works fine afterwards, so it's just the print button that is errorring out.
    This error happens both on a development computer (XP sp3) and a development server (2008 x86).
    Any ideas? Thanks, Harlan

    Hi Don,
    I created a new asp.net Crystal reports Web site, created a new report and just connected it to a table instead of a stored procedure with no parameters. When I run it from the browser, I still get the same error messages when I try to print so it does not appear to be a migration issue.
    Thanks again,
    Harlan

  • Thread was being aborted Error.

    HI,
        I am Getting Below error:
    Thread was being aborted. Source of Error :mscorlib Error Method :18 Helplink : Line of Error : at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End() 
    Thanks is in Advance,
    Help me.

    try to move Response outside of the Try/Catch block
    Check this thread
    http://stackoverflow.com/questions/1433448/thread-was-being-aborted

  • Thread being aborted sharepoint 2013

    Hi All,
    I am receiving the below error "Thread being aborted" when i try to open my dev url. I have no idea about the area(ThirdSPS2010) which is throwing error. As the production was set up by third party and i just took back up of the url and also the
    back up of custom webparts and restored in development environment. I am struck with this error now :(
    06/25/2013 14:06:17.45     w3wp.exe (0x22A4)                           0x13DC    ThirdSPS2010               
         Error                             00000    Unexpected    Thread was
    being aborted.    b6c1289c-d07c-a0de-44ea-088cb42c35e3
    Above this i can find multiple Distributed cache warnings as below
    SharePoint Foundation             DistributedCache                  ah24w    Unexpected  
     Unexpected Exception in SPDistributedCachePointerWrapper::InitializeDataCacheFactory for usage 'DistributedLogonTokenCache' - Exception 'System.InvalidOperationException: SPDistributedCachePointerWrapper::InitializeDataCacheFactory - No cache hosts are
    present or running in the farm.     at Microsoft.SharePoint.DistributedCaching.SPDistributedCachePointerWrapper.InitializeDataCacheFactory()'.
    Can someone guide what is the reason for these errors :(
    Thanks in advance
    Ranjani.R

    Unlike other service instances, though, the Distributed Cache Service Instance should either be installed *and* online on a SharePoint server, or not installed at all. If the service instance is stopped (disabled) but not uninstalled, details about the associated
    Cache Host stay in the Cache Cluster Config store, which can cause problems.
    For this reason, the Distributed Cache Service Instance should never be stopped via the Services on Server page in Central Administration or via Stop-SPServiceInstance in PowerShell. A special cmdlet, Remove-SPDistributedCacheServiceInstance, is available
    to stop *and* uninstall the local Distributed Cache Service Instance from a SharePoint server. This cmdlet, and its complement Add-SPDistributedCacheServiceInstance, should be used instead of Stop- and Start-SPServiceInstance for managing the local Distributed
    Cache Service Instance.
    from
    http://blogs.msdn.com/b/besidethepoint/archive/2013/03/27/appfabric-caching-and-sharepoint-2.aspx

  • Error 4 occurred while information structure S001 was being updated.

    Hi experts,
    I set up the environment for the 2LIS_01_S001 DataSource (InfoCube 0SD_C01) accordingly these steps (as mentioned in another thread):
    1) Activating LIS update - goto OMO1 transaction code
    In the Updating – Info Structures(S001) - double-click the Updating radio button for Info structure S001.
    In the Parameters dialog box select Synchronous updating and choose ok.
    2) Goto OLI7 Transaction code - run the statistical update.
    3) Goto OLIX transaction code - setup version &( will be copied to actual version 000 for reporting
    4)Go back to OMO1 do deactive the LIS Update, check radio button to "No Update"
    5)Now goto LBW0 and choose option "Deactivate" Delta updating in LIS.
    6) In BW, Replicate DataSource, and run info Package with Initilization.
    7) Now again in R/3 we need to "Activate" Delta option from transaction code LBW0.
    8) and last step is to goto OMO1 to activate LIS Update to Synchronous updating and save.
    But in step 2 , I am getting an error i.e 
    Error 4 updating info structure S001
    Message no. M2022
    Error 4 occurred while information structure S001 was being updated.
    The update was attempted with the following key:
    &V3 0100000000000000290658
    I am not understanding this error,so cant proceed further.
    waiting for ur replies.
    Thanks in advance.

    Hi Colum
    I have two systems in both i am doing the same process.
    But in my one system i am getting  error
    but in my other system i am not getting  error and my set up table is filled with records.
    According to that note key figures sequence in S001, S001BIW1 & S001BIW2 should be same.
    but i my other system, key figure sequence is different and i am fine working with it.
    so why it is not able to fill my set up table for my other system ?
    thanks in advance.

  • I was being able to watch facebook videos from my ipad, and since i updated my IOS to 7.1.1,i dont know if it has to do with that but now i can no longer see any facebook videos

    I was being able to watch facebook videos from my ipad, and since i updated my IOS to 7.1.1,i dont know if it has to do with that but now i can no longer see any facebook videos

    If you look at the preferences for Flashblock (access from the extensions window of the add-ons manager) and choose Whitelist, you can add a site to that window, and that site will not be blocked by Flashblock at all. You will not even see the Flashblock icon.

  • My ipad was being updated to ios 6.1.3 and when it rebooted it went to recovery mode. I want my ipad 2 back with or without my files.Please help

    My ipad 2 was being updated to ios 6.1.3 and when it rebooted it went to recovery mode. I want my ipad 2 back with or without my files.Please help

    Recovery Mode
    1. Disconnect the USB cable from the device, but leave the other end of the cable connected to your computer's USB port.
    2. Turn off the device: Press and hold the Sleep/Wake button for a few seconds until the red slider appears, then slide the slider. Wait for the device to turn off.
    3.While pressing and holding the Home button, reconnect the USB cable to the device. The device should turn on.
    4. Continue holding the Home button until you see the "Connect to iTunes" screen. When this screen appears, release the Home button. iTunes should alert you that it has detected a device in recovery mode. Click OK, and then click Restore to restore the device.
    Note: Data will be lost. You may have to repeat the above many times.

  • My ipod touch was being updated, computer went on standby - now itunes says i need to restore it?! But i CANT loose my notes, what do i do?!

    My ipod was being updated, computer went on standby - now itunes says i need to restore it?! But i CANT loose my notes, what do i do?! Hw do i fix or repair/resore and get it all back - without loosing anything. Its 32GB, i will do anyhing to avoid loosing my data/notes (600+), and current appox 23000 pics (20000 loaded on computer)

    Once the Device is asking to be Restored with iTunes... it is too late to save anything...
    To minimise loss... Connect to iTunes on the computer you Usually Sync with and Restore from the most recent Backup...
    http://support.apple.com/kb/HT1414

  • HT201210 my iphone was being updated when it was ready to restore it stops sayin an error ocured, the phone wont oparate cant get it to restore

    my iphone was being updated when it was ready to restore it stops sayin an error ocured, the phone wont oparate cant get it to restore

    any specific error messages? If so, check out http://support.apple.com/kb/ts3694 for solutions
    if not, force restore: http://support.apple.com/kb/ht1808
    NB: make sure you have a backup, because following the last article will remove all data/content on the device.
    Good luck

  • Viber deleted itself from my phone while it was being updated but the app store says that i still have it. How can i download viber again?

    Viber deleted itself from my phone while it was being updated but the app store says that i still have it. How can i download viber again?

    Hi,
    We would like to investigate what's going on but we will need more information from you. Please open a support ticket at this link: http://bit.ly/1aOwGy2 and a support agent will be in touch.

Maybe you are looking for