@Fredrik I managed to find the reason, but not solve it. I had to set up a new database to get around it.
The reason was that I'd added custom fields to the customer meta class. I think that when you create a custom field, a validator to that field i also created. When I, later on, removed some of those custom fields, a validator somehow remained. When the system tried to validate a customer meta class during create, this validator was connected to a field that didn't exist and an exception was thrown.
If you have created custom fields to the customer meta class, load up the customer meta class, debug and inspect the class, compare the number of meta fileds with the number of validators. Theses should match, but didn't in my case.
I didn't bother wiping my database, maybe you are in another situation. If so, maybe you can figure out how the validators are loaded and find out why the faulty validator remains.
Validators are serialized as XML in the meta class so you need to update this field in the database and remove the offending validator.
Check the field XSValidators in table mcmd_MetaClass.
Unfortunately the exception is not handled by EPI so there is no clue as to what validator is causing the problem. At best you know which meta class it is. We ended up reflecting/debugging the code to identify the validator.
In my case I deleted the email column from the cls_Contact table in the Commerce DB manually and then ran the following script once:
MetaClassManager manager = DataContext.Current.MetaModel; MetaClass mc = manager.MetaClasses[ContactEntity.ClassName]; using (MetaFieldBuilder builder = new MetaFieldBuilder(mc)) { builder.CreateEmail("Email", "{Customer:Contact_mf_Email}", false, 254, false); builder.SaveChanges(); }
I'm running 9.20.0
I can't login with users created in the cms admin. It's been working before and somwhere along the way, this problem arised. It works on my local dev against my local database, but not against the database on azure. I've also tried to run my local application against the database on azure with the same result.
The user is created and appears in the cms, but when I try to login with the user I get a NullReferenceException with following StackTrace:
Update: It seems to always happen when a CustomerContact is created. When I try to create a new Contact inside Commerce Manager I get exception at the same place with the following StackTrace: