Umbraco 8.6.0. Cannot access a disposed object. Object name: 'snapshot'.
Hi! I am updating umbraco from 7 to 8 version. I got this piece of code in my project:
public class TypedPublishedContentQuery : IPublishedContentQuery
{
private static readonly Mapper __mapper = new Mapper();
private readonly IPublishedContentQuery __typedPublishedContentQuery;
private readonly PublishedContentTypeResolver __publishedContentTypeResolver;
public TypedPublishedContentQuery()
: this(new PublishedContentQuery(Current.UmbracoContext.PublishedSnapshot, Current.UmbracoContext.VariationContextAccessor))
{
}
public TypedPublishedContentQuery(IPublishedContentQuery typedPublishedContentQuery)
{
this.__publishedContentTypeResolver = new PublishedContentTypeResolver();
this.__typedPublishedContentQuery = typedPublishedContentQuery;
}
public IEnumerable<T> TypedContent<T>(IEnumerable<int> ids)
where T : class, IPublishedContent
{
return this.__typedPublishedContentQuery.Content(ids)
.Select(typedContent =>
this.CreateTypedPublishedContent<T>(typedContent)
)
.Where(typedContent =>
typedContent != null
);
}
public IEnumerable<T> TypedContent<T>(IEnumerable<Guid> ids)
where T : class, IPublishedContent
{
return this.__typedPublishedContentQuery.Content(ids)
.Select(typedContent =>
this.CreateTypedPublishedContent<T>(typedContent)
)
.Where(typedContent =>
typedContent != null
);
}
IEnumerable<IPublishedContent> IPublishedContentQuery.Content(IEnumerable<int> ids)
{
return this.TypedContent<IPublishedContent>(ids);
}
public IEnumerable<IPublishedContent> TypedContent(IEnumerable<Guid> ids)
{
return this.TypedContent<IPublishedContent>(ids);
}
public T TypedContent<T>(int id)
where T : class, IPublishedContent
{
var publishedContent = this.__typedPublishedContentQuery.Content(id);
if(publishedContent == null)
{
return null;
}
var typedContent = this.CreateTypedPublishedContent<T>(publishedContent);
if(typedContent == null)
{
return null;
}
return typedContent;
}
public T TypedContent<T>(Guid id)
where T : class, IPublishedContent
{
var publishedContent = this.__typedPublishedContentQuery.Content(id);
if (publishedContent == null)
{
return null;
}
var typedContent = this.CreateTypedPublishedContent<T>(publishedContent);
if (typedContent == null)
{
return null;
}
return typedContent;
}
IPublishedContent IPublishedContentQuery.Content(int id)
{
return this.TypedContent<IPublishedContent>(id);
}
public IPublishedContent TypedContent(Guid id)
{
return this.TypedContent<IPublishedContent>(id);
}
......
}
After upgrading, When I run the project and starting page opens up for the first time, there is no issues. But if I reload the page i got "Cannot access a disposed object. Object name: 'snapshot'. " issue. Or if I try to open other pages. Can't find where is the problem and why snapshot gets disposed. Would be grateful for any help.
Umbraco 8.6.0. Cannot access a disposed object. Object name: 'snapshot'.
Hi! I am updating umbraco from 7 to 8 version. I got this piece of code in my project:
}
After upgrading, When I run the project and starting page opens up for the first time, there is no issues. But if I reload the page i got "Cannot access a disposed object. Object name: 'snapshot'. " issue. Or if I try to open other pages. Can't find where is the problem and why snapshot gets disposed. Would be grateful for any help.
Juris, Take a look at the discussion here: https://github.com/umbraco/Umbraco-CMS/issues/5073
seems to be a similar issue.
is working on a reply...