I want to pass null as the default instance for my IFarmManager class using StructureMap. In my Global.asax application, I have the following:
ObjectFactory.Initialize(x =>
{
x.ForRequestedType<IFarmManager>().TheDefault.Is.Object(null);
};
However, at runtime, an ArgumentNullException is thrown:
Value cannot be null.
Parameter name: anObject
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentNullException: Value cannot be null.
Parameter name: anObject
Is it possible to use null as the default instance for an interface?
I know this question: StructureMap and passing a null parameter to an instance , but it has no answers.
source
share