473,490 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

When would null pointer exception occurs ?

for (int i=0; i<_request.Form.Count; i++ )
{
string key = _request.Form.GetKey(i);
if ( !key.Equals("formCode")
&& !key.Equals("formLanguage")
&& !key.Equals("__VIEWSTATE")
&& !key.Equals("__EVENTARGUMENT")
&& !key.Equals("__EVENTTARGET")
&& key.IndexOf("sendButton")<0
&& key.IndexOf("clearButton")<0
&& key.IndexOf("HeaderControl")<0
&& key.IndexOf("PostingListControl")<0 )
{
formVO.addFormData(key,
StringUtil.extractStringFromStringArray(_request.F orm.GetValues(key)));
}
}

here is a part of my code. After several postback due to invalid validation,
null pointer exception is caught. What I wonder is request.Form.Count means
number of name-value pairs in Form collection. Then variable i would be
within the range of count. The null pointer exception seem to point to the
variable key. Is that possible a name-value pair can contain a null as key ?
Thx
Nov 19 '05 #1
5 2831
Look at the trace.axd to get more information and you will probably see
what's going wrong.

It is also possible that one of the key don't have an associated value.
This happens frequently with the QueryString information. You should store
the value of request.Form.GetValues(key) as an object and make that it's not
null before using it.

S. L.

"Tony Cheng" <sd***@fdfsds.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
for (int i=0; i<_request.Form.Count; i++ )
{
string key = _request.Form.GetKey(i);
if ( !key.Equals("formCode")
&& !key.Equals("formLanguage")
&& !key.Equals("__VIEWSTATE")
&& !key.Equals("__EVENTARGUMENT")
&& !key.Equals("__EVENTTARGET")
&& key.IndexOf("sendButton")<0
&& key.IndexOf("clearButton")<0
&& key.IndexOf("HeaderControl")<0
&& key.IndexOf("PostingListControl")<0 )
{
formVO.addFormData(key,
StringUtil.extractStringFromStringArray(_request.F orm.GetValues(key)));
}
}

here is a part of my code. After several postback due to invalid
validation, null pointer exception is caught. What I wonder is
request.Form.Count means number of name-value pairs in Form collection.
Then variable i would be within the range of count. The null pointer
exception seem to point to the variable key. Is that possible a name-value
pair can contain a null as key ? Thx

Nov 19 '05 #2
Where I can get the trace.axd ?
And also, the exception thrown from code lied in section

if ( !key.Equals("formCode")
&& !key.Equals("formLanguage")
&& !key.Equals("__VIEWSTATE")
&& !key.Equals("__EVENTARGUMENT")
&& !key.Equals("__EVENTTARGET")
&& key.IndexOf("sendButton")<0
&& key.IndexOf("clearButton")<0
&& key.IndexOf("HeaderControl")<0
&& key.IndexOf("PostingListControl")<0 )

the null pointer exception seem to point to variable key. That's why I asked
would it possible the key would be a null value ? Thx

"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:OL**************@TK2MSFTNGP10.phx.gbl...
Look at the trace.axd to get more information and you will probably see
what's going wrong.

It is also possible that one of the key don't have an associated value.
This happens frequently with the QueryString information. You should
store the value of request.Form.GetValues(key) as an object and make that
it's not null before using it.

S. L.

"Tony Cheng" <sd***@fdfsds.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
for (int i=0; i<_request.Form.Count; i++ )
{
string key = _request.Form.GetKey(i);
if ( !key.Equals("formCode")
&& !key.Equals("formLanguage")
&& !key.Equals("__VIEWSTATE")
&& !key.Equals("__EVENTARGUMENT")
&& !key.Equals("__EVENTTARGET")
&& key.IndexOf("sendButton")<0
&& key.IndexOf("clearButton")<0
&& key.IndexOf("HeaderControl")<0
&& key.IndexOf("PostingListControl")<0 )
{
formVO.addFormData(key,
StringUtil.extractStringFromStringArray(_request.F orm.GetValues(key)));
}
}

here is a part of my code. After several postback due to invalid
validation, null pointer exception is caught. What I wonder is
request.Form.Count means number of name-value pairs in Form collection.
Then variable i would be within the range of count. The null pointer
exception seem to point to the variable key. Is that possible a
name-value pair can contain a null as key ? Thx


Nov 19 '05 #3
Tony:

Does this happen on a development machine? The quickest way to find
out the root of the problem is to use the debugger.

--
Scott
http://www.OdeToCode.com/blogs/scott/

On Tue, 22 Mar 2005 15:55:10 +0800, "Tony Cheng" <sd***@fdfsds.com>
wrote:
Where I can get the trace.axd ?
And also, the exception thrown from code lied in section

if ( !key.Equals("formCode")
&& !key.Equals("formLanguage")
&& !key.Equals("__VIEWSTATE")
&& !key.Equals("__EVENTARGUMENT")
&& !key.Equals("__EVENTTARGET")
&& key.IndexOf("sendButton")<0
&& key.IndexOf("clearButton")<0
&& key.IndexOf("HeaderControl")<0
&& key.IndexOf("PostingListControl")<0 )

the null pointer exception seem to point to variable key. That's why I asked
would it possible the key would be a null value ? Thx

"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:OL**************@TK2MSFTNGP10.phx.gbl...
Look at the trace.axd to get more information and you will probably see
what's going wrong.

It is also possible that one of the key don't have an associated value.
This happens frequently with the QueryString information. You should
store the value of request.Form.GetValues(key) as an object and make that
it's not null before using it.

S. L.

"Tony Cheng" <sd***@fdfsds.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
for (int i=0; i<_request.Form.Count; i++ )
{
string key = _request.Form.GetKey(i);
if ( !key.Equals("formCode")
&& !key.Equals("formLanguage")
&& !key.Equals("__VIEWSTATE")
&& !key.Equals("__EVENTARGUMENT")
&& !key.Equals("__EVENTTARGET")
&& key.IndexOf("sendButton")<0
&& key.IndexOf("clearButton")<0
&& key.IndexOf("HeaderControl")<0
&& key.IndexOf("PostingListControl")<0 )
{
formVO.addFormData(key,
StringUtil.extractStringFromStringArray(_request.F orm.GetValues(key)));
}
}

here is a part of my code. After several postback due to invalid
validation, null pointer exception is caught. What I wonder is
request.Form.Count means number of name-value pairs in Form collection.
Then variable i would be within the range of count. The null pointer
exception seem to point to the variable key. Is that possible a
name-value pair can contain a null as key ? Thx



Nov 19 '05 #4
You open a new browser window and you replace the name of the aspx file with
trace.axd. For exemple, if you asp.net file is
http://localhost/LxpNet1/Lxp7_Infrag.../welcome.aspx; then the new name
will be http://localhost/LxpNet1/Lxp7_Infragistic1/trace.axd .

Here are the parameters that I'm using in the web.config file:
<trace enabled="true" requestLimit="10" pageOutput="false"
traceMode="SortByTime" localOnly="true" />

If pageOutput is set to true instead of false, the output of the trace will
get mixed with the HTML written by the aspx file; clearly something that you
don't want must of the time. You can also use Trace.Write (...) and
Trace.Warn (...) to output data to the trace file.

S. L.

"Tony Cheng" <sd***@fdfsds.com> wrote in message
news:uY**************@TK2MSFTNGP15.phx.gbl...
Where I can get the trace.axd ?
And also, the exception thrown from code lied in section

if ( !key.Equals("formCode")
&& !key.Equals("formLanguage")
&& !key.Equals("__VIEWSTATE")
&& !key.Equals("__EVENTARGUMENT")
&& !key.Equals("__EVENTTARGET")
&& key.IndexOf("sendButton")<0
&& key.IndexOf("clearButton")<0
&& key.IndexOf("HeaderControl")<0
&& key.IndexOf("PostingListControl")<0 )

the null pointer exception seem to point to variable key. That's why I
asked would it possible the key would be a null value ? Thx

"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:OL**************@TK2MSFTNGP10.phx.gbl...
Look at the trace.axd to get more information and you will probably see
what's going wrong.

It is also possible that one of the key don't have an associated value.
This happens frequently with the QueryString information. You should
store the value of request.Form.GetValues(key) as an object and make that
it's not null before using it.

S. L.

"Tony Cheng" <sd***@fdfsds.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
for (int i=0; i<_request.Form.Count; i++ )
{
string key = _request.Form.GetKey(i);
if ( !key.Equals("formCode")
&& !key.Equals("formLanguage")
&& !key.Equals("__VIEWSTATE")
&& !key.Equals("__EVENTARGUMENT")
&& !key.Equals("__EVENTTARGET")
&& key.IndexOf("sendButton")<0
&& key.IndexOf("clearButton")<0
&& key.IndexOf("HeaderControl")<0
&& key.IndexOf("PostingListControl")<0 )
{
formVO.addFormData(key,
StringUtil.extractStringFromStringArray(_request.F orm.GetValues(key)));
}
}

here is a part of my code. After several postback due to invalid
validation, null pointer exception is caught. What I wonder is
request.Form.Count means number of name-value pairs in Form collection.
Then variable i would be within the range of count. The null pointer
exception seem to point to the variable key. Is that possible a
name-value pair can contain a null as key ? Thx



Nov 19 '05 #5
thx so much

"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:u7**************@TK2MSFTNGP14.phx.gbl...
You open a new browser window and you replace the name of the aspx file
with trace.axd. For exemple, if you asp.net file is
http://localhost/LxpNet1/Lxp7_Infrag.../welcome.aspx; then the new name
will be http://localhost/LxpNet1/Lxp7_Infragistic1/trace.axd .

Here are the parameters that I'm using in the web.config file:
<trace enabled="true" requestLimit="10" pageOutput="false"
traceMode="SortByTime" localOnly="true" />

If pageOutput is set to true instead of false, the output of the trace
will get mixed with the HTML written by the aspx file; clearly something
that you don't want must of the time. You can also use Trace.Write (...)
and Trace.Warn (...) to output data to the trace file.

S. L.

"Tony Cheng" <sd***@fdfsds.com> wrote in message
news:uY**************@TK2MSFTNGP15.phx.gbl...
Where I can get the trace.axd ?
And also, the exception thrown from code lied in section

if ( !key.Equals("formCode")
&& !key.Equals("formLanguage")
&& !key.Equals("__VIEWSTATE")
&& !key.Equals("__EVENTARGUMENT")
&& !key.Equals("__EVENTTARGET")
&& key.IndexOf("sendButton")<0
&& key.IndexOf("clearButton")<0
&& key.IndexOf("HeaderControl")<0
&& key.IndexOf("PostingListControl")<0 )

the null pointer exception seem to point to variable key. That's why I
asked would it possible the key would be a null value ? Thx

"Sylvain Lafontaine" <sylvain aei ca (fill the blanks, no spam please)>
wrote in message news:OL**************@TK2MSFTNGP10.phx.gbl...
Look at the trace.axd to get more information and you will probably see
what's going wrong.

It is also possible that one of the key don't have an associated value.
This happens frequently with the QueryString information. You should
store the value of request.Form.GetValues(key) as an object and make
that it's not null before using it.

S. L.

"Tony Cheng" <sd***@fdfsds.com> wrote in message
news:%2****************@TK2MSFTNGP15.phx.gbl...
for (int i=0; i<_request.Form.Count; i++ )
{
string key = _request.Form.GetKey(i);
if ( !key.Equals("formCode")
&& !key.Equals("formLanguage")
&& !key.Equals("__VIEWSTATE")
&& !key.Equals("__EVENTARGUMENT")
&& !key.Equals("__EVENTTARGET")
&& key.IndexOf("sendButton")<0
&& key.IndexOf("clearButton")<0
&& key.IndexOf("HeaderControl")<0
&& key.IndexOf("PostingListControl")<0 )
{
formVO.addFormData(key,
StringUtil.extractStringFromStringArray(_request.F orm.GetValues(key)));
}
}

here is a part of my code. After several postback due to invalid
validation, null pointer exception is caught. What I wonder is
request.Form.Count means number of name-value pairs in Form collection.
Then variable i would be within the range of count. The null pointer
exception seem to point to the variable key. Is that possible a
name-value pair can contain a null as key ? Thx



Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
3702
by: Jari Kujansuu | last post by:
I am trying to learn to use jing through JARV interface and I have read JARV User's Guide (http://iso-relax.sourceforge.net/JARV/JARV.html). I have downloaded jingjarv-examples.zip from JARV...
4
2651
by: Jeff Rodriguez | last post by:
Main just loops over this while it's not null. The segfault occurs at this line: *line = (char)ch; Also, please don't just fix the code. I would like to know why exactly this isn't working so I...
5
2687
by: Peter Steele | last post by:
We have an application that when it runs in the IDE in debug mode an unhandled exception is occurring in a system header file associated with STL stirngs. The actual statement that crashes is ...
0
290
by: Matt | last post by:
Hi all, I'm having a very strange problem. The third line in the following code gives me a null reference exception when used in an ASP.Net web page. The code is called on the click of a...
27
4183
by: David W | last post by:
I'm almost tearing my hair out. A colleague claimed that a null reference can exist, like this: void f( int& p ) { printf( "%d\n", p ); } int main (int argc, char *argv) {
1
13076
by: zahidkhan | last post by:
Hi All, Plz help me if you can..... I have a program something like this int main(int argc,char* argv) { try { int* p = NULL;
46
3618
by: lovecreatesbea... | last post by:
Do you prefer malloc or calloc? p = malloc(size); Which of the following two is right to get same storage same as the above call? p = calloc(1, size); p = calloc(size, 1);
11
3218
by: MikeT | last post by:
This may sound very elementary, but can you trap when your object is set to null within the object? I have created a class that registers an event from an object passed in the constructor. When...
9
3784
by: Francois Grieu | last post by:
When running the following code under MinGW, I get realloc(p,0) returned NULL Is that a non-conformance? TIA, Francois Grieu #include <stdio.h> #include <stdlib.h>
1
6852
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7356
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5448
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
4878
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4573
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3084
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3074
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1389
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
628
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.