c# - Is it possible to get a NullReferenceException with a null coalescing operator and a 'as'? -


i'm moniterring application , got a...

nullreferenceexception object reference not set instance of object.

the stack trace points accurately line of code :

 this.modelcontrol = this.modelcontrol creeretablissementmodel ?? new creeretablissementmodel(); 

is possible this.modelcontrol creeretablissementmodel throw exception before doing ?? ?

edit

by request... you'll need class member (it's inherited in case)

    private const string modelcontrol = "modelcontrol";     public object modelcontrol     {         { return (object)httpcontext.current.session[modelcontrol] ?? new object(); }         set { httpcontext.current.session[modelcontrol] = value; }     } 

no, not possible as in combination null coalescing operator throws nullreferenceexception.

the exception originates within property. either httpcontext.current or httpcontext.current.session null.

you can check setting break point in getter of property.


Comments

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -