Developer forum

Forum » Dynamicweb 9.0 Upgrade issues » DW 9.3.5 Dynamicweb.Security.UserManagement.User.Save() crashes on Dynamicweb.Ecommerce.Cart.UserSavedSubscriber.OnNotify

DW 9.3.5 Dynamicweb.Security.UserManagement.User.Save() crashes on Dynamicweb.Ecommerce.Cart.UserSavedSubscriber.OnNotify

Hans Kloppenborg
Reply

Hello,

I am writing some backend code for a DW solution that has products, but no cart. When I create a user and save it, somehow the Dynamicweb.Ecommerce.Cart.UserSavedSubscriber gets called and crashes with a null reference in Dynamicweb.Ecommerce.Common.Context.GetCart() with the stacktrace:

at Dynamicweb.Ecommerce.Common.Context.GetCart()
   at Dynamicweb.Ecommerce.Cart.UserSavedSubscriber.OnNotify(String notification, NotificationArgs args)
   at Dynamicweb.Extensibility.Notifications.NotificationManager.Notify(String notification, NotificationArgs eventArgs)
   at Dynamicweb.Security.UserManagement.User.Save()

I have tried to override the UserSavedSubscriber OnNotify method, and while debugging see that it gets called, but even then the exception occurs afterwards. (which seems weird, the override should prevent excecution of normal code I would think)

Is this normal behavior when not implementing the cart and can I do something to solve this, or is this a bug?

Greets Hans


Replies

 
Nicolai Pedersen
Reply

Hi Hans

Think it might be the same issue as this one: http://doc.dynamicweb.com/forum/development/development/how-to-handle-nullable-user-custom-fields

So update to a hotfix with that TFS# included.

BR Nicolai

 
Hans Kloppenborg
Reply

Hai Nicolai,

I have updated to 9.3.6 and the problem is still not solved. My workaround at this moment is to catch the exception and ignore it, but thats really ugly. Am I really the only one that saves users using the api?

Even a super simple piece of code:

user.Active = false;

user.Save();

crashes. This is on an existing user.

Greets Hans

 
Nicolai Pedersen
Reply

Hi Hans

Now I read your stack trace again, I can see that this is something else - the bug I linked to is not related to this exception. Sorry about that.

Can I see the conext of your code? Runinng in a .aspx, thread or where?

BR Nicolai

 

 
Hans Kloppenborg
Reply

Hai Nicolai,

The code runs in a handler in the ProcessRequest part in a DW application that uses products in a catalog, but has no cart/order traject configured.

I added a notificationobserver for the notification that seems to be called in the stacktrace, and if I debug that he first comes in that observer, and after that he still goes to the overridden observer to crash.

Greets Hans

.

 
Nicolai Pedersen
Reply

ok - so you are in a context without a sessionstate - which I think is the cause.

I've made a change to the API, TFS#42247, that I believe should fix the issue. Will be out with the next release of Dynamicweb.Ecommerce.dll

Attached find a pirate version of that dll for you to test on.

BR Nicolai

 
Kristian Kirkholt Dynamicweb Employee
Kristian Kirkholt
Reply

Hi Hans

The problem TFS#42247 "Make it possible to save a user in a context without session" has now been fixed in version 9.3.8

You are able to find this build in the download section:

http://doc.dynamicweb.com/releases-and-downloads/releases

Please contact Dynamicweb Support if you need any additional help regarding this.

Kind Regards
Dynamicweb Support
Kristian Kirkholt

 

You must be logged in to post in the forum