473,326 Members | 2,168 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

Object reference

in global.asax file of my web application I defined:

public void Application_Start(Object sender, EventArgs e) {

String[] besedila = new String[2];

besedila[1] = "test";

Application["besedilo"] = besedila;

}

And then on my page I have:

public partial class objava : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

String test;
String[] besedila = new String[2];

besedila[1] = "test";
test = besedila[1].ToString();
}

}

And I get the following error:
Object reference not set to an instance of an object.

What that could be? Any idea?

Regards,S


May 19 '06 #1
3 1333
You shouldn't need the .ToString() method because the array is already
of String type. That wouldn't cause the object reference error.

Which line is throwing this exception?

May 19 '06 #2
Array indexes are zero based.

Have you checked that Application object is different than null in
Application_Start ?

Regards,
Tasos

May 19 '06 #3
The code in global.asax and the code in the page are totally unrelated,
and I see nothing in either of them that would cause that exception. The
first item in both array that you create is null, as you don't give them
any value, but that is no problem as you don't use the first item of
either array.

On what line in what file do you get the exception?

simonZ wrote:
in global.asax file of my web application I defined:

public void Application_Start(Object sender, EventArgs e) {

String[] besedila = new String[2];

besedila[1] = "test";

Application["besedilo"] = besedila;

}

And then on my page I have:

public partial class objava : System.Web.UI.Page

{

protected void Page_Load(object sender, EventArgs e)

{

String test;
String[] besedila = new String[2];

besedila[1] = "test";
test = besedila[1].ToString();
}

}

And I get the following error:
Object reference not set to an instance of an object.

What that could be? Any idea?

Regards,S

May 19 '06 #4

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

Similar topics

11
by: DrUg13 | last post by:
In java, this seems so easy. You need a new object Object test = new Object() gives me exactly what I want. could someone please help me understand the different ways to do the same thing in...
5
by: Michael Moreno | last post by:
Hello, In a class I have this code: public object Obj; If Obj is a COM object I would like to call in the Dispose() method the following code: ...
3
by: User1014 | last post by:
A global variable is really just a property of the "Global Object", so what does that make a function defined in the global context? A method of the Global Object? ...
2
by: Ralph | last post by:
Hi I don't understand why it's not working: function schedule(imTop){ this.tdImagesTop = imTop; } schedule.prototype.selectEl = function() { alert(this.tdImagesTop);
275
by: Astley Le Jasper | last post by:
Sorry for the numpty question ... How do you find the reference name of an object? So if i have this bob = modulename.objectname() how do i find that the name is 'bob'
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.