I've always had the habit of defining a public constructor for my objects when being consumed by SL or WinRT, but I conditionally provide the private parameterless constructor for .NET projects. I'm consuming an object from an ASP.NET MVC project and I'm running into the "No parameterless constructor defined for this object" error.
If I turn the private constructor (for .NET compilation) into a public one, it solves the problem. Am I missing something on why a public one would be needed by ASP.NET? Thanks.
Hi,
I believe the ASP.NET MVC DefaultModelBinder expects all models to have a public default constructor.
The Csla.Web.Mvc.CslaModelBinder inherits from DefaultModelBinder and helps to suppress rule checking while setting properties and the call CheckRules when completed.
What if I need a parameter in my default public constructor?
Hi,
Then you must also create your own model binder in order to add code that use the non-default constructor. You may look at the CslaModelBinder for a sample of this (see interface IModelCreator).
Please start new thread when you have a new question rather than posting new questions on a thread that is marked as answered.
Copyright (c) Marimer LLC