473,769 Members | 3,383 Online
Bytes | Software Development & Data Engineering Community
+ 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.G etKey(i);
if ( !key.Equals("fo rmCode")
&& !key.Equals("fo rmLanguage")
&& !key.Equals("__ VIEWSTATE")
&& !key.Equals("__ EVENTARGUMENT")
&& !key.Equals("__ EVENTTARGET")
&& key.IndexOf("se ndButton")<0
&& key.IndexOf("cl earButton")<0
&& key.IndexOf("He aderControl")<0
&& key.IndexOf("Po stingListContro l")<0 )
{
formVO.addFormD ata(key,
StringUtil.extr actStringFromSt ringArray(_requ est.Form.GetVal ues(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.Co unt 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 2851
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.Ge tValues(key) as an object and make that it's not
null before using it.

S. L.

"Tony Cheng" <sd***@fdfsds.c om> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
for (int i=0; i<_request.Form .Count; i++ )
{
string key = _request.Form.G etKey(i);
if ( !key.Equals("fo rmCode")
&& !key.Equals("fo rmLanguage")
&& !key.Equals("__ VIEWSTATE")
&& !key.Equals("__ EVENTARGUMENT")
&& !key.Equals("__ EVENTTARGET")
&& key.IndexOf("se ndButton")<0
&& key.IndexOf("cl earButton")<0
&& key.IndexOf("He aderControl")<0
&& key.IndexOf("Po stingListContro l")<0 )
{
formVO.addFormD ata(key,
StringUtil.extr actStringFromSt ringArray(_requ est.Form.GetVal ues(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.Co unt 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("fo rmCode")
&& !key.Equals("fo rmLanguage")
&& !key.Equals("__ VIEWSTATE")
&& !key.Equals("__ EVENTARGUMENT")
&& !key.Equals("__ EVENTTARGET")
&& key.IndexOf("se ndButton")<0
&& key.IndexOf("cl earButton")<0
&& key.IndexOf("He aderControl")<0
&& key.IndexOf("Po stingListContro l")<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******** ******@TK2MSFTN GP10.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.Ge tValues(key) as an object and make that
it's not null before using it.

S. L.

"Tony Cheng" <sd***@fdfsds.c om> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
for (int i=0; i<_request.Form .Count; i++ )
{
string key = _request.Form.G etKey(i);
if ( !key.Equals("fo rmCode")
&& !key.Equals("fo rmLanguage")
&& !key.Equals("__ VIEWSTATE")
&& !key.Equals("__ EVENTARGUMENT")
&& !key.Equals("__ EVENTTARGET")
&& key.IndexOf("se ndButton")<0
&& key.IndexOf("cl earButton")<0
&& key.IndexOf("He aderControl")<0
&& key.IndexOf("Po stingListContro l")<0 )
{
formVO.addFormD ata(key,
StringUtil.extr actStringFromSt ringArray(_requ est.Form.GetVal ues(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.Co unt 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.c om>
wrote:
Where I can get the trace.axd ?
And also, the exception thrown from code lied in section

if ( !key.Equals("fo rmCode")
&& !key.Equals("fo rmLanguage")
&& !key.Equals("__ VIEWSTATE")
&& !key.Equals("__ EVENTARGUMENT")
&& !key.Equals("__ EVENTTARGET")
&& key.IndexOf("se ndButton")<0
&& key.IndexOf("cl earButton")<0
&& key.IndexOf("He aderControl")<0
&& key.IndexOf("Po stingListContro l")<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******** ******@TK2MSFTN GP10.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.Ge tValues(key) as an object and make that
it's not null before using it.

S. L.

"Tony Cheng" <sd***@fdfsds.c om> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
for (int i=0; i<_request.Form .Count; i++ )
{
string key = _request.Form.G etKey(i);
if ( !key.Equals("fo rmCode")
&& !key.Equals("fo rmLanguage")
&& !key.Equals("__ VIEWSTATE")
&& !key.Equals("__ EVENTARGUMENT")
&& !key.Equals("__ EVENTTARGET")
&& key.IndexOf("se ndButton")<0
&& key.IndexOf("cl earButton")<0
&& key.IndexOf("He aderControl")<0
&& key.IndexOf("Po stingListContro l")<0 )
{
formVO.addFormD ata(key,
StringUtil.extr actStringFromSt ringArray(_requ est.Form.GetVal ues(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.Co unt 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="1 0" pageOutput="fal se"
traceMode="Sort ByTime" 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.c om> wrote in message
news:uY******** ******@TK2MSFTN GP15.phx.gbl...
Where I can get the trace.axd ?
And also, the exception thrown from code lied in section

if ( !key.Equals("fo rmCode")
&& !key.Equals("fo rmLanguage")
&& !key.Equals("__ VIEWSTATE")
&& !key.Equals("__ EVENTARGUMENT")
&& !key.Equals("__ EVENTTARGET")
&& key.IndexOf("se ndButton")<0
&& key.IndexOf("cl earButton")<0
&& key.IndexOf("He aderControl")<0
&& key.IndexOf("Po stingListContro l")<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******** ******@TK2MSFTN GP10.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.Ge tValues(key) as an object and make that
it's not null before using it.

S. L.

"Tony Cheng" <sd***@fdfsds.c om> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
for (int i=0; i<_request.Form .Count; i++ )
{
string key = _request.Form.G etKey(i);
if ( !key.Equals("fo rmCode")
&& !key.Equals("fo rmLanguage")
&& !key.Equals("__ VIEWSTATE")
&& !key.Equals("__ EVENTARGUMENT")
&& !key.Equals("__ EVENTTARGET")
&& key.IndexOf("se ndButton")<0
&& key.IndexOf("cl earButton")<0
&& key.IndexOf("He aderControl")<0
&& key.IndexOf("Po stingListContro l")<0 )
{
formVO.addFormD ata(key,
StringUtil.extr actStringFromSt ringArray(_requ est.Form.GetVal ues(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.Co unt 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******** ******@TK2MSFTN GP14.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="1 0" pageOutput="fal se"
traceMode="Sort ByTime" 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.c om> wrote in message
news:uY******** ******@TK2MSFTN GP15.phx.gbl...
Where I can get the trace.axd ?
And also, the exception thrown from code lied in section

if ( !key.Equals("fo rmCode")
&& !key.Equals("fo rmLanguage")
&& !key.Equals("__ VIEWSTATE")
&& !key.Equals("__ EVENTARGUMENT")
&& !key.Equals("__ EVENTTARGET")
&& key.IndexOf("se ndButton")<0
&& key.IndexOf("cl earButton")<0
&& key.IndexOf("He aderControl")<0
&& key.IndexOf("Po stingListContro l")<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******** ******@TK2MSFTN GP10.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.Ge tValues(key) as an object and make
that it's not null before using it.

S. L.

"Tony Cheng" <sd***@fdfsds.c om> wrote in message
news:%2******** ********@TK2MSF TNGP15.phx.gbl. ..
for (int i=0; i<_request.Form .Count; i++ )
{
string key = _request.Form.G etKey(i);
if ( !key.Equals("fo rmCode")
&& !key.Equals("fo rmLanguage")
&& !key.Equals("__ VIEWSTATE")
&& !key.Equals("__ EVENTARGUMENT")
&& !key.Equals("__ EVENTTARGET")
&& key.IndexOf("se ndButton")<0
&& key.IndexOf("cl earButton")<0
&& key.IndexOf("He aderControl")<0
&& key.IndexOf("Po stingListContro l")<0 )
{
formVO.addFormD ata(key,
StringUtil.extr actStringFromSt ringArray(_requ est.Form.GetVal ues(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.Co unt 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
3724
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 User's Guide page and latest jing version 20030619 from jing home page. I can run jing successfully from command line like this (which I guess proves that schema should be correct) C:\Temp\APU> java -jar jing.jar schema.xsd valid.xml
4
2667
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 can avoid problems with it in the future. If there are any references I should check out let me know. Full highlighted code at:
5
2705
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 return ::memcmp(_First1, _First2, _Count); On inspecting these variables, the strings are in fact equal when the exception occurs and _Count is the right size. As a test I replaced this code in the system include file with a for loop to do the...
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 button. Public Overridable Property SDSVarsSetup() As Boolean Get If Not IsNothing(Session("SDSVarsSetup")) Then ' <-- **Exception occurs here**
27
4234
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
13105
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
3688
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
3266
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 my object is destroyed, I want my object to un-register this event. If I don't then the object would never be destroyed until the object I passed in the constructor is destroyed. I have implemented a Dispose(), Dispose(bool), and ~Finalize...
9
3810
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>
0
9423
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10210
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10043
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9990
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
7406
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6672
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5446
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3561
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2814
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.