Skip to content

Installing Ninject.Web affects existing FindControl calls #12

@jbdutton

Description

@jbdutton

I installed Ninject.Web recently so that I could begin injecting dependencies into my VB.NET Web Forms pages. This works without any problems, but I noticed that other pages (whose own code has not been changed in any way) break after the NuGet package is installed. Uninstall it and the errors go away.

Specifically, a lot of the code uses FindControl in or near Page_Load and returns null once Ninject.Web has been installed, causing null reference exceptions (I don't know if this is bad practice to use FindControl in Page_Load but the application is large and inherited and I'd rather keep it stable than introduce a bunch of unknowns at this time).

I used Debug.WriteLine with and without Ninject.Web on some of my code. In it, I use a method that recursively prints all of the child controls of a parent control. [I should mention that the parent control in this particular case is a FormView.]

Without Ninject.Web:

Page_Load Begins
Name of Parent Control
Parent Control Data Binding Begins and Ends
Names of Child Controls
Page_Load

With Ninject.Web:

Page_Load Begins
Name of Parent Control
[No child controls printed; this is where null reference would occur if using FindControl]
Page_Load Ends
Parent Control Data Binding Begins and Ends

As you can see, once Ninject.Web as been installed, the databinding occurs after Page_Load, so the method that prints all of the control names stops at the parent control.

I am not familiar enough with Web Forms to know why this might occur, and I don't see anything in the Ninject.Web source that would cause this. Any insight would be greatly appreciated.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions