How do I read this stack trace I'm only getting from scrapers? - asp.net-mvc-4

The following is the stack trace error I get when I try to run my site through a validator like http://validator.w3.org/ or the facebook open graph debugger. The thing is, the page appears to load just fine in the browser, or in the mobile app web view. The only way I can see this error is by having the validator show me error pages (option). Any suggestions about how to read the stack trace? I see the reference to one of my controllers Literrater.Controllers.BookController.Index(Int32 id, String slug) but I havent changed anything and it used to work, and it works fine in the browser. So, I'm confused. Do I need to check redirect happening or something?
The follow page has the problem. http://literrater.azurewebsites.net/book/33625/birdsong-a-novel-of-love-and-war
[RuntimeBinderException: Cannot convert null to 'bool' because it is a non-nullable value type]
CallSite.Target(Closure , CallSite , Object ) +115
System.Dynamic.UpdateDelegates.UpdateAndExecute1(CallSite site, T0 arg0) +661
Literrater.Controllers.BookController.Index(Int32 id, String slug) +13725
lambda_method(Closure , ControllerBase , Object[] ) +146
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary`2 parameters) +182
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary`2 parameters) +27
System.Web.Mvc.Async.<>c__DisplayClass42.<BeginInvokeSynchronousActionMethod>b__41() +28
System.Web.Mvc.Async.<>c__DisplayClass8`1.<BeginSynchronous>b__7(IAsyncResult _) +10
System.Web.Mvc.Async.WrappedAsyncResult`1.End() +50
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult) +32
System.Web.Mvc.Async.<>c__DisplayClass39.<BeginInvokeActionMethodWithFilters>b__33() +58
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +225
System.Web.Mvc.Async.<>c__DisplayClass4f.<InvokeActionMethodFilterAsynchronously>b__49() +225

At this moment, your page is not loading and producing the error:
Exception Details: Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: Cannot convert null to 'bool' because it is a non-nullable value type
Source Error:
Line 32: <div class="status-wrapper">
Line 33: <h2 class="sub-title">Collections</h2>
Line 34: #{Model.CollectionVM.FacebookStatus = ViewBag.FacebookStatus;}
Line 35: #Html.Partial("_MiniBookStatus", Model.CollectionVM)
Line 36:
Source File: d:\home\site\wwwroot\Views\Book\Index.cshtml Line: 34
It looks like maybe you did not initialize the ViewBag.FacebookStatus value in your controller. With those ViewBag values, if you don't set the value in all code paths, then you may have a case like this where the it's null.
As an example:
protected ActionResult Test()
{
ViewBag.SomeString = string.Empty;
ViewBag.SomeBool = false;
//some code
if (condition)
{
ViewBag.SomeBool = true;
}
else
{
ViewBag.SomeString = "Yea I'm a string!";
}
return View();
}
It's good practice to init the ViewBag values or it can come back to bite you in the Razor view because Intellisense won't pick it up, and it won't cause a build error or warning.

Related

Json Errors in raven 3.5 client

Periodically we receive the following error when saving to a Raven Database. The client and database are v3.5. The solution thus far has been to restart the servers and after that things appear to settle down. The user can go to a different server and can go back into the site and retrieved what was saved. However when we see 1 error like this on a server the server starts to report 100's of them. We cannot reproduce this in QA. So I am leaning towards load or our Raven Sessions are not being closed properly.
Calling the Raven OpenSessionAsync() as the point of creating the class
IAsyncDocumentSession
public async Task<bool> SaveChangesAsync()
{
using (_session)
{
await _session.SaveChangesAsync();
}
return true;
}
This is the area in our code that starts the error when saving should we also be doing something more?
Message: Token PropertyName in state Property would result in an invalid JSON object. Path ''.
Raven.Imports.Newtonsoft.Json.JsonWriter.AutoComplete(JsonToken tokenBeingWritten) in C:\Builds\RavenDB-Stable-3.5\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonWriter.cs:779
Raven.Json.Linq.RavenJTokenWriter.WritePropertyName(String name) in C:\Builds\RavenDB-Stable-3.5\Raven.Abstractions\Json\Linq\RavenJTokenWriter.cs:51
Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.SerializeObject(JsonWriter writer, Object value, JsonObjectContract contract, JsonProperty member, JsonContainerContract collectionContract, JsonProperty containerProperty) in C:\Builds\RavenDB-Stable-3.5\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalWriter.cs:428
Raven.Imports.Newtonsoft.Json.Serialization.JsonSerializerInternalWriter.Serialize(JsonWriter jsonWriter, Object value, Type objectType) in C:\Builds\RavenDB-Stable-3.5\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\Serialization\JsonSerializerInternalWriter.cs:101
Raven.Imports.Newtonsoft.Json.JsonSerializer.SerializeInternal(JsonWriter jsonWriter, Object value, Type objectType) in C:\Builds\RavenDB-Stable-3.5\Imports\Newtonsoft.Json\Src\Newtonsoft.Json\JsonSerializer.cs:949
Raven.Json.Linq.RavenJToken.FromObjectInternal(Object o, JsonSerializer jsonSerializer) in C:\Builds\RavenDB-Stable-3.5\Raven.Abstractions\Json\Linq\RavenJToken.cs:91
Raven.Json.Linq.RavenJObject.FromObject(Object o, JsonSerializer jsonSerializer) in C:\Builds\RavenDB-Stable-3.5\Raven.Abstractions\Json\Linq\RavenJObject.cs:174
Raven.Client.Document.EntityToJson.GetObjectAsJson(Object entity) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\EntityToJson.cs:72
Raven.Client.Document.EntityToJson.ConvertEntityToJson(String key, Object entity, RavenJObject metadata) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\EntityToJson.cs:44
Raven.Client.Document.InMemoryDocumentSessionOperations.EntityChanged(Object entity, DocumentMetadata documentMetadata, IDictionary2 changes) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:1218
Raven.Client.Document.InMemoryDocumentSessionOperations.<PrepareForEntitiesPuts>b__110_0(KeyValuePair2 pair) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:1025
System.Linq.Enumerable+WhereEnumerableIterator1.MoveNext():55
System.Linq.Buffer1..ctor(IEnumerable1 source):114
System.Linq.Enumerable.ToArray[TSource](IEnumerable1 source):20
Raven.Client.Document.InMemoryDocumentSessionOperations.PrepareForEntitiesPuts(SaveChangesData result) in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:1025
Raven.Client.Document.InMemoryDocumentSessionOperations.PrepareForSaveChanges() in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\InMemoryDocumentSessionOperations.cs:986
Raven.Client.Document.Async.AsyncDocumentSession+d__73.MoveNext() in C:\Builds\RavenDB-Stable-3.5\Raven.Client.Lightweight\Document\Async\AsyncDocumentSession.cs:928
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw():12
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task):46
ApplicantCenter.Services.ApplicationService+d__9.MoveNext() in d:\a\1\s\Project\Services\ApplicationService_Helpers.cs:207
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw():12
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task):46
ApplicantCenter.Controllers.ApplicationController+d__10.MoveNext() in d:\a\1\s\Project\Controllers\ApplicationController.cs:117
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw():12
System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task):46
System.Web.Mvc.Async.TaskAsyncActionDescriptor.EndExecute(IAsyncResult asyncResult)
System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass8_0.b__1(IAsyncResult asyncResult)
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethod(IAsyncResult asyncResult)
System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters.b__11_0():19
System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass11_1.b__2():134
System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass11_1.b__2():134
System.Web.Mvc.Async.AsyncControllerActionInvoker+AsyncInvocationWithFilters+<>c__DisplayClass11_1.b__2():134
System.Web.Mvc.Async.AsyncControllerActionInvoker.EndInvokeActionMethodWithFilters(IAsyncResult asyncResult)
System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass3_6.b__3()
System.Web.Mvc.Async.AsyncControllerActionInvoker+<>c__DisplayClass3_1.b__5(IAsyncResult asyncResult)
The problem here is that you are disposing the session that maybe used by others.
You put a global _session inside an using block, the _session resources will be disposed after the using block end, and other parts of code that are using the same global _session will become invalid.

How to make Akka.NET's ClusterClient work?

I'm trying out ClusterClient as per the docs.
However my client test app keeps getting the following error:
Error while creating actor instance of type Akka.Cluster.Tools.Client.ClusterClient with 1 args: (Akka.Cluster.Tools.Client.ClusterClientSettings)
Cause: [akka://TestSystem/user/$a#705838478]: Akka.Actor.ActorInitializationException: Exception during creation ---> System.TypeLoadException: Error while creating actor instance of type Akka.Cluster.Tools.Client.ClusterClient with 1 args: (Akka.Cluster.Tools.Client.ClusterClientSettings) ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ArgumentException: failure-detector.heartbeat-interval must be > 0s
at Akka.Remote.DeadlineFailureDetector..ctor(TimeSpan acceptableHeartbeatPause, TimeSpan heartbeatInterval, Clock clock)
at Akka.Remote.DeadlineFailureDetector..ctor(TimeSpan acceptableHeartbeatPause, Clock clock)
at Akka.Cluster.Tools.Client.ClusterClient..ctor(ClusterClientSettings settings)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes, StackCrawlMark& stackMark)
at System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes)
at System.Activator.CreateInstance(Type type, Object[] args)
at Akka.Actor.Props.ActivatorProducer.Produce()
at Akka.Actor.Props.NewActor()
--- End of inner exception stack trace ---
at Akka.Actor.Props.NewActor()
at Akka.Actor.ActorCell.CreateNewActorInstance()
at Akka.Actor.ActorCell.<>c__DisplayClass118_0.<NewActor>b__0()
at Akka.Actor.ActorCell.UseThreadContext(Action action)
at Akka.Actor.ActorCell.NewActor()
at Akka.Actor.ActorCell.Create(Exception failure)
--- End of inner exception stack trace ---
at Akka.Actor.ActorCell.Create(Exception failure)
at Akka.Actor.ActorCell.SysMsgInvokeAll(EarliestFirstSystemMessageList messages, Int32 currentState)
The minimal code I'm using to get this error:
using (var system = ActorSystem.Create("TestSystem")) {
system.Settings.InjectTopLevelFallback(ClusterClientReceptionist.DefaultConfig());
var settings = ClusterClientSettings.Create(system);
var client = system.ActorOf(ClusterClient.Props(settings));
Console.Write("Press any key to exit...");
Console.ReadKey();
}
The HOCON config for the client contains:
akka {
actor {
provider = "Akka.Remote.RemoteActorRefProvider, Akka.Remote"
}
remote {
helios.tcp {
port = 0
hostname = localhost
}
}
cluster {
client {
initial-contacts: ["akka.tcp://TestSystem#localhost:8082/user/receptionist"]
}
}
}
Also checked the settings variable, seemed to be populated and looks ok to me:
Tried several random stuff to actually fulfill the error message:
failure-detector.heartbeat-interval must be > 0s
including various permutation of HOCON entries, but to no avail.
Anything else I missed out?
Update #1
Modified HOCON to initialize Akka.Remote.
Still received what looks like the same error message.
But now it is stating:
failure-detector.heartbeat-interval must be > 0s
Previously it was stating:
failure-detector.acceptable-heartbeat-pause must be >= 0s
Managed to make it working now.
The cause of the issue: I was using Akka.Cluster.Tools latest release version 1.0.6
The fix: Upgraded to the latest beta version 1.1.2.30-beta
p/s: I wished the docs could have specified the minimum NuGet version required to make it work.

Add regex to password complexity in Sitecore 8

The requirement is to require users to have complex passwords requiring minimum length of 8 characters. 1+ non alpha numeric character. 1+ lowercase alpha character. 1+ uppercase alpha character. 1+ number.
I can accomplish this by adding the following to the web.config
<add name="sql" type="System.Web.Security.SqlMembershipProvider" connectionStringName="core" applicationName="sitecore" minRequiredPasswordLength="8" minRequiredNonalphanumericCharacters="1" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" passwordStrengthRegularExpression="(?=.{8,})(?=.*[\d])(?=.*[a-z])(?=.*[A-Z]).*" />
passwordStrengthRegularExpression validation seems to not be handled by Sitecore as I get the following unhandled exception when an invalid password is entered:
376 15:59:41 ERROR Application error.
Exception: System.Web.HttpUnhandledException
Message: Exception of type 'System.Web.HttpUnhandledException' was thrown.
Source: System.Web
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
Nested Exception
Exception: System.Reflection.TargetInvocationException
Message: Exception has been thrown by the target of an invocation.
Source: mscorlib
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Sitecore.Web.UI.XamlSharp.Xaml.XamlControl.ExecuteAjaxMethod(AjaxMethodEventArgs e)
at Sitecore.Web.UI.WebControls.AjaxScriptManager.DispatchMethod(Control control, String parameters)
at Sitecore.Nexus.Pipelines.NexusPipelineApi.Resume(PipelineArgs args, Pipeline pipeline)
at Sitecore.Pipelines.Pipeline.Start(PipelineArgs args, Boolean atomic)
at Sitecore.Web.UI.WebControls.ContinuationManager.RunPipelines()
at Sitecore.Web.UI.WebControls.ContinuationManager.OnPreRender(EventArgs e)
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Control.PreRenderRecursiveInternal()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
Nested Exception
Exception: System.ArgumentException
Message: The parameter 'newPassword' does not match the regular expression specified in config file.
Source: System.Web
at System.Web.Security.SqlMembershipProvider.ChangePassword(String username, String oldPassword, String newPassword)
at Sitecore.Data.DataProviders.NullRetryer.Execute[T](Func`1 action, Action recover)
at Sitecore.Security.SitecoreMembershipProvider.ChangePassword(String username, String oldPassword, String newPassword)
at Sitecore.Security.Accounts.MembershipUserWrapper.ChangePassword(String oldPassword, String newPassword)
at Sitecore.Shell.Applications.Security.SetPassword.SetPasswordPage.OK_Click()
Can this be accomplished by modifying config values or is this something that can easily be accomplished by patching the <loggingin> pipeline?
Looking at the code for the SitecoreMembershipProvider there is a wrapper property for PasswordStrengthRegularExpession and the material methods just hand off processing to the underlying provider, in this case the SqlMembershipProvider. So the error is actually being generated there, as you see from the stack trace.
The exception is actually an expected behaviour for this method according to the MSDN documentation. In your application's login/change password/new user forms you should validate a user's entry against Membership.PasswordStrengthRegularExpression manually to ensure the complexity requirement is met before passing the new value back to Sitecore.
It's hard to tell from your question, but does this cover your case, or are you referring to an error being generated in the Sitecore Change Password dialog (haven't tried that)? If that's the case I would raise a support ticket, as the system really should gracefully cope with that situation. Notwithstanding the documentation eluded to by Nikola (#nsgocev) it seems that at least the author of the Sitecore wrapper did implement at least rudimentary wrappers for this property.

EPiServer-error, Dynamic Data Store 6.2.267.1 can only be used with database version 6204, current version is 6001

I have upgraded a database from EPiServer 5 to 6 R2.
Current database-version is '6103' according to a script run in Microsoft SQL Server Management Studio. However when I try to access the website I get the following error ('current version is 6001'):
Previously a copy of the same database has run successfully with the same website (same web.config and the other files the same (the only difference is the database of the connectionstring).
Dynamic Data Store 6.2.267.1 can only be used with database version 6204, current version is 6001. Make sure both database and assemblies are upgraded correctly.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.InvalidOperationException: Dynamic Data Store 6.2.267.1 can only be used with database version 6204, current version is 6001. Make sure both database and assemblies are upgraded correctly.
Source Error:
[No relevant source lines]
Source File: c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\87acb86c\7104e381\App_global.asax.j09cuuvu.0.cs Line: 0
Stack Trace:
[InvalidOperationException: Dynamic Data Store 6.2.267.1 can only be used with database version 6204, current version is 6001. Make sure both database and assemblies are upgraded correctly.]
EPiServer.Data.Dynamic.Providers.DbDataStoreProvider.ValidateVersion() +427
EPiServer.Data.Dynamic.Providers.DbDataStoreProvider.get_Connection() +36
EPiServer.Data.Dynamic.Providers.DbDataStoreProvider.CreateCommand() +16
EPiServer.Data.Dynamic.Providers.DbDataStoreProvider.ValidateVersion() +75
EPiServer.Data.Dynamic.Providers.DbDataStoreProvider.Initialize(String name, NameValueCollection config) +564
EPiServer.Data.Dynamic.Providers.DataStoreProvider.CreateInstance(ProviderSettings providerSettings) +198
EPiServer.Data.Dynamic.Providers.DataStoreProvider.CreateInstance() +145
EPiServer.Data.Dynamic.<>c__DisplayClass1.<InternalGet>b__0() +11
EPiServer.Data.Cache.LocalCache`2.Add(TKey key, Boolean cacheNullValues, Boolean overwriteExistingValue, Func`1 action) +140
EPiServer.Data.Cache.ReplicatedCache`1.Add(String key, Boolean cacheNullValues, Boolean overwriteExistingValue, Func`1 action, Boolean broadcast) +28
EPiServer.Data.Dynamic.StoreDefinition.InternalGet(String storeName) +172
EPiServer.Data.Dynamic.EPiServerDynamicDataStoreFactory.CreateStore(String storeName, Type type, StoreDefinitionParameters parameters) +110
EPiServer.Data.Dynamic.EPiServerDynamicDataStoreFactory.CreateStore(Type type) +35
EPiServer.Web.InitializationModule.InitializeDynamicDataStore() +169
EPiServer.Web.InitializationModule.<Initialize>b__1a() +5
EPiServer.Web.InitializeEngine.Initialize() +235
EPiServer.Web.InitializationModule.Initialize(EPiServerSection config, Settings settings, ConnectionStringSettingsCollection connectionStringSettings) +2832
EPiServer.Web.InitializationModule.<StaticInitialization>b__4() +34
EPiServer.Web.InitializeEngine.Initialize() +235
EPiServer.Web.InitializationModule.StaticInitialization() +1490
EPiServer.Web.InitializationModule.Initialize(InitializationEngine context) +47
EPiServer.Framework.Initialization.InitializationEngine.InitializeModules() +343
EPiServer.Framework.Initialization.InitializationEngine.Initialize(HostType hostType) +83
EPiServer.Framework.Initialization.InitializationModule.Initialize(HostType hostType) +163
EPiServer.Framework.Initialization.InitializationModule.FrameworkInitialization(HostType hostType) +68
EPiServer.Global..ctor() +54
ASP.global_asax..ctor() in c:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\87acb86c\7104e381\App_global.asax.j09cuuvu.0.cs:0
[TargetInvocationException: Exception has been thrown by the target of an invocation.]
System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck) +0
System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache) +98
System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache) +241
System.Activator.CreateInstance(Type type, Boolean nonPublic) +69
System.RuntimeType.CreateInstanceImpl(BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +1136
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture, Object[] activationAttributes) +111
System.Activator.CreateInstance(Type type, BindingFlags bindingAttr, Binder binder, Object[] args, CultureInfo culture) +23
System.Web.HttpRuntime.CreateNonPublicInstance(Type type, Object[] args) +60
System.Web.HttpApplicationFactory.GetNormalApplicationInstance(HttpContext context) +227
System.Web.HttpApplicationFactory.GetApplicationInstance(HttpContext context) +107
System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr) +327
How do I resolve this?
Sounds like you have had a mix of hotfixed and non-hotfixed 6 R2 environments.
You need to run the SchemaUpdate.sql script for the database giving the error message you posted.
More info here:
http://world.episerver.com/Blogs/Shahid-Nawaz/Dates/2012/1/General-Hotfix-CMS-6-R2/

Enumeration error on results fetched using nhibernate session create sql query

I am using sharp arch ver 1.0.
In the NHibernate PostUpdateEvent I am trying to access database.
public class PostUpdateListener : IPostUpdateEventListener
{
public void OnPostUpdate(PostUpdateEvent postUpdateEvent)
{
var session = NHibernateSession.Current;
var results = session.CreateSQLQuery("Select * from Storefront").List<object>();
for (int i = 0; i < results.Count; i++)
{
}
}
When I try to save any entity and in the postupdateevent i run this select query, it gives the enumeration error on OnFlush. NHibernate\Listeners\FlushFixEventListener .cs Line: 35
I read that using foreach loop runs enumeration operation so better to run for loop. But I tried with the for loop. still makes no difference.
The save operation is processed with SharArch NHibernate Transaction attribute. If I remove the Transaction attribute the query in the postupdatelistener works fine.
here is the stack trace.
[InvalidOperationException: Collection was modified; enumeration operation may not execute.]
System.ThrowHelper.ThrowInvalidOperationException(ExceptionResource resource) +56
System.Collections.Generic.Enumerator.MoveNextRare() +58
System.Collections.Generic.Enumerator.MoveNext() +93
NHibernate.Engine.ActionQueue.ExecuteActions(IList list) in d:\horn.horn\orm\nhibernate\Working-2.1\src\NHibernate\Engine\ActionQueue.cs:112
NHibernate.Engine.ActionQueue.ExecuteActions() in d:\horn.horn\orm\nhibernate\Working-2.1\src\NHibernate\Engine\ActionQueue.cs:147
NHibernate.Event.Default.AbstractFlushingEventListener.PerformExecutions(IEventSource session) in d:\horn.horn\orm\nhibernate\Working-2.1\src\NHibernate\Event\Default\AbstractFlushingEventListener.cs:241
NHibernate.Event.Default.DefaultFlushEventListener.OnFlush(FlushEvent event) in d:\horn.horn\orm\nhibernate\Working-2.1\src\NHibernate\Event\Default\DefaultFlushEventListener.cs:19
Infrastructure.NHibernate.Listeners.FlushFixEventListener.OnFlush(FlushEvent event) in D:\Solutions\Infrastructure\NHibernate\Listeners\FlushFixEventListener .cs:35
NHibernate.Impl.SessionImpl.Flush() in d:\horn.horn\orm\nhibernate\Working-2.1\src\NHibernate\Impl\SessionImpl.cs:1478
Infrastructure.NHibernate.LinqRepository1.Save(T entity) in D:\Solutions\Infrastructure\NHibernate\LinqRepository.cs:95
Tasks.Shared.ContentEntityTasks4.Save(TSaveEntityRequestDetails details) in D:\Solutions\Tasks\Shared\ContentEntityTasks.cs:96
Web.Controllers.Entity.EntityController.Edit(EntityViewModel entityViewModel, HttpPostedFileBase fileName, HttpPostedFileBase mainImageFileName, HttpPostedFileBase thumbnailFileName) in D:\Solutions\Web.Controllers\Entity\EntityController.cs:379
lambda_method(ExecutionScope , ControllerBase , Object[] ) +185
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +236
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary2 parameters) +31
System.Web.Mvc.<>c_DisplayClassa.b_7() +85
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +235491
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +235491
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +235491
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func1 continuation) +235491
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(ControllerContext controllerContext, IList1 filters, ActionDescriptor actionDescriptor, IDictionary2 parameters) +288
System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) +235670
System.Web.Mvc.Controller.ExecuteCore() +174
System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext) +209
System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +599
System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +171
It seems like what is happening is the session is deciding to flush due to the CreateSQLQuery call. That causes the post update event to be added to the list of internal events that need to be fired (guessing at this one).
You should be able to fix it by accessing a child session, instead of the main NH session, by using the event. Like this:
public class PostUpdateListener : IPostUpdateEventListener
{
public void OnPostUpdate(PostUpdateEvent postUpdateEvent)
{
var session = postUpdateEvent.Session.GetSession(EntityMode.Poco)
var results = session.CreateSQLQuery("Select * from Storefront").List<object>();
for (int i = 0; i < results.Count; i++)
{
}
}
}
If you also require adding or updating entities inside this event, for the purposes of an audit log for example, then you'll also want to ensure you flush the inner session.