We have moved to GitHub Issues
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.
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
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.
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.
@email@example.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?
Still no luck. Class now inherits from Umbraco.Web.UI.Controls.UmbracoUserControl.
Full error attached if that helps.
Strange, something going on with the indexing. If i can replicate I'll fix it up.
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() ?
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);
Ok no problem, I do a similar thing in Articulate, i'll see if i can replicate there.
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?
Hi, full log attached. I catch the error and write to log with the following:
2015-02-23 16:48:15,692  ERROR USN_SD_V7_Package.usercontrols.usn_sd_v7_package.packageinstaller - [Thread 80] Installation failed. An issue occured updating your demonstration website media
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) ?
On way home, thanks for looking into this, will test first thing 2moro
That worked, no errors this time. What was the issue you spotted?
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.
Great, thanks Shannon
FIxed in rev: 4544520b6673f92e08bac6f76299cae12b429827 with latest examine update
Assignee: Shannon Deminick
Backwards Compatible: True
Affected versions: 7.2.2
Due in version: 7.2.3