Can't login with new users on azure


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:

[NullReferenceException: Object reference not set to an instance of an object.]
at Mediachase.BusinessFoundation.Data.BaseFieldValidator.GetValue()
at Mediachase.BusinessFoundation.Data.StringFieldValidator.EvaluateIsValid()
at Mediachase.BusinessFoundation.Data.BaseFieldValidator.Validate()
at Mediachase.BusinessFoundation.Data.Meta.MetaObject.Validate()
at Mediachase.BusinessFoundation.Data.Meta.MetaObject.OnSaving()
at Mediachase.BusinessFoundation.Data.Meta.MetaObject.Save(Boolean forceSave)
at Mediachase.BusinessFoundation.Data.Meta.MetaObject.Save()
at Mediachase.BusinessFoundation.Data.Business.EntityObjectDefaultRequestHandler.Create(BusinessContext context)
at Mediachase.BusinessFoundation.Data.Business.EntityObjectDefaultRequestHandler.Execute(BusinessContext context)
at Mediachase.BusinessFoundation.Data.Business.BaseRequestHandler.Mediachase.BusinessFoundation.Data.Business.IRequestHandler.Execute(BusinessContext context)
at Mediachase.BusinessFoundation.Data.Business.BusinessManager.ExecutePipeline(Request request, IRequestHandler handler)
at Mediachase.BusinessFoundation.Data.Business.BusinessManager.ExecutePipelineInTransaction(Request request, IRequestHandler handler)
at Mediachase.BusinessFoundation.Data.Business.BusinessManager.Execute(Request request)
at Mediachase.BusinessFoundation.Data.Business.BusinessManager.Create(EntityObject target)
at Mediachase.Commerce.Customers.CustomerContact.SaveChanges()
at Mediachase.Commerce.Security.PrincipalExtensions.GetCustomerContact(IPrincipal principal)
at Mediachase.Commerce.Security.PrincipalExtensions.GetContactId(IPrincipal principal)
at Mediachase.Commerce.Core.Modules.BusinessFoundationInitializeModule.context_AuthorizeRequest(Object sender, EventArgs e)
at System.Web.HttpApplication.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

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:

[NullReferenceException: Object reference not set to an instance of an object.]
   Mediachase.BusinessFoundation.Data.BaseFieldValidator.GetValue() +273
   Mediachase.BusinessFoundation.Data.StringFieldValidator.EvaluateIsValid() +73
   Mediachase.BusinessFoundation.Data.BaseFieldValidator.Validate() +66
   Mediachase.BusinessFoundation.Data.Meta.MetaObject.Validate() +166
   Mediachase.BusinessFoundation.Data.Meta.MetaObject.OnSaving() +118
   Mediachase.BusinessFoundation.Data.Meta.MetaObject.Save(Boolean forceSave) +76
   Mediachase.BusinessFoundation.Data.Meta.MetaObject.Save() +54
   Mediachase.BusinessFoundation.Data.Business.EntityObjectDefaultRequestHandler.Create(BusinessContext context) +976
   Mediachase.BusinessFoundation.Data.Business.EntityObjectDefaultRequestHandler.Execute(BusinessContext context) +720
   Mediachase.BusinessFoundation.Data.Business.BaseRequestHandler.Mediachase.BusinessFoundation.Data.Business.IRequestHandler.Execute(BusinessContext context) +60
   Mediachase.BusinessFoundation.Data.Business.BusinessManager.ExecutePipeline(Request request, IRequestHandler handler) +151
   Mediachase.BusinessFoundation.Data.Business.BusinessManager.ExecutePipelineInTransaction(Request request, IRequestHandler handler) +117
   Mediachase.BusinessFoundation.Data.Business.BusinessManager.Execute(Request request) +768
   Mediachase.BusinessFoundation.Data.Business.BusinessManager.Create(EntityObject target) +106
   Mediachase.Commerce.Manager.Apps.MetaUIEntity.Tabs.EntityEditTab.SaveChanges(IDictionary context) +940
   Mediachase.Commerce.Manager.Core.Controls.EditViewControl.SaveChanges(IDictionary context) +290
   Mediachase.Commerce.Manager.Core.SaveControl.OnSaveChanges(Object sender, EventArgs e) +60
   System.Web.UI.WebControls.Button.OnClick(EventArgs e) +11762636
   System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +149
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6015
Edited, Aug 12, 2016 8:18

I have the same problem, did you figure this out Tobias?



Sep 11, 2016 22:26

@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.

Sep 12, 2016 8:28

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.

Edited, Sep 30, 2016 11:27

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);
Sep 30, 2016 18:10
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.