Controller ModelState with ModelStateWrappper-Collection of common programming errors
You need to provide more information, but this is my best guess as to what you have:
public class ModelStateWrapper : IValidationDictionary
{
...
private readonly ModelState _modelState;
public ModelStateWrapper(ModelState modelState)
{
_modelState = modelState;
}
...
}
If you want to pass a variable (the controller’s model state in this case) to the ModelStateWrapper you almost certainly need to do that explicitly by calling the ObjectFactory.
Example:
MyController : Controller
{
...
public MyAction()
{
...
IValidationDictionary validationDictionary = ObjectFactory
.With(this.ModelState)
.GetInstance();
...
}
...
}
See this documentation for details:
Passing Arguments to StructureMap at Runtime