c# - An assignment generates a System.NullReferenceException -
iobjectvmfactory objectvmfactory = this.container.resolve<iobjectvmfactory>();
this throws nullreferenceexception.
if not assign result of this.container.resolve
variable, not throw:
this.container.resolve<iobjectvmfactory>().anymethod(...)
this has no sense me ... can give me explanation?
extra information:
this.container
not null sure. triple checked. , if null second line fail.
the class implementing iobjectvmfactory
has no defined constructor exception not happening inside iobjectvmfactory
implementation.
the exception has no inner exceptions , points directly first line.
executing line directly on inmediate window generates ('' null) message.
thanks!
my project's configuration in release, not debug. in release mode, throws exception @ assignment. in debug, throws on step after assignment:
foo member { get; } public bar(foo foo) { // crashes here on release member = foo; // crashes here in debug (foo.collection null) foreach (var thing in foo.collection) thing.dosomething(); }
so looks having project's configuration in release may cause error. try switching configuration debug , find it's failing.
go build -> configuration manager
select project
change configuration release debug.
build , see if error occurs @ same place.
Comments
Post a Comment