Neil: "These are the lines on the master page that seem to cause the problem (it works fine if we comment them out): Me.lblLoginLabel.Text = "Logged in as: " & SageLibrary.SageUser.CurrentUserName Me.lblLoginLabel.Visible = True Me.lblBrowserType.Text = "Using: " & SageLibrary.SageUser.CurrentUserBrowserType Me.lblBrowserType.Visible = True Me.lblScreenDetails.Text = "Screen size: " & SageLibrary.SageUser.CurrentUserScreenWidth & " X " & SageLibrary.SageUser.CurrentUserScreenHeight Me.lblScreenDetails.Visible = True Me.lblPageTitle.Visible = True Me.lblPageTitle.Text = Me.Parent.Page.Title.ToString"
No sh!t buddy. No sh!t. You realize this is one form of the Big Ball of Mud Anti-Pattern, right? Don't concatenate strings all over the place. It's fugly, and as you're discovering, hard to debug. And not performance-friendly. Use a StringBuilder -- not only is it more performant and somewhat less fugly, especially with decent indentation, but it would immediately tell you which line was causing a problem. Use a single variable in each line. You will discover your problem without difficulty. Sloppiness begets hard-to-debug-ness and technical debt and coder-laziness. Which begs more sloppiness. Slay Ouroboros! ∞ Andy Badera ∞ +1 518-641-1280 ∞ This email is: [ ] bloggable [x] ask first [ ] private ∞ Google me: http://www.google.com/search?q=andrew%20badera On Fri, Sep 18, 2009 at 10:59 AM, NeilR <[email protected]> wrote: > > Hi All and I hope someone can help us, > We have a website with two levels of master pages. On the bottom level > master, we use code-behind to set values for some labels such as page > title and user name. This has worked fine for months until we > converted our project into a web application. Now we are getting this > error on the first page after login (ie the first to use the master > page): > > Server Error in '/' Application. > Object reference not set to an instance of an object. > 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.NullReferenceException: Object reference not > set to an instance of an object. > Source Error: > An unhandled exception was generated during the execution of the > current web request. Information regarding the origin and location of > the exception can be identified using the exception stack trace > below. > Stack Trace: > [NullReferenceException: Object reference not set to an instance of an > object.] > SageWeb.MasterPages_ABBlogoOnly.Page_Load(Object sender, EventArgs > eEventArgs) +675 > System.Web.UI.Control.OnLoad(EventArgs e) +131 > System.Web.UI.Control.LoadRecursive() +65 > System.Web.UI.Control.LoadRecursive() +190 > System.Web.UI.Control.LoadRecursive() +190 > System.Web.UI.Page.ProcessRequestMain(Boolean > includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) > +2427 > Version Information: Microsoft .NET Framework Version:2.0.50727.3074; > ASP.NET Version:2.0.50727.3601 > > > These are the lines on the master page that seem to cause the problem > (it works fine if we comment them out): > Me.lblLoginLabel.Text = "Logged in as: " & > SageLibrary.SageUser.CurrentUserName > Me.lblLoginLabel.Visible = True > Me.lblBrowserType.Text = "Using: " & > SageLibrary.SageUser.CurrentUserBrowserType > Me.lblBrowserType.Visible = True > Me.lblScreenDetails.Text = "Screen size: " & > SageLibrary.SageUser.CurrentUserScreenWidth & " X " & > SageLibrary.SageUser.CurrentUserScreenHeight > Me.lblScreenDetails.Visible = True > Me.lblPageTitle.Visible = True > Me.lblPageTitle.Text = Me.Parent.Page.Title.ToString > > In debug we have proved that all of the values called here are > available. Any idea what could be causing the problem and why the > conversion from project to web application triggered it? > > Many thanks if you can help > NeilR >
