andrewWinn
andrewWinn

Reputation: 1786

ASP.NET: Object reference not set to an instance of an object

I have a VB.NET site. At the top of many of my pages I have code such as this:

Partial Class _Default
    Inherits System.Web.UI.Page
    Dim fns As New Functions
    Dim bOnOff As Boolean
    Dim LNBs As New LimsNetBusiness.SiteUI.SiteUI
    Dim LNBu As New LimsNetBusiness.User.user
    Dim LNBp As New LimsNetBusiness.PasswordFunctions.Password

When I publish the site. I get "Object reference not set to an instance of an object." on line:

Dim LNBs As New LimsNetBusiness.SiteUI.SiteUI

Why? And how do I fix?

Upvotes: 1

Views: 744

Answers (6)

xpda
xpda

Reputation: 15813

It's possible that the error is occuring in the initialization of LNBs. Since that happens in the dim statement, you probably won't see the location of the error if this is true. You can try moving the initialization of LNBs to an assignment statement:

Dim LNBs As LimsNetBusiness.SiteUI.SiteUI
LNBs = new LimsNetBusiness.SiteUI.SiteUI

Also, check in the initialization of LimsNetBusiness.SiteUI.SiteUI and make sure there is a "new" everywhere that there should be.

Upvotes: 0

Chris
Chris

Reputation: 2055

This is a NullReferenceException Some where along the way a NullReferenceException is occurring.

Now you didn't provide enough information about what LimsNetBusiness is but if I had to guess:

  • Since I can't see you stack trace, you should be aware of the fact that the exception might be contained in the code that is instantiated in the constructor of LimsNetBusiness.SiteUI.SiteUI
  • If LimsNetBusiness.SiteUI is a static Property, you will need to make sure that you instantiate the returned object.

Upvotes: 0

Matt Mitchell
Matt Mitchell

Reputation: 41871

You would need to show us the constructor of LimsNetBusiness.SiteUI.SiteUI I would assume.

Given that this problem only happens remotely, I'm thinking the constructor accesses an asset, connection or config file that isn't available on the server.

My recommendation is to open the DLL with Reflector and see what resources it accesses/other potentials for a null dereference.

Oddly you are saying there is no Sub New(), but I'm curious how you can create a variable of that type without having a constructor.

You mention that SiteUI passes through to your data layer - are you confident the data layer access is working fine remotely?

Upvotes: 1

personaelit
personaelit

Reputation: 1653

Does LimsNetBusiness.SiteUI.SiteUI reference a table, or perhaps web.config file? Maybe a table row was deleted or something similar.

Upvotes: 0

jao
jao

Reputation: 18620

Is LimsNetBusiness a seperate DLL? Did you publish that too?

Upvotes: 1

Jonathan Kaufman
Jonathan Kaufman

Reputation: 314

Not enough info. Unfortunately LimsNetBusiness is not a .net namespace. I would suggest looking into the SiteUI constructor and see if you fail inside there.

Upvotes: 1

Related Questions