StructureMap crashing when editing client side code RRS feed

  • Question

  • Hello,

    I've got an MVC application using StructureMap. StructureMap keeps throwing an exception when the application is running and I make a change to a CSS, CSHTML, or JS file.

    The line that throws the exception is this:

            private HttpContextBase HttpContext {

                get {

                    var ctx = Container.TryGetInstance<HttpContextBase>(); // <-- THIS LINE HERE
                    return ctx ?? new HttpContextWrapper(System.Web.HttpContext.Current);



    It says:

    An exception of type 'StructureMap.Building.StructureMapBuildException' occurred in StructureMap.dll but was not handled in user code

    The exception message is:
    "Failure while building 'Lambda: new HttpContextWrapper(HttpContext.Current)', check the inner exception for details\r\n1.) Lambda: new HttpContextWrapper(HttpContext.Current)\r\n2.) Instance of System.Web.HttpContextBase (System.Web.HttpContextWrapper)\r\n3.) Container.GetInstance(System.Web.HttpContextBase)\r\n4.) Container.TryGetInstance<System.Web.HttpContextBase>()\r\n"

    The inner exception is:

    "Value cannot be null.\r\nParameter name: httpContext"

    My application didn't used to do this. I used to be able to make modifications to client side code to my hearts content and it would not only not crash but update immediately (I wouldn't even have to save).

    Can someone please tell me what's wrong?
    Thursday, January 4, 2018 9:02 PM

All replies