By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
460,028 Members | 815 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 460,028 IT Pros & Developers. It's quick & easy.

runs in debug but not in production

P: n/a
I have a simple asp.net app which works fine in debug mode, but crashes on
the following line when I run it on the production server:

Dim dt As DataTable

I have tried the following variations which produce the same result:
Dim dt As System.Data.DataTable
Dim dt As DataTable = New DataTable

The error message reads: System.NullReferenceException: Object reference
not set to an instance of an object.

This is the only place in code that dt is declared. Funny that this will
work in debug and error out in production. Does anyone have any ideas? I
am out. :)

Scott

Nov 18 '05 #1
Share this Question
Share on Google+
10 Replies


P: n/a
I would think there is something else going on, like the production server
has some files out of date. So the line number that is shown when it
crashes isn't actually the code being executed.

"Scott" <sc***********@nospam.ma-hc.com> wrote in message
news:e2**************@tk2msftngp13.phx.gbl...
I have a simple asp.net app which works fine in debug mode, but crashes on
the following line when I run it on the production server:

Dim dt As DataTable

I have tried the following variations which produce the same result:
Dim dt As System.Data.DataTable
Dim dt As DataTable = New DataTable

The error message reads: System.NullReferenceException: Object reference
not set to an instance of an object.

This is the only place in code that dt is declared. Funny that this will
work in debug and error out in production. Does anyone have any ideas? I
am out. :)

Scott

Nov 18 '05 #2

P: n/a
Hi Scott,

Thanks you for using Microsoft Newsgroup Service. Based on your
description, one of your web page will running into "Null reference"
exception on production server, however runs ok on debug environment? Also,
you thought the problem is due to a "DataTable" variable. Is my
understanding of your problem correct?

If so, I think you may first try confirming the actual object which caused
the exception. Since you run to the exception on Production server, you may
add some code such as"

If dt is Nothing Then
.....

Or other to confirm whether the DataTable variable is the root caused of
the problem. In addition, I think Marina's suggestion is also considerable,
maybe you can reboot the web application or the web server? Or try creating
another page which does the has the same functions and operations in it and
run it on both debug and production server to see whether the problem
remain.
Please try out the preceding suggestions and let me know if you need any
help.
Regards,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)

Nov 18 '05 #3

P: n/a
Alright I did the following:
1) Went to Microsoft's web site and did an update on anything it wanted to
update (the server is a Windows 2000 Pro OS)
2) Downloaded the latest .NET framework version (1.1 Redistributable
Package) and ran it on the server.
3) I opened the solution in VS and ran a build on it, saved the files and
then copied the whole directory from my inetpub/wwwroot directory to the
production directory on the server (after deleting all the files on the
server related to the project).

I even checked the references on the project to make sure I knew where they
were pointing to. I suspect this may be the problem. I have 2 references
in the project. I have them built as DLLs on my hard drive. I created a
reference to their DLLs from the main project and I see that VS dropped them
into the bin directory for the main project. The 2 sub-projects that allow
me to code the DLLs are also included in my solution for my application. Is
there somewhere else I should point them to?

Maybe it has nothing to do with that. Since my changes I am getting the
same error on the following line of code which follows the one I described
previously:

dt = ds.tables(0)

The error message (assuming it is showing me the right line of code) seems
to indicate it can't get a reference for an object, but the ds and dt
variables are declared properly.

Please!!!! Any thoughts on this would be appreciated! This isn't supposed
to happen in .NET!!!!

Scott

"Marina" <so*****@nospam.com> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
I would think there is something else going on, like the production server
has some files out of date. So the line number that is shown when it
crashes isn't actually the code being executed.

"Scott" <sc***********@nospam.ma-hc.com> wrote in message
news:e2**************@tk2msftngp13.phx.gbl...
I have a simple asp.net app which works fine in debug mode, but crashes on the following line when I run it on the production server:

Dim dt As DataTable

I have tried the following variations which produce the same result:
Dim dt As System.Data.DataTable
Dim dt As DataTable = New DataTable

The error message reads: System.NullReferenceException: Object reference not set to an instance of an object.

This is the only place in code that dt is declared. Funny that this will work in debug and error out in production. Does anyone have any ideas? I am out. :)

Scott


Nov 18 '05 #4

P: n/a
1) Did you rebuild the 2 referenced projects after downloading the .NET 1.1
framework?

2) Are you sure the dataset is properly instantiated and that it contains at
least one datatable?

HTH

"Scott" <sc***********@nospam.ma-hc.com> wrote in message
news:Oz**************@tk2msftngp13.phx.gbl...
Alright I did the following:
1) Went to Microsoft's web site and did an update on anything it wanted to update (the server is a Windows 2000 Pro OS)
2) Downloaded the latest .NET framework version (1.1 Redistributable
Package) and ran it on the server.
3) I opened the solution in VS and ran a build on it, saved the files and
then copied the whole directory from my inetpub/wwwroot directory to the
production directory on the server (after deleting all the files on the
server related to the project).

I even checked the references on the project to make sure I knew where they were pointing to. I suspect this may be the problem. I have 2 references
in the project. I have them built as DLLs on my hard drive. I created a
reference to their DLLs from the main project and I see that VS dropped them into the bin directory for the main project. The 2 sub-projects that allow me to code the DLLs are also included in my solution for my application. Is there somewhere else I should point them to?

Maybe it has nothing to do with that. Since my changes I am getting the
same error on the following line of code which follows the one I described
previously:

dt = ds.tables(0)

The error message (assuming it is showing me the right line of code) seems
to indicate it can't get a reference for an object, but the ds and dt
variables are declared properly.

Please!!!! Any thoughts on this would be appreciated! This isn't supposed to happen in .NET!!!!

Scott

"Marina" <so*****@nospam.com> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
I would think there is something else going on, like the production server
has some files out of date. So the line number that is shown when it
crashes isn't actually the code being executed.

"Scott" <sc***********@nospam.ma-hc.com> wrote in message
news:e2**************@tk2msftngp13.phx.gbl...
I have a simple asp.net app which works fine in debug mode, but
crashes on the following line when I run it on the production server:

Dim dt As DataTable

I have tried the following variations which produce the same result:
Dim dt As System.Data.DataTable
Dim dt As DataTable = New DataTable

The error message reads: System.NullReferenceException: Object reference not set to an instance of an object.

This is the only place in code that dt is declared. Funny that this will work in debug and error out in production. Does anyone have any
ideas?
I am out. :)

Scott



Nov 18 '05 #5

P: n/a
1) Did you rebuild the 2 referenced projects after downloading the .NET 1.1
framework?

2) Are you sure the dataset is properly instantiated and that it contains at
least one datatable?

HTH

"Scott" <sc***********@nospam.ma-hc.com> wrote in message
news:Oz**************@tk2msftngp13.phx.gbl...
Alright I did the following:
1) Went to Microsoft's web site and did an update on anything it wanted to update (the server is a Windows 2000 Pro OS)
2) Downloaded the latest .NET framework version (1.1 Redistributable
Package) and ran it on the server.
3) I opened the solution in VS and ran a build on it, saved the files and
then copied the whole directory from my inetpub/wwwroot directory to the
production directory on the server (after deleting all the files on the
server related to the project).

I even checked the references on the project to make sure I knew where they were pointing to. I suspect this may be the problem. I have 2 references
in the project. I have them built as DLLs on my hard drive. I created a
reference to their DLLs from the main project and I see that VS dropped them into the bin directory for the main project. The 2 sub-projects that allow me to code the DLLs are also included in my solution for my application. Is there somewhere else I should point them to?

Maybe it has nothing to do with that. Since my changes I am getting the
same error on the following line of code which follows the one I described
previously:

dt = ds.tables(0)

The error message (assuming it is showing me the right line of code) seems
to indicate it can't get a reference for an object, but the ds and dt
variables are declared properly.

Please!!!! Any thoughts on this would be appreciated! This isn't supposed to happen in .NET!!!!

Scott

"Marina" <so*****@nospam.com> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
I would think there is something else going on, like the production server
has some files out of date. So the line number that is shown when it
crashes isn't actually the code being executed.

"Scott" <sc***********@nospam.ma-hc.com> wrote in message
news:e2**************@tk2msftngp13.phx.gbl...
I have a simple asp.net app which works fine in debug mode, but
crashes on the following line when I run it on the production server:

Dim dt As DataTable

I have tried the following variations which produce the same result:
Dim dt As System.Data.DataTable
Dim dt As DataTable = New DataTable

The error message reads: System.NullReferenceException: Object reference not set to an instance of an object.

This is the only place in code that dt is declared. Funny that this will work in debug and error out in production. Does anyone have any
ideas?
I am out. :)

Scott



Nov 18 '05 #6

P: n/a
I went and clicked on "Build" on the pop-up menus for each sub project and
then the main project. Earlier, I was clicking on Debug/build in VS which I
assumed did the whole solution. Is there something else I need to do?

I will list my code here that instantiates the relevant variables, but I
should point out that this code works fine in debug mode in VS and also if I
run it on the development server when I access the site with:
http://localhost/project. If I use the server name or IP address (ie.
http://server1/project) It errors out. In fact, the only way I can get the
error message itself and not the generic version of the error, is to go to
the server and try to run the code with the server name or IP address. I
hope that gives you good clues.

The line of code it stops on is part of the following set:

================================================== ===============
Public Class DecPat1
...
Public ds As DataSet
...
Public Sub HandleCommands(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
...
ds = CType(Session("MyData"), DataSet)
Dim dt As System.Data.DataTable
dt = ds.Tables(0)
...
End Sub
...
End Class
================================================== ===============

I have tried variations of the "Dim dt As ..." line. As far as whether or
not I am using the correct table inside of the Tables collection, I only
know that it works in debug mode, so I think that tells me I am referencing
it properly.

I hope this helps. Please let me know what additional information you could
use or what you think.

Scott

PS. I ran the framework redistributable on my workstation and on the server
just now... just to be on the safe side and try to rule that out. :)
"John Miner" <mi****@celeris.ca> wrote in message
news:uS**************@TK2MSFTNGP12.phx.gbl...
1) Did you rebuild the 2 referenced projects after downloading the .NET 1.1 framework?

2) Are you sure the dataset is properly instantiated and that it contains at least one datatable?

HTH

"Scott" <sc***********@nospam.ma-hc.com> wrote in message
news:Oz**************@tk2msftngp13.phx.gbl...
Alright I did the following:
1) Went to Microsoft's web site and did an update on anything it wanted

to
update (the server is a Windows 2000 Pro OS)
2) Downloaded the latest .NET framework version (1.1 Redistributable
Package) and ran it on the server.
3) I opened the solution in VS and ran a build on it, saved the files and
then copied the whole directory from my inetpub/wwwroot directory to the
production directory on the server (after deleting all the files on the
server related to the project).

I even checked the references on the project to make sure I knew where

they
were pointing to. I suspect this may be the problem. I have 2 references in the project. I have them built as DLLs on my hard drive. I created a reference to their DLLs from the main project and I see that VS dropped

them
into the bin directory for the main project. The 2 sub-projects that

allow
me to code the DLLs are also included in my solution for my application.

Is
there somewhere else I should point them to?

Maybe it has nothing to do with that. Since my changes I am getting the
same error on the following line of code which follows the one I described previously:

dt = ds.tables(0)

The error message (assuming it is showing me the right line of code) seems to indicate it can't get a reference for an object, but the ds and dt
variables are declared properly.

Please!!!! Any thoughts on this would be appreciated! This isn't

supposed
to happen in .NET!!!!

Scott

"Marina" <so*****@nospam.com> wrote in message
news:OR**************@TK2MSFTNGP10.phx.gbl...
I would think there is something else going on, like the production

server has some files out of date. So the line number that is shown when it
crashes isn't actually the code being executed.

"Scott" <sc***********@nospam.ma-hc.com> wrote in message
news:e2**************@tk2msftngp13.phx.gbl...
> I have a simple asp.net app which works fine in debug mode, but

crashes
on
> the following line when I run it on the production server:
>
> Dim dt As DataTable
>
> I have tried the following variations which produce the same result:
> Dim dt As System.Data.DataTable
> Dim dt As DataTable = New DataTable
>
> The error message reads: System.NullReferenceException: Object

reference
> not set to an instance of an object.
>
> This is the only place in code that dt is declared. Funny that this

will
> work in debug and error out in production. Does anyone have any

ideas?
I
> am out. :)
>
> Scott
>
>
>



Nov 18 '05 #7

P: n/a
Scott wrote:
I went and clicked on "Build" on the pop-up menus for each sub project and
then the main project. Earlier, I was clicking on Debug/build in VS which I
assumed did the whole solution. Is there something else I need to do?

I will list my code here that instantiates the relevant variables, but I
should point out that this code works fine in debug mode in VS and also if I
run it on the development server when I access the site with:
http://localhost/project. If I use the server name or IP address (ie.
http://server1/project) It errors out. In fact, the only way I can get the
error message itself and not the generic version of the error, is to go to
the server and try to run the code with the server name or IP address. I
hope that gives you good clues.

The line of code it stops on is part of the following set:

================================================== ===============
Public Class DecPat1
...
Public ds As DataSet
...
Public Sub HandleCommands(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
...
ds = CType(Session("MyData"), DataSet)
Dim dt As System.Data.DataTable
dt = ds.Tables(0)
...
End Sub
...
End Class
================================================== ===============

I have tried variations of the "Dim dt As ..." line. As far as whether or
not I am using the correct table inside of the Tables collection, I only
know that it works in debug mode, so I think that tells me I am referencing
it properly.

I hope this helps. Please let me know what additional information you could
use or what you think.

Scott

PS. I ran the framework redistributable on my workstation and on the server
just now... just to be on the safe side and try to rule that out. :)


Your problem will have nothing to do with the declarations of the
variables - you need to check at runtime to see that your DataSet or
DataTable references are non-null.

Your code snippet shows that you're getting the dataset from the Session
collection, but it doesn't show how the dataset is created in the first
place.

In any case, add the following lines of code right after you get the
dataset reference from the Sessoin collection - it should help you get
closer to the cause of the problem:

If ds Is Nothing Then
Trace.Warn("DataSet is Null")
Return
End If

If ds.Tables Is Nothing Then
Trace.Warn("ds.Tables is Null")
Return
End If

And add a trace="true" attribute to the aspx page's @Page directive.

Now when you navigate to that page, you'll get trace output added to the
bottom, and there will be a line written in red indicating which
reference is null.

You'll have to debug some other part of your application to find out why.
--
mikeb
Nov 18 '05 #8

P: n/a
Just a thought, but have you confirmed that RIGHTS are set correctly to
the queries used to populate the session variable you use as your
datasource?

For example, in SQL Server 2000 (or whatever you use) you may need to
set permissions on these queries depending on your setup. Sometimes the
username/passwords are different from dev server to production server.

I'll admit to once spending quite a bit of debug time only to have that
be the cause (blush)...now it's the first thing I check if I know my
query returns the dataset in SQL Analyzer, etc.,but I get Nothing for
the dataset.

Good luck.

Kat

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #9

P: n/a
Scott wrote:
Mike,
I added the code you mentioned and was able to make it run on my
workstation... I added an "Else... trace.warn("DataSet is NOT null")" to
each of the sections so I could confirm that it got to that line of code. I
also added a "Return" right after the test code so it doesn't try to run the
rest of the procedure. On my workstation this all runs fine whether I run
in debug mode or access the code through IE with
//localhost/directory/pagename and I get the red lines in the stack trace on
the aspx page with the "NOT null" messages.

I copy the code to the server and get different results. If I try to run it
in IE with "//<servername>/<directory>/ I get "Object Reference Not set to
an instance of an object". If I use "//localhost/<directory>/ it runs fine
but I don't see the trace messages in red... I get the trace info, just not
our messages.
I think that means that the updated .aspx file is being copied to the
server, but the updated code-behind dll is not. The .aspx file has the
@Page directive which enables the trace (which you're seeing). But, the
code-behind DLL has the calls to Trace.Warn(). Sine the Trace.Warn()
messages are not being seen, it seems that the dll is not being copied over.

Of course, I'm assuming that you're using a code-behind model.

I can't think of why you'd get different behavior using //<servername>
and //localhost, unless there is DNS, WINS or host file issues.

Does a simple "hello word" .aspx page work in that virtual directory?

I started wondering if the problem is with the way that I am releaseing the
application to the server or the server itself. I have another machine here
available to me with Windows 2000 Server loaded and normally used as a
SQL2000 server but has IIS on it, so I loaded dotnetfx.exe on it, did not
reboot, dropped the files from my workstation's inetpub/wwwroot/project1
directory into inetpub/wwwroot/project1 on the server and tried to run the
program throuh IE on that server with
//localhost/testzone/project1/decpat.aspx. I got an error screen saying
"Server Error in '/' Application". It is referencing the "authentication
mode="windows"" line in web.config and suggesting I should create a virtual
directory. So, I set one up with Read, Run, Execute and Write permissions
and everything works great (although I don't see the red statements in the
trace).

So, I go back to the first server and remove the virtual directory I was
using and add it back again, this time making sure to check the Read, Run,
Execute and Write boxes. When I try to run the code I get an error saying
that "Object Not Set to and Instance Of An Object". So, I have the same
code on both servers, but one server will not run it. Question is: Why?
Could it be that I did not release it to the first server properly? Is
there a better way to release a project? Any other reasons for this that
you can think of would also be appreciated.

Thank you for your time in helping me to understand this issue.

Scott

BTW: I don't think permissions are an issue because I am running 2 other
applications on the first server that do similar tasks with the same SQL
server database and not having any problems.


"mikeb" <ma************@mailnull.com> wrote in message
news:#k**************@TK2MSFTNGP11.phx.gbl...
Scott wrote:
I went and clicked on "Build" on the pop-up menus for each sub project
and
then the main project. Earlier, I was clicking on Debug/build in VS
which I
assumed did the whole solution. Is there something else I need to do?

I will list my code here that instantiates the relevant variables, but I
should point out that this code works fine in debug mode in VS and also
if I
run it on the development server when I access the site with:
http://localhost/project. If I use the server name or IP address (ie.
http://server1/project) It errors out. In fact, the only way I can get
the
error message itself and not the generic version of the error, is to go
to
the server and try to run the code with the server name or IP address.
I
hope that gives you good clues.

The line of code it stops on is part of the following set:

=============================================== ==================
Public Class DecPat1
...
Public ds As DataSet
...
Public Sub HandleCommands(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
...
ds = CType(Session("MyData"), DataSet)
Dim dt As System.Data.DataTable
dt = ds.Tables(0)
...
End Sub
...
End Class
=============================================== ==================

I have tried variations of the "Dim dt As ..." line. As far as whether
or
not I am using the correct table inside of the Tables collection, I only
know that it works in debug mode, so I think that tells me I am
referencing
it properly.

I hope this helps. Please let me know what additional information you
could
use or what you think.

Scott

PS. I ran the framework redistributable on my workstation and on the
server
just now... just to be on the safe side and try to rule that out. :)


Your problem will have nothing to do with the declarations of the
variables - you need to check at runtime to see that your DataSet or
DataTable references are non-null.

Your code snippet shows that you're getting the dataset from the Session
collection, but it doesn't show how the dataset is created in the first
place.

In any case, add the following lines of code right after you get the
dataset reference from the Sessoin collection - it should help you get
closer to the cause of the problem:

If ds Is Nothing Then
Trace.Warn("DataSet is Null")
Return
End If

If ds.Tables Is Nothing Then
Trace.Warn("ds.Tables is Null")
Return
End If

And add a trace="true" attribute to the aspx page's @Page directive.

Now when you navigate to that page, you'll get trace output added to the
bottom, and there will be a line written in red indicating which
reference is null.

You'll have to debug some other part of your application to find out why.
--
mikeb


--
mikeb
Nov 18 '05 #10

P: n/a
Mike,
Thanks for your reply. Seeing as how this is working on the second server I
need to move forward with it from there (I have a deadline to meet and this
has put me behind). So, I may not get to play with this for a while but
wanted to respond to your comments.

Yes, I am using a code-behind model and I agree with you that it appears the
aspx is looking for DLLs that it can't find. I even opened the aspx and the
aspx.vb files in notepad and looked for mis-directed links to the wrong
locations, but couldn't find anything wrong. This is certainly perplexing
and it is unfortunate that I need to move forward and leave this issue
behind.

I will schedule our techs to wipe-out the OS on the first server and
reinstall W2000 Server w/.NET or W2003. Maybe there is something 'twisted'
in the OS that is causing a problem... this IS our development server so it
ends up being a playground for new ideas... something on the server may be
causeing this.

Thanks again for your help. :)

Scott

"mikeb" <ma************@mailnull.com> wrote in message
news:ud**************@tk2msftngp13.phx.gbl...
Scott wrote:
Mike,
I added the code you mentioned and was able to make it run on my
workstation... I added an "Else... trace.warn("DataSet is NOT null")" to
each of the sections so I could confirm that it got to that line of code. I also added a "Return" right after the test code so it doesn't try to run the rest of the procedure. On my workstation this all runs fine whether I run in debug mode or access the code through IE with
//localhost/directory/pagename and I get the red lines in the stack trace on the aspx page with the "NOT null" messages.

I copy the code to the server and get different results. If I try to run it in IE with "//<servername>/<directory>/ I get "Object Reference Not set to an instance of an object". If I use "//localhost/<directory>/ it runs fine but I don't see the trace messages in red... I get the trace info, just not our messages.
I think that means that the updated .aspx file is being copied to the
server, but the updated code-behind dll is not. The .aspx file has the
@Page directive which enables the trace (which you're seeing). But, the
code-behind DLL has the calls to Trace.Warn(). Sine the Trace.Warn()
messages are not being seen, it seems that the dll is not being copied

over.
Of course, I'm assuming that you're using a code-behind model.

I can't think of why you'd get different behavior using //<servername>
and //localhost, unless there is DNS, WINS or host file issues.

Does a simple "hello word" .aspx page work in that virtual directory?

I started wondering if the problem is with the way that I am releaseing the application to the server or the server itself. I have another machine here available to me with Windows 2000 Server loaded and normally used as a
SQL2000 server but has IIS on it, so I loaded dotnetfx.exe on it, did not reboot, dropped the files from my workstation's inetpub/wwwroot/project1
directory into inetpub/wwwroot/project1 on the server and tried to run the program throuh IE on that server with
//localhost/testzone/project1/decpat.aspx. I got an error screen saying
"Server Error in '/' Application". It is referencing the "authentication mode="windows"" line in web.config and suggesting I should create a virtual directory. So, I set one up with Read, Run, Execute and Write permissions and everything works great (although I don't see the red statements in the trace).

So, I go back to the first server and remove the virtual directory I was
using and add it back again, this time making sure to check the Read, Run, Execute and Write boxes. When I try to run the code I get an error saying that "Object Not Set to and Instance Of An Object". So, I have the same
code on both servers, but one server will not run it. Question is: Why? Could it be that I did not release it to the first server properly? Is
there a better way to release a project? Any other reasons for this that you can think of would also be appreciated.

Thank you for your time in helping me to understand this issue.

Scott

BTW: I don't think permissions are an issue because I am running 2 other applications on the first server that do similar tasks with the same SQL
server database and not having any problems.


"mikeb" <ma************@mailnull.com> wrote in message
news:#k**************@TK2MSFTNGP11.phx.gbl...
Scott wrote:

I went and clicked on "Build" on the pop-up menus for each sub project


and
then the main project. Earlier, I was clicking on Debug/build in VS


which I
assumed did the whole solution. Is there something else I need to do?

I will list my code here that instantiates the relevant variables, but Ishould point out that this code works fine in debug mode in VS and also


if I
run it on the development server when I access the site with:
http://localhost/project. If I use the server name or IP address (ie.
http://server1/project) It errors out. In fact, the only way I can get


the
error message itself and not the generic version of the error, is to go


to
the server and try to run the code with the server name or IP address.


I
hope that gives you good clues.

The line of code it stops on is part of the following set:

=============================================== ==================
Public Class DecPat1
...
Public ds As DataSet
...
Public Sub HandleCommands(ByVal sender As Object, ByVal e As
DataGridCommandEventArgs)
...
ds = CType(Session("MyData"), DataSet)
Dim dt As System.Data.DataTable
dt = ds.Tables(0)
...
End Sub
...
End Class
=============================================== ==================

I have tried variations of the "Dim dt As ..." line. As far as whether


or
not I am using the correct table inside of the Tables collection, I onlyknow that it works in debug mode, so I think that tells me I am


referencing
it properly.

I hope this helps. Please let me know what additional information you


could
use or what you think.

Scott

PS. I ran the framework redistributable on my workstation and on the


server
just now... just to be on the safe side and try to rule that out. :)

Your problem will have nothing to do with the declarations of the
variables - you need to check at runtime to see that your DataSet or
DataTable references are non-null.

Your code snippet shows that you're getting the dataset from the Session
collection, but it doesn't show how the dataset is created in the first
place.

In any case, add the following lines of code right after you get the
dataset reference from the Sessoin collection - it should help you get
closer to the cause of the problem:

If ds Is Nothing Then
Trace.Warn("DataSet is Null")
Return
End If

If ds.Tables Is Nothing Then
Trace.Warn("ds.Tables is Null")
Return
End If

And add a trace="true" attribute to the aspx page's @Page directive.

Now when you navigate to that page, you'll get trace output added to the
bottom, and there will be a line written in red indicating which
reference is null.

You'll have to debug some other part of your application to find out why.

--
mikeb


--
mikeb

Nov 18 '05 #11

This discussion thread is closed

Replies have been disabled for this discussion.