Reputation: 253
I have a VB.NET solution that I just upgraded. It was originally in .NET 1.1, I upgraded to .NET 2.0 and verified that it would build and run correctly. Then I upgraded from 2.0 to 4.0. It is still building with no errors, but when I try to run I am getting a NullReferenceException
in Global.asax.vb
. The really weird thing is, the line that is throwing the exception is this:
Dim dt As System.Data.DataTable
I am not trying to use the variable, just declare it. Further down a Function
is called that returns a DataTable
and sets the variable, but I don't even get to that line. It is throwing the NullReferenceException
on the Dim
line. Has anyone run across this before? Is this some issue with upgrading?
Edit
Okay, this is the first line in a function. The surrounding code looks like this.
Private Function GetUserRoles() As String
Dim dt As System.Data.DataTable
Dim oDBLookup As New DBLookups
I updated it to this, which should make no difference.
Private Function GetUserRoles() As String
Dim oDBLookup As New DBLookups
Dim dt As System.Data.DataTable
Now, the NullReferenceException is happening on the new first line in the function.
Dim oDBLookup As New DBLookups
The GetUserRoles() Function is the first line in Application_AuthenticateRequest that isn't a Dim or If statement.
Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
' Fires upon attempting to authenticate the user
Dim authCookie As HttpCookie = Context.Request.Cookies("GROUPCOOKIES")
Dim Groups As String
Dim noGroups As Boolean = False
If authCookie Is Nothing Then
Groups = GetUserRoles()
I did a Rebuild Solution before posting. This is a web application and the only files I see in the bin folder are the dll files I am referencing. I'm not sure what else I should clean up.
Upvotes: 0
Views: 357
Reputation: 36573
It sounds like the solution may not have rebuilt properly and is appearing to throw the exception there even though it's actually occurring somewhere else because the source is different than the debug symbols. Try cleaning the solution, manually deleting all your bin and obj directories, then rebuilding and re-running.
Upvotes: 1