Hello,
We are getting complaints from a customer that sometimes their visitors experience a yellow exception screen with the error:
Object reference not set to an instance of an object..
System.NullReferenceException: Object reference not set to an instance of an object.
at Dynamicweb.Ecommerce.Cart.Notifications.AfterLoginSubscriber.OnNotify(String notification, NotificationArgs args)
at Dynamicweb.Extensibility.Notifications.NotificationManager.Notify(String notification, NotificationArgs eventArgs)
in E:\agent_work\35\s\09 - Core\Dynamicweb.Extensibility\Head\Dynamicweb.Extensibility\Notifications\NotificationManager.cs:line 76
at Dynamicweb.Frontend.LogOnHandler.LogOn(String username, String password, Boolean onlyActive, Boolean impersonateUser, Int32 impersonateUserId, Boolean skipPasswordCheck)
at Dynamicweb.Frontend.LogOnHandler.CookieLogon()
at Dynamicweb.Frontend.SecurityHandler.ExtranetStart()
at Dynamicweb.Frontend.LoginHandler.ExtranetStart(Int32 pageId)
at Dynamicweb.Frontend.PageView.Load()
at Dynamicweb.Frontend.DynamicwebHttpHandler.ProcessRequest(HttpContext context)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStepImpl(IExecutionStep step)
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
I have been looking at this and when I check what code gets hit it seems that there are two lines where properties of the user get read which, as far as I know, can be null if you are not logged in. It are the following two lines:
if (!string.IsNullOrEmpty(extranetLoginArgs.User.Currency) && Dynamicweb.Ecommerce.Services.Currencies.GetCurrency(extranetLoginArgs.User.Currency) != null)
and
if (string.IsNullOrEmpty(extranetLoginArgs.User.CountryCode) || Dynamicweb.Ecommerce.Services.Countries.GetCountry(extranetLoginArgs.User.CountryCode) == null)
We tried to overriding the notificationsubscriber (and hit the null reference exceptions debugging) but it seems the original goes off too and crashes the application.
Can you suggest a solution for this problem?
Greets Hans