Failed to retrieve data for content id - after deleting a property - c#

I'm currently working on a project using Umbraco and I ended up with this error after something went wrong when editing an Archetype property. The Archetype object cleared all of its properties for some reason and I deleted it with the intention to re-create it. After deleting it, my root-node and some of its subnodes just stopped working. Whenever I click on them to edit them, the error belows shows up.
The thing is, I only used that Archetype property on the "frontpage"-node, so why the "frontpage"-node's siblings started erroring too, I have no idea about.
I hope you can help me, I can simply not figure out what to do and only my webhost has database backups, and they require a fee in order to restore it.
Received an error from the server
Failed to retrieve data for content id 1082
Mapping types:
Property -> ContentPropertyDisplay
Umbraco.Core.Models.Property -> Umbraco.Web.Models.ContentEditing.ContentPropertyDisplay
Destination path:
IEnumerable`1[0]
Source value:
Umbraco.Core.Models.Property
EXCEPTION DETAILS:
AutoMapper.AutoMapperMappingException:
Mapping types:
Property -> ContentPropertyDisplay
Umbraco.Core.Models.Property -> Umbraco.Web.Models.ContentEditing.ContentPropertyDisplay
Destination path:
IEnumerable`1[0]
Source value:
Umbraco.Core.Models.Property
STACKTRACE:
ved AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)
ved AutoMapper.Mappers.EnumerableMapperBase`1.Map(ResolutionContext context, IMappingEngineRunner mapper)
ved AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)
ved AutoMapper.MappingEngine.Map(Object source, Type sourceType, Type destinationType, Action`1 opts)
ved AutoMapper.MappingEngine.Map[TSource,TDestination](TSource source)
ved AutoMapper.Mapper.Map[TSource,TDestination](TSource source)
ved Umbraco.Web.Models.Mapping.TabsAndPropertiesResolver.ResolveCore(IContentBase content)
ved AutoMapper.ValueResolver`2.Resolve(ResolutionResult source)
ved AutoMapper.PropertyMap.<ResolveValue>b__6(ResolutionResult current, IValueResolver resolver)
ved System.Linq.Enumerable.Aggregate[TSource,TAccumulate](IEnumerable`1 source, TAccumulate seed, Func`3 func)
ved AutoMapper.PropertyMap.ResolveValue(ResolutionContext context)
ved AutoMapper.Mappers.TypeMapObjectMapperRegistry.PropertyMapMappingStrategy.MapPropertyValue(ResolutionContext context, IMappingEngineRunner mapper, Object mappedObject, PropertyMap propertyMap)
ved AutoMapper.Mappers.TypeMapObjectMapperRegistry.PropertyMapMappingStrategy.Map(ResolutionContext context, IMappingEngineRunner mapper)
ved AutoMapper.Mappers.TypeMapMapper.Map(ResolutionContext context, IMappingEngineRunner mapper)
ved AutoMapper.MappingEngine.AutoMapper.IMappingEngineRunner.Map(ResolutionContext context)
ved AutoMapper.MappingEngine.Map(Object source, Type sourceType, Type destinationType, Action`1 opts)
ved AutoMapper.MappingEngine.Map[TSource,TDestination](TSource source)
ved AutoMapper.Mapper.Map[TSource,TDestination](TSource source)
ved Umbraco.Web.Editors.ContentController.GetById(Int32 id)
ved lambda_method(Closure , Object , Object[] )
ved System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
ved System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
ved System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()
--- Afslutningen på staksporingen fra den tidligere placering, hvor undtagelsen blev udløst ---
ved System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
ved System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
ved System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()

The issue was fixed by restoring a backup of the files. As I mentioned, I had no database backup, but I did have a backup of the Umbraco files, just had no idea that would actually fix it considering it was a datatype screwing me over.

Related

MailKit: SocketException thrown during Connect: "A non-recoverable error occurred during a database lookup"

when I try send email using MailKit so I got error:
System.Net.Sockets.SocketException (0x80004005): A non-recoverable error occurred during a database lookup
OS: Windows 10
.NET Framework: 4.5
MailKit version: 2.15.0
I have two separate projects in Visual Studio. First project is Class Library and there is no problem with connection. Second project is Console Application and here occurs this problem.
Could you somebody help me with this issue. Thanks a lot
Code:
using MailKit.Net.Smtp;
using MailKit.Security;
SmtpClient smtp = new SmtpClient();
smtp.Connect("mail.tophosting.cz", "465", SecureSocketOptions.Auto);
StackTrace:
v System.Net.Dns.HostResolutionEndHelper(IAsyncResult asyncResult)
v System.Net.Dns.EndGetHostAddresses(IAsyncResult asyncResult)
v System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- Konec trasování zásobníku z predchozího místa, ze kterého byla vyvolána vyjimka ---
v System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
v System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
v MailKit.Net.SocketUtils.<ConnectAsync>d__0.MoveNext() v D:\src\MailKit\MailKit\Net\SocketUtils.cs:rádek 0
--- Konec trasování zásobníku z predchozího místa, ze kterého byla vyvolána vyjimka ---
v System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
v System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
v MailKit.Net.SocketUtils.<ConnectAsync>d__1.MoveNext() v D:\src\MailKit\MailKit\Net\SocketUtils.cs:rádek 100
--- Konec trasování zásobníku z predchozího místa, ze kterého byla vyvolána vyjimka ---
v System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
v System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
v MailKit.MailService.<ConnectSocket>d__76.MoveNext() v D:\src\MailKit\MailKit\MailService.cs:rádek 574
--- Konec trasování zásobníku z predchozího místa, ze kterého byla vyvolána vyjimka ---
v System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
v System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
v System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
v MailKit.Net.Smtp.SmtpClient.<ConnectAsync>d__93.MoveNext() v D:\src\MailKit\MailKit\Net\Smtp\SmtpClient.cs:rádek 1169
--- Konec trasování zásobníku z predchozího místa, ze kterého byla vyvolána vyjimka ---
v System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
v System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
v MailKit.Net.Smtp.SmtpClient.Connect(String host, Int32 port, SecureSocketOptions options, CancellationToken cancellationToken) v D:\src\MailKit\MailKit\Net\Smtp\SmtpClient.cs:rádek 1346
v HeliosService.Services.Mail.MailService.connect() v C:\Users\alesk\Google Drive\Work\Helios\Externi reseni\HeliosService\Services\Mail\MailService.cs:rádek 54
v DealerSync.Program.Main(String[] args) v C:\Users\alesk\Google Drive\Work\redenge\Externi reseni\Dealer System\DealerSync\DealerSync\Program.cs:rádek 47------------------------
v System.Net.Dns.HostResolutionEndHelper(IAsyncResult asyncResult)
v System.Net.Dns.EndGetHostAddresses(IAsyncResult asyncResult)
v System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- Konec trasování zásobníku z predchozího místa, ze kterého byla vyvolána vyjimka ---
v System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
v System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
v MailKit.Net.SocketUtils.<ConnectAsync>d__0.MoveNext() v D:\src\MailKit\MailKit\Net\SocketUtils.cs:rádek 0
--- Konec trasování zásobníku z predchozího místa, ze kterého byla vyvolána vyjimka ---
v System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
v System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
v MailKit.Net.SocketUtils.<ConnectAsync>d__1.MoveNext() v D:\src\MailKit\MailKit\Net\SocketUtils.cs:rádek 100
--- Konec trasování zásobníku z predchozího místa, ze kterého byla vyvolána vyjimka ---
v System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
v System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
v MailKit.MailService.<ConnectSocket>d__76.MoveNext() v D:\src\MailKit\MailKit\MailService.cs:rádek 574
--- Konec trasování zásobníku z predchozího místa, ze kterého byla vyvolána vyjimka ---
v System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
v System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
v System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd(Task task)
v MailKit.Net.Smtp.SmtpClient.<ConnectAsync>d__93.MoveNext() v D:\src\MailKit\MailKit\Net\Smtp\SmtpClient.cs:rádek 1169
--- Konec trasování zásobníku z predchozího místa, ze kterého byla vyvolána vyjimka ---
v System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
v System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
v MailKit.Net.Smtp.SmtpClient.Connect(String host, Int32 port, SecureSocketOptions options, CancellationToken cancellationToken) v D:\src\MailKit\MailKit\Net\Smtp\SmtpClient.cs:rádek 1346
v HeliosService.Services.Mail.MailService.connect() v C:\Users\alesk\Google Drive\Work\Helios\Externi reseni\HeliosService\Services\Mail\MailService.cs:rádek 54
v DealerSync.Program.Main(String[] args) v C:\Users\alesk\Google Drive\Work\redenge\Externi reseni\Dealer System\DealerSync\DealerSync\Program.cs:rádek 47

Ninject Serilization error when calling new StandardKernel

When I try to call
var ninjectKernel = new StandardKernel();
I get the below error. I can successfully use ninject with constructor injection. I only get this error when I try to grab a service by hand.
{"Message":"An error has occurred.","ExceptionMessage":"Type
'Ninject.Web.WebApi.NinjectDependencyResolver' in assembly
'Ninject.Web.WebApi, Version=3.3.1.0, Culture=neutral,
PublicKeyToken=c7192dc5380945e7' is not marked as
serializable.","ExceptionType":"System.Runtime.Serialization.SerializationException","StackTrace":"
at System.AppDomain.CreateInstanceAndUnwrap(String assemblyName,
String typeName)\r\n at
Ninject.Modules.AssemblyNameRetriever.GetAssemblyNames(IEnumerable1 filenames, Predicate1 filter)\r\n at
Ninject.Modules.CompiledModuleLoaderPlugin.LoadModules(IEnumerable1 filenames)\r\n at Ninject.Modules.ModuleLoader.LoadModules(IEnumerable1 patterns)\r\n
at Ninject.KernelBase.Load(IEnumerable1 filePatterns)\r\n at Ninject.KernelBase..ctor(IComponentContainer components, INinjectSettings settings, INinjectModule[] modules)\r\n at Ninject.KernelBase..ctor(INinjectModule[] modules)\r\n at Ninject.StandardKernel..ctor(INinjectModule[] modules)\r\n at Controllers.Controllers.TagController.GetTags(TagEnum tagType) in C:\\Users\\george\\Desktop\\NewScp\\SCP\\UI\\Controllers\\TagController.cs:line 39\r\n at lambda_method(Closure , Object , Object[] )\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)\r\n at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary2 arguments, CancellationToken
cancellationToken)\r\n--- End of stack trace from previous location
where exception was thrown ---\r\n at
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Controllers.ApiControllerActionInvoker.d__1.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Controllers.ActionFilterResult.d__5.MoveNext()\r\n---
End of stack trace from previous location where exception was thrown
---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task
task)\r\n at
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task
task)\r\n at
System.Web.Http.Dispatcher.HttpControllerDispatcher.d__15.MoveNext()"}

Unable to execute groupby query using OData V4 query syntax in Web API

I am trying to upgrade my web api to use OData V4 query syntax. After upgrading the dlls am able to issue $filter and $select queries for my web api.
But When I issue a request like https://localhost:65000/api/Entitlement?$apply=groupby((Grade)), getting below exception (am using NHibernate ORM)
{
"message": "An error has occurred.",
"exceptionMessage": "MemberInitExpression",
"exceptionType": "System.NotSupportedException",
"stackTrace": " at NHibernate.Linq.Visitors.HqlGeneratorExpressionTreeVisitor.VisitExpression(Expression expression)\r\n at NHibernate.Linq.Visitors.ResultOperatorProcessors.ProcessGroupBy.<>c__DisplayClass1.<Process>b__0(Expression k)\r\n at System.Linq.Enumerable.WhereSelectArrayIterator`2.MoveNext()\r\n at System.Linq.Buffer`1..ctor(IEnumerable`1 source)\r\n at System.Linq.Enumerable.ToArray[TSource](IEnumerable`1 source)\r\n at NHibernate.Linq.Visitors.ResultOperatorProcessors.ProcessGroupBy.Process(GroupResultOperator resultOperator, QueryModelVisitor queryModelVisitor, IntermediateHqlTree tree)\r\n at NHibernate.Linq.Visitors.ResultOperatorProcessors.ResultOperatorProcessor`1.Process(ResultOperatorBase resultOperator, QueryModelVisitor queryModel, IntermediateHqlTree tree)\r\n at NHibernate.Linq.Visitors.ResultOperatorProcessors.ResultOperatorMap.Process(ResultOperatorBase resultOperator, QueryModelVisitor queryModel, IntermediateHqlTree tree)\r\n at NHibernate.Linq.Visitors.QueryModelVisitor.VisitResultOperator(ResultOperatorBase resultOperator, QueryModel queryModel, Int32 index)\r\n at Remotion.Linq.Clauses.ResultOperatorBase.Accept(IQueryModelVisitor visitor, QueryModel queryModel, Int32 index)\r\n at Remotion.Linq.QueryModelVisitorBase.VisitResultOperators(ObservableCollection`1 resultOperators, QueryModel queryModel)\r\n at Remotion.Linq.QueryModelVisitorBase.VisitQueryModel(QueryModel queryModel)\r\n at NHibernate.Linq.Visitors.QueryModelVisitor.GenerateHqlQuery(QueryModel queryModel, VisitorParameters parameters, Boolean root)\r\n at NHibernate.Linq.NhLinqExpression.Translate(ISessionFactoryImplementor sessionFactory)\r\n at NHibernate.Hql.Ast.ANTLR.ASTQueryTranslatorFactory.CreateQueryTranslators(String queryIdentifier, IQueryExpression queryExpression, String collectionRole, Boolean shallow, IDictionary`2 filters, ISessionFactoryImplementor factory)\r\n at NHibernate.Engine.Query.QueryPlanCache.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow, IDictionary`2 enabledFilters)\r\n at NHibernate.Impl.AbstractSessionImpl.GetHQLQueryPlan(IQueryExpression queryExpression, Boolean shallow)\r\n at NHibernate.Impl.AbstractSessionImpl.CreateQuery(IQueryExpression queryExpression)\r\n at NHibernate.Linq.DefaultQueryProvider.PrepareQuery(Expression expression, IQuery& query, NhLinqExpression& nhQuery)\r\n at NHibernate.Linq.DefaultQueryProvider.Execute(Expression expression)\r\n at NHibernate.Linq.DefaultQueryProvider.Execute[TResult](Expression expression)\r\n at Remotion.Linq.QueryableBase`1.System.Collections.IEnumerable.GetEnumerator()\r\n at System.Linq.Enumerable.<OfTypeIterator>d__95`1.MoveNext()\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n at MatrixGroup.Bmx.Server.Filters.UnitOfWorkFilterAttribute.OnActionExecuted(HttpActionExecutedContext actionExecutedContext)\r\n at System.Web.Http.Filters.ActionFilterAttribute.OnActionExecutedAsync(HttpActionExecutedContext actionExecutedContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()"
}

HttpContext.Current.Session and UmbracoContext.Current.Session is always null in Umbraco

I am using Umbraco 7.5.7 for my application When ever I click on the content item in CMS it shows me this error, I have provided the code below, can some help me on this.
HttpContext.Current.Session and UmbracoContext.Current.HttpContext.Session is always null in Umbraco CMS while accessing content and throwing
Received an error from the server
-"value cannot be null. Parameter Name: httpSessionState" error on the cms UI
IManageState.cs
public interface IManageState
{
void SetValue(string key, object data);
bool HasKey(string key);
T GetValue<T>(string key);
bool SessionIdExists();
}
SessionContext.cs
protected readonly IManageState SessionManager;
public SessionContext()
{
SessionManager = new HttpSessionManager();
}
HttpSessionManager.cs
public class HttpSessionManager : IManageState
{
private readonly HttpSessionStateBase _session;
public HttpSessionManager()
{
}
public HttpSessionManager(HttpSessionStateBase session)
{
_session = session;
}
public HttpSessionStateBase Session
{
get { return _session ?? new HttpSessionStateWrapper(HttpContext.Current.Session); }//getting null here for HttpContext.Current.Session
}
public void SetValue(string key, object data)
{
Session[key] = data;
}
public bool HasKey(string key)
{
return Session[key] != null;
}
public T GetValue<T>(string key)
{
return HasKey(key) ? (T)Session[key] : default(T);
}
public bool SessionIdExists()
{
if (HttpContext.Current.Session == null)
{
return false;
}
string cookieHeader = HttpContext.Current.Request.Headers[GenericConstants.Cookie];
return !string.IsNullOrEmpty(cookieHeader)
&& cookieHeader.IndexOf(GenericConstants.AuthorizationCode, StringComparison.OrdinalIgnoreCase) >= 0
&& HttpContext.Current.Request.Cookies[GenericConstants.DOTNETSESSIONID] != null
&& Session[GenericConstants.AuthorizationCode] != null
&& HttpContext.Current.Request.Cookies[GenericConstants.AuthorizationCode] == Session[GenericConstants.AuthorizationCode];
}
}
I have also tried the below code, I replaced this line
get { return _session ?? new HttpSessionStateWrapper(HttpContext.Current.Session); }
with
get { return _session != null ? _session : HttpContext.Current.Session != null ? new HttpSessionStateWrapper(HttpContext.Current.Session): UmbracoContext.Current.HttpContext.Session ; }
StackTrace
at System.Web.HttpSessionStateWrapper..ctor(HttpSessionState httpSessionState)
at MyProject.Infrastructure.Services.HttpSessionManager.get_Session() in D:\MyProject\MyProject.Infrastructure\Services\HttpSessionManager.cs:line 50
at MyProject.Infrastructure.Services.HttpSessionManager.HasKey(String key) in D:\MyProject\MyProject.Infrastructure\Services\HttpSessionManager.cs:line 74
at MyProject.Infrastructure.Services.HttpSessionManager.GetValue[T](String key) in D:\MyProject\MyProject.Infrastructure\Services\HttpSessionManager.cs:line 123
at MyProject.Web.Http.SessionContext.get_IsAuthenticated() in D:\MyProject\MyProject.Web\Http\SessionContext.cs:line 125
at ASP._Page_Views_MacroPartials_Dashboard_cshtml.Execute() in d:\MyProject\MyProject.Web\Views\MacroPartials\Dashboard.cshtml:line 7
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy()
at System.Web.Mvc.WebViewPage.ExecutePageHierarchy()
at System.Web.WebPages.WebPageBase.ExecutePageHierarchy(WebPageContext pageContext, TextWriter writer, WebPageRenderingBase startPage)
at System.Web.Mvc.RazorView.RenderView(ViewContext viewContext, TextWriter writer, Object instance)
at System.Web.Mvc.BuildManagerCompiledView.Render(ViewContext viewContext, TextWriter writer)
at Umbraco.Core.Profiling.ProfilingView.Render(ViewContext viewContext, TextWriter writer)
at Umbraco.Web.Mvc.ControllerExtensions.RenderViewResultAsString(ControllerBase controller, ViewResultBase viewResult)
at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, IPublishedContent content)
at Umbraco.Web.Macros.PartialViewMacroEngine.Execute(MacroModel macro, INode node)
at umbraco.macro.LoadPartialViewMacro(MacroModel macro)
at umbraco.macro.renderMacro(Hashtable pageElements, Int32 pageId)
at Umbraco.Web.UmbracoComponentRenderer.RenderMacro(macro m, IDictionary`2 parameters, page umbracoPage)
at Umbraco.Web.Editors.MacroController.GetMacroResultAsHtml(String macroAlias, Int32 pageId, IDictionary`2 macroParams)
at Umbraco.Web.Editors.MacroController.GetMacroResultAsHtmlForEditor(MacroParameterModel model)
at lambda_method(Closure , Object , Object[] )
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments)
at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__5.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__1.MoveNext()

nlog event context custom variables log error

I have a simple setup with Nlog, its working fine when just passing through normal parameters like the message, but when i pass a LogEventInfo object like this:
//inside a class
private static Logger _logger = LogManager.GetLogger("MyLogs");
//in a method
LogEventInfo logEvent = new LogEventInfo(LogLevel.Info, "LogName", "some message");
logEvent.Properties.Add("httpMethod", "GET");
_logger.Warn(logEvent);
I am receiving the following error:
[InvalidOperationException: Collection was modified; enumeration operation may not execute.]
System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +52
System.Collections.Generic.Enumerator.MoveNext() +10900893
NLog.Targets.Target.MergeEventProperties(LogEventInfo logEvent) +312
NLog.Targets.Target.Write(AsyncLogEventInfo logEvent) +74
[NLogRuntimeException: Exception occurred in NLog]
NLog.<>c__DisplayClass1.<Write>b__0(Exception ex) +150
NLog.Internal.SingleCallContinuation.Function(Exception exception) +153
NLog.Targets.Target.Write(AsyncLogEventInfo logEvent) +189
NLog.Targets.Target.WriteAsyncLogEvent(AsyncLogEventInfo logEvent) +364
NLog.LoggerImpl.WriteToTargetWithFilterChain(TargetWithFilterChain targetListHead, LogEventInfo logEvent, AsyncContinuation onException) +341
NLog.LoggerImpl.Write(Type loggerType, TargetWithFilterChain targets, LogEventInfo logEvent, LogFactory factory) +351
NLog.Logger.WriteToTargets(LogLevel level, IFormatProvider formatProvider, T value) +136
NLog.Logger.Warn(T value) +106
proj.Infrastructure.Logging.LogResponse(String message, IOwinContext context, String flow, String action) in c:\Sites\proj\Infrastructure\Logging.cs:45
proj.<Validate>d__0.MoveNext() in c:\Sites\proj\myclass.cs:40
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21
Microsoft.Owin.Security.OAuth.<InvokeTokenEndpointAsync>d__1e.MoveNext() +1049
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.TaskAwaiter.GetResult() +21
Microsoft.Owin.Security.OAuth.<InvokeAsync>d__0.MoveNext() +1735
System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) +93
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) +52
System.Runtime.CompilerServices.TaskAwaiter`1.GetResult() +24
Microsoft.Owin.Security.Infrastructure.<Invoke>d__0.MoveNext() +664
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() +22
Microsoft.Owin.Host.SystemWeb.Infrastructure.ErrorState.Rethrow() +33
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.StageAsyncResult.End(IAsyncResult ar) +150
Microsoft.Owin.Host.SystemWeb.IntegratedPipeline.IntegratedPipelineContext.EndFinalWork(IAsyncResult ar) +42
System.Web.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +415
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +155
This is the nlog configuration file:
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
internalLogFile="c:\log.txt"
internalLogLevel="Trace"
throwExceptions="true">
<targets>
<target xsi:type="File" name="textFile"
fileName="${basedir}/logs/${shortdate}/file.txt" layout="${message} ${event-context:item=httpMethod}"/>
</targets>
<rules>
<logger name="*" minlevel="Trace" writeTo="textFile" />
</rules>
</nlog>
I have had a search, and cant find anything related. The nlog version i am using is: 3.1.0.0
Anyone have any ideas?
In this case you should use void Log(LogEventInfo logEvent) method.
_logger.Log(logEvent);
Source: https://github.com/NLog/NLog/wiki/EventContext-Layout-Renderer
But if you want know why this happen, you can follow by link:
https://github.com/NLog/NLog/commit/02e7eff1c5606ea4a4aa4dffc3114adf82791bd6

Categories