I have some code that was working with 8.00 and now i am on 8.3.0 and i am getting the following error:
Cannot access a disposed object.\r\nObject name: 'snapshot'.","ExceptionType":"System.ObjectDisposedException","StackTrace":"
at Umbraco.Web.PublishedCache.NuCache.ContentStore.Snapshot.Get(Int32 id) in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\ContentStore.cs:line 1480\r\n
at Umbraco.Web.PublishedCache.NuCache.ContentCache.GetById(Boolean preview, Int32 contentId) in D:\a\1\s\src\Umbraco.Web\PublishedCache\NuCache\ContentCache.cs:line 226\r\n
The code i question looks like:
public class RedirectPublishedContentFinder : IRedirectPublishedContentFinder
{
private IPublishedContentCache publishedCache { get; }
public RedirectPublishedContentFinder(IPublishedContentCache publishedCache)
{
this.publishedCache = publishedCache;
}
public IPublishedContent Find(string url)
{
return publishedCache.GetByRoute(false, new Uri(url).LocalPath.TrimEnd('/'), false);
}
public IPublishedContent Find(int id)
{
return publishedCache.GetById(false, id);
}
public IPublishedContent Find(Guid id)
{
return publishedCache.GetById(false, id);
}
}
The error is happening on line return publishedCache.GetById(false, id);
bool ignoreLocalDb = Boolean.Parse(ConfigurationManager.AppSettings["ignoreLocalDb"]);
//only does this for prod with slots
if (ignoreLocalDb)
{
//see https://github.com/umbraco/Umbraco-CMS/issues/5035#issuecomment-523581706
// its a workaround for azure slot swapping, without this code you end up with
// locks on nucache and site will not boot until u restart it after slot deploy and swap
composition.Register(factory => new PublishedSnapshotServiceOptions
{
IgnoreLocalDb = true
});
}
Cannot access a disposed object
I have some code that was working with 8.00 and now i am on 8.3.0 and i am getting the following error:
The code i question looks like:
The error is happening on line return publishedCache.GetById(false, id);
Looks like something with nucache?
Ok thanks to callums pointer:
See the github comment for more info
Callum would have done:
is working on a reply...