IDeliverable / IDeliverable.Donuts

A module for the Orchard CMS that can dramatically improve the performance of websites by using different caching strategies for different sections of the rendered page.
BSD 3-Clause "New" or "Revised" License
2 stars 2 forks source link

LifetimeScope has already been disposed #2

Open MatteoPiovanelli-Laser opened 4 years ago

MatteoPiovanelli-Laser commented 4 years ago

Hello,

We are trying to set up an ItemLevelCachePart on a MenuWidget. The Menu that will display has one item that changes for each user base on the content of a ContentPickerField set on the user.

@*This code is in the shape for a menu item*@
var useritem = (dynamic)(WorkContext.CurrentUser.ContentItem);
// User has a Part called ProfilePart
if (useritem.ProfilePart.MyCPF.ContentItems != null && useritem.ProfilePart.MyCPF.ContentItems.Length >0 ) {
    // personalize menu here
}

The call to useritem.ProfilePart.MyCPF.ContentItems goes though that property's Loader, that does _contentManager.GetMany(/**/). That call fails as soon as it tries to get the current sessions with the following error:

Instances cannot be resolved and nested lifetimes cannot be created from this LifetimeScope as it has already been disposed.

I've already tried replacing that call to the LazyField with an explicit call to _contentManager.GetMany(/**/), but I see the same error.

I will look a bit more into that.

MatteoPiovanelli-Laser commented 4 years ago

More details:

It looks like the delegate factory that is used in SessionLocator to return a new ContentManagerSession has already been disposed of when the code is calling this from the TransformStream delegate that is being set in PlaceholderResolutionFilter.OnResultExecuted