U4-6303 - SaveAndPublishWithStatus error

Created by Marc Love 20 Feb 2015, 17:42:37 Updated by Shannon Deminick 09 Mar 2015, 04:10:26

Following code now causing error with v7.2.2. Code worked in v7.2.1

ContentService contentService = new ContentService(); var homeNode = contentService.GetRootContent().Where(x => x.Name == "Home").FirstOrDefault(); homeNode.SetValue("metaDescription", "This is my meta description"); contentService.SaveAndPublishWithStatus(homeNode);

SaveAndPublishWithStatus causing error: An exception of type 'System.ObjectDisposedException' occurred in mscorlib.dll but was not handled in user code Additional information: The CancellationTokenSource has been disposed.

3 Attachments

Download error.txt

Download UmbracoTraceLog.txt

Download Examine.zip

Comments

Sebastiaan Janssen 23 Feb 2015, 09:02:36

First off: I can't reproduce this with your exact code on 7.2.2, secondly: Make sure your first line reads:

var contentService = ApplicationContext.Current.Services.ContentService; (you might have to add a using Umbraco.Core;)

Depending on what kind of class you're in you can also just write

var contentService = Services.ContentService;

But in any case you shouldn't new up a ContentService.


Marc Love 23 Feb 2015, 11:53:18

Hi Sebastiaan,

Thanks for the quick reply. I have updated the code as instructed but still getting same issue.

Any content or media creation from code is causing the same issue. Also tried following code to test and getting same error:

var ms = ApplicationContext.Current.Services.MediaService; var mediaFolder = ms.CreateMedia("Photography", -1, "Folder"); ms.Save(mediaFolder);

This code is getting executed as part of a package. Code is within user control fired at the end of package installation.


Sebastiaan Janssen 23 Feb 2015, 13:43:14

@marc@madebycrunch.com Hmmm, I'm not sure if we changed anything related to that. It would be good if you could change your UserControl inheritance to make the class inherit from UmbracoUserControl so it would get some Umbraco context, does that help?


Marc Love 23 Feb 2015, 14:31:27

Hi Sebastiaan,

Still no luck. Class now inherits from Umbraco.Web.UI.Controls.UmbracoUserControl.

Full error attached if that helps.


Shannon Deminick 23 Feb 2015, 14:43:39

Strange, something going on with the indexing. If i can replicate I'll fix it up.


Shannon Deminick 23 Feb 2015, 15:14:57

So the only time that cancellation token get's disposed is on application shutdown when the ExamineManager.Stop is called. This should never be called directly from code. Any chance you are disposing of anything in Examine or calling Stop() ?


Marc Love 23 Feb 2015, 15:38:54

Hi Shannon,

Nothing happening in my code like that. I have a simple usercontrol setup to be called at the end of package installation. I have a method which is called inside Page_Load for the usercontrol which then calls the following code:

var ms = ApplicationContext.Current.Services.MediaService;

//Create Media Folder var mediaFolder = ms.CreateMedia("Photography", -1, "Folder"); ms.Save(mediaFolder);

Any code that is trying to update content also fails with the same error:

var contentService = ApplicationContext.Current.Services.ContentService; var homeNode = contentService.GetRootContent().Where(x => x.Name == "Home").FirstOrDefault(); homeNode.SetValue("metaDescription", "This is my meta description"); contentService.SaveAndPublishWithStatus(homeNode);


Shannon Deminick 23 Feb 2015, 15:58:58

Ok no problem, I do a similar thing in Articulate, i'll see if i can replicate there.


Shannon Deminick 23 Feb 2015, 16:21:32

I can't get it to replicate there. If you can replicate this can you please change your log4net settings to 'Debug' instead of 'Info' and then replicate the issue and send over your log?


Marc Love 23 Feb 2015, 16:52:39

Hi, full log attached. I catch the error and write to log with the following:

2015-02-23 16:48:15,692 [68] ERROR USN_SD_V7_Package.usercontrols.usn_sd_v7_package.packageinstaller - [Thread 80] Installation failed. An issue occured updating your demonstration website media

library.


Shannon Deminick 23 Feb 2015, 17:22:33

Must be an odd sequence of events happening that I can't reproduce however I have found a possible culprit in the examine source. Can you test with this DLL (see zip attached) ?


Marc Love 23 Feb 2015, 17:33:18

On way home, thanks for looking into this, will test first thing 2moro


Marc Love 24 Feb 2015, 09:19:45

Hi Shannon,

That worked, no errors this time. What was the issue you spotted?

Cheers,

Marc


Shannon Deminick 26 Feb 2015, 03:31:03

That's great news ... well it's good news that I know what the problem is, maybe not so great that there is a problem ;)

It's due to a cancelation token check in examine during app shutdown. I'll release a new version of Examine tomorrow with the fix.


Marc Love 26 Feb 2015, 09:44:28

Great, thanks Shannon


Shannon Deminick 09 Mar 2015, 04:10:21

FIxed in rev: 4544520b6673f92e08bac6f76299cae12b429827 with latest examine update


Priority: Major

Type: Bug

State: Fixed

Assignee: Shannon Deminick

Difficulty: Normal

Category:

Backwards Compatible: True

Fix Submitted:

Affected versions: 7.2.2

Due in version: 7.2.3

Sprint:

Story Points:

Cycle: