473,657 Members | 2,473 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

another Object reference not set to an instance of an object. prob

I'm a beginner with .NET so this is probably a very simple problem that will
be immediately obvious to someone hopefully. I'm using J#.NET

The following contains the code caused the error

Line 385: String link = "http://10.4.190.120/config/lconfig.aspx" ;
Line 386: GtLink.Redirect (link);
Line 387: //NLine.set_Text( Selection);

STACK TRACE

[NullReferenceEx ception: Object reference not set to an instance of an
object.]
Config.Config.U pdate_Click(Obj ect sender, EventArgs e) in
E:\Inetpub\wwwr oot\Portal\Conf ig\Config.aspx. jsl:386
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +111
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument)
+232

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +5
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +11
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +31
System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint

Am I leaving something out or should I be initializing something firat. I
had the same error trying to get the server variables from the client but I
gave up on it eventually as I was able to work without the Host name though
it would add an extra element of security that I am looking for.

Thanks in adv for any help.

Dubh
Jul 21 '05 #1
14 1811
Is GtLink a type or an object reference? That is, does the line

GtLink.Redirect (link)

mean 'call the static Redirect method defined by the GtLink class', or
does it mean 'call the Redirect method on the object referenced by the
GtLink variable'.

If it is the latter, the GtLink variable is probably not initialized,
otherwise we need a bit more info.

Regards,
Joakim

Dubh wrote:
I'm a beginner with .NET so this is probably a very simple problem that will
be immediately obvious to someone hopefully. I'm using J#.NET

The following contains the code caused the error

Line 385: String link = "http://10.4.190.120/config/lconfig.aspx" ;
Line 386: GtLink.Redirect (link);
Line 387: //NLine.set_Text( Selection);

STACK TRACE

[NullReferenceEx ception: Object reference not set to an instance of an
object.]
Config.Config.U pdate_Click(Obj ect sender, EventArgs e) in
E:\Inetpub\wwwr oot\Portal\Conf ig\Config.aspx. jsl:386
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +111
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument)
+232

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +5
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +11
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +31
System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint

Am I leaving something out or should I be initializing something firat. I
had the same error trying to get the server variables from the client but I
gave up on it eventually as I was able to work without the Host name though
it would add an extra element of security that I am looking for.

Thanks in adv for any help.

Dubh

Jul 21 '05 #2
GtLink is defined here:

protected System.Web.Http Response GtLink;

Does that help?

"Joakim Karlsson" wrote:
Is GtLink a type or an object reference? That is, does the line

GtLink.Redirect (link)

mean 'call the static Redirect method defined by the GtLink class', or
does it mean 'call the Redirect method on the object referenced by the
GtLink variable'.

If it is the latter, the GtLink variable is probably not initialized,
otherwise we need a bit more info.

Regards,
Joakim

Dubh wrote:
I'm a beginner with .NET so this is probably a very simple problem that will
be immediately obvious to someone hopefully. I'm using J#.NET

The following contains the code caused the error

Line 385: String link = "http://10.4.190.120/config/lconfig.aspx" ;
Line 386: GtLink.Redirect (link);
Line 387: //NLine.set_Text( Selection);

STACK TRACE

[NullReferenceEx ception: Object reference not set to an instance of an
object.]
Config.Config.U pdate_Click(Obj ect sender, EventArgs e) in
E:\Inetpub\wwwr oot\Portal\Conf ig\Config.aspx. jsl:386
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +111
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument)
+232

System.Web.UI.W ebControls.Butt on.System.Web.U I.IPostBackEven tHandler.RaiseP ostBackEvent(St ring eventArgument) +5
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceControl, String eventArgument) +11
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +31
System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint

Am I leaving something out or should I be initializing something firat. I
had the same error trying to get the server variables from the client but I
gave up on it eventually as I was able to work without the Host name though
it would add an extra element of security that I am looking for.

Thanks in adv for any help.

Dubh

Jul 21 '05 #3
Do you ever assign the GtLink variable to anything?

I suspect you don't.

Regards,
Joakim

Dubh wrote:
GtLink is defined here:

protected System.Web.Http Response GtLink;

Does that help?

"Joakim Karlsson" wrote:

Is GtLink a type or an object reference? That is, does the line

GtLink.Redire ct(link)

mean 'call the static Redirect method defined by the GtLink class', or
does it mean 'call the Redirect method on the object referenced by the
GtLink variable'.

If it is the latter, the GtLink variable is probably not initialized,
otherwise we need a bit more info.

Regards,
Joakim

Dubh wrote:
I'm a beginner with .NET so this is probably a very simple problem that will
be immediately obvious to someone hopefully. I'm using J#.NET

The following contains the code caused the error

Line 385: String link = "http://10.4.190.120/config/lconfig.aspx" ;
Line 386: GtLink.Redirect (link);
Line 387: //NLine.set_Text( Selection);

STACK TRACE

[NullReferenceEx ception: Object reference not set to an instance of an
object.]
Config.Config.U pdate_Click(Obj ect sender, EventArgs e) in
E:\Inetpub\w wwroot\Portal\C onfig\Config.as px.jsl:386
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +111
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument)
+232

System.Web.U I.WebControls.B utton.System.We b.UI.IPostBackE ventHandler.Rai sePostBackEvent (String eventArgument) +5
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceContro l, String eventArgument) +11
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +31
System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint

Am I leaving something out or should I be initializing something firat. I
had the same error trying to get the server variables from the client but I
gave up on it eventually as I was able to work without the Host name though
it would add an extra element of security that I am looking for.

Thanks in adv for any help.

Dubh

Jul 21 '05 #4
Is it not assigned to the System.Web.Http Response object ? Does it have to be
initialized first?

"Joakim Karlsson" wrote:
Do you ever assign the GtLink variable to anything?

I suspect you don't.

Regards,
Joakim

Dubh wrote:
GtLink is defined here:

protected System.Web.Http Response GtLink;

Does that help?

"Joakim Karlsson" wrote:

Is GtLink a type or an object reference? That is, does the line

GtLink.Redire ct(link)

mean 'call the static Redirect method defined by the GtLink class', or
does it mean 'call the Redirect method on the object referenced by the
GtLink variable'.

If it is the latter, the GtLink variable is probably not initialized,
otherwise we need a bit more info.

Regards,
Joakim

Dubh wrote:

I'm a beginner with .NET so this is probably a very simple problem that will
be immediately obvious to someone hopefully. I'm using J#.NET

The following contains the code caused the error

Line 385: String link = "http://10.4.190.120/config/lconfig.aspx" ;
Line 386: GtLink.Redirect (link);
Line 387: //NLine.set_Text( Selection);

STACK TRACE

[NullReferenceEx ception: Object reference not set to an instance of an
object.]
Config.Config.U pdate_Click(Obj ect sender, EventArgs e) in
E:\Inetpub\w wwroot\Portal\C onfig\Config.as px.jsl:386
System.Web.UI.W ebControls.Butt on.OnClick(Even tArgs e) +111
System.Web.UI.W ebControls.Butt on.RaisePostBac kEvent(String eventArgument)
+232

System.Web.U I.WebControls.B utton.System.We b.UI.IPostBackE ventHandler.Rai sePostBackEvent (String eventArgument) +5
System.Web.UI.P age.RaisePostBa ckEvent(IPostBa ckEventHandler
sourceContro l, String eventArgument) +11
System.Web.UI.P age.RaisePostBa ckEvent(NameVal ueCollection postData) +31
System.Web.UI.P age.ProcessRequ estMain(Boolean includeStagesBe foreAsyncPoint

Am I leaving something out or should I be initializing something firat. I
had the same error trying to get the server variables from the client but I
gave up on it eventually as I was able to work without the Host name though
it would add an extra element of security that I am looking for.

Thanks in adv for any help.

Dubh

Jul 21 '05 #5
Dubh <Du**@discussio ns.microsoft.co m> wrote:
Is it not assigned to the System.Web.Http Response object ? Does it have to be
initialized first?


System.Web.Http Response is a type, not an object. You have to set the
variable's value in order for it to become non-null, yes.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #6
Excuse my ignorance regarding terminology. I'm finding it a bit difficult
with the J#.NET stuff as it doesn't have as many examples or even
documentation as VB.NET or C*.NET. Could you give me a very quick example of
what I should be putting in.

Currently I am using the following lines

protected System.Web.Http Response GtLink;

String link = "http://10.4.190.120/config/lconfig.aspx" ;
GtLink.Redirect (link);

Couldn't I have just as easily used

protected System.Web.Http Response GtLink;
GtLink.Redirect ("http://10.4.190.120/config/lconfig.aspx");

and still get the same error. What do I need to make GtLink non-null?
Also could this be why I was getting the same error when trying to get the
server variables using HttpRequest.get _UserHostAddres s(). Should I be
initializing something there as well?

Thanks again for all your help.

Dubh

"Jon Skeet [C# MVP]" wrote:
Dubh <Du**@discussio ns.microsoft.co m> wrote:
Is it not assigned to the System.Web.Http Response object ? Does it have to be
initialized first?


System.Web.Http Response is a type, not an object. You have to set the
variable's value in order for it to become non-null, yes.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Jul 21 '05 #7
Dubh <Du**@discussio ns.microsoft.co m> wrote:
Excuse my ignorance regarding terminology. I'm finding it a bit difficult
with the J#.NET stuff as it doesn't have as many examples or even
documentation as VB.NET or C*.NET.
Indeed - although the problem is absolutely the same in any of the
languages.
Could you give me a very quick example of what I should be putting in.
I'm not an ASP.NET expect, but I'm sure there's the Response property
of some kind of context that you have access to.
Currently I am using the following lines

protected System.Web.Http Response GtLink;

String link = "http://10.4.190.120/config/lconfig.aspx" ;
GtLink.Redirect (link);

Couldn't I have just as easily used

protected System.Web.Http Response GtLink;
GtLink.Redirect ("http://10.4.190.120/config/lconfig.aspx");

and still get the same error. What do I need to make GtLink non-null?
Because you're trying to call an instance method on it. As it is, the
runtime is basically saying "I don't know which response I'm trying to
redirect."
Also could this be why I was getting the same error when trying to get the
server variables using HttpRequest.get _UserHostAddres s(). Should I be
initializing something there as well?


Yes - otherwise it doesn't know which request you're talking about.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Jul 21 '05 #8
Jon,

thanks for your help though to be honest I'm none the wiser if not even more
confused. I think I'll just start at the beginning with the JScript language
tour and slowly work my way back to where I'm stuck. I studied Basic and
Cobol but that was years ago and am only doing this to set up a netware
systems monitoring and admin website at work.
I'm not an ASP.NET expect, but I'm sure there's the Response property
of some kind of context that you have access to.
No idea what you mean by this! I have a drop-down list of a grouping of
servers and depending on what was selected I want to redirect the user to
administer or reconfigure it on a separate page. I don't want to use a
hyperlink as I need to send extra info so I'm using a standard button and
calling the code on the OnClick event.

main code ...

protected System.Web.Http Response GtLink;

.....more code

private void Update_Click (Object sender, System.EventArg s e)
{
............... ..some code
String link = "http://10.4.190.120/config/lconfig.aspx" ;
GtLink.Redirect (link);
............... ...some code
}

Take the following code as an example of an area with no issue.

main code ....
protected System.Web.UI.W ebControls.Text Box NLine;

.....more code

Selection = DDList1.get_Sel ectedItem().get _Text(); //Get Line to be
configured DD
NLine.set_Text( Selection);

My textbox shows the item selected form the DDlist, yet I didn't do anything
to pre-initialize NLine. I expected that the same would apply to GtLink??
Because you're trying to call an instance method on it. As it is, the
runtime is basically saying "I don't know which response I'm trying to
redirect."


I assumed that what I was telling it to do was If this button is clicked
then this and that and open the following web page. Obviously it is not that
simple.
Also could this be why I was getting the same error when trying to get the
server variables using HttpRequest.get _UserHostAddres s(). Should I be
initializing something there as well?


Yes - otherwise it doesn't know which request you're talking about.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Thanks

Dubh

Jul 21 '05 #9
Dubh,

Here the samples of use of the response.redire ct on msdn

http://msdn.microsoft.com/library/de...irecttopic.asp

Seems for me simple to solve your problem with that

I hope this helps?

Cor
Jul 21 '05 #10

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

Similar topics

4
8400
by: Ken | last post by:
Hello I am trying to change the color of a font in a text box. I have been reading about and trying various examples found it this group, but still can't get it right. Here is where I am now: <script language="JavaScript">
188
7165
by: christopher diggins | last post by:
I have posted a C# critique at http://www.heron-language.com/c-sharp-critique.html. To summarize I bring up the following issues : - unsafe code - attributes - garbage collection - non-deterministic destructors - Objects can't exist on the stack - Type / Reference Types
12
11961
by: Bill Todd | last post by:
Form B needs to call a public method of Form A. How can form B get a reference to the instance of Form A using its name or any other method? Is there a collection of form instances that can be searched? -- Bill
4
2678
by: Frawls | last post by:
Hi, I get the following error when trying to run a search on my aspx site, this error only occours if the product im searching for does not exist. Can anybody explain this please and help me with a solution, i know its probably simple but im new to the game...Cheers ----------------------------------------------------------------------- Object reference not set to an instance of an object.
14
260
by: Dubh | last post by:
I'm a beginner with .NET so this is probably a very simple problem that will be immediately obvious to someone hopefully. I'm using J#.NET The following contains the code caused the error Line 385: String link = "http://10.4.190.120/config/lconfig.aspx" ; Line 386: GtLink.Redirect(link); Line 387: //NLine.set_Text(Selection); STACK TRACE
6
2474
by: Shailen Sukul | last post by:
Observed a weird behaviour with object references. See code listing below: using System; using System.Collections.Generic; using System.Text; namespace PointerExceptionTest { /*
12
2359
by: Rob | last post by:
Let's say you open Form1 that contains TabControl1 There are several tabs on TabControl1 Now you open a new Form2 that contains a User Control How can you determine the Selected tab in Form1 from the User Control in Form2 ? Hope this is clear enough...
4
1717
by: eBob.com | last post by:
In my class which contains the code for my worker thread I have ... Public MustInherit Class Base_Miner #Region " Delegates for accessing main UI form " Delegate Sub DelegAddProgressBar(ByVal uiform As Form1, ByRef si As MTCC02.Form1.SiteRunOpts, _ ByVal numitems As Integer) #End Region
8
1748
by: weird0 | last post by:
The scenario is that i have two forms, Form1( main form) and Form2 and both of them opened. Form1 has called Form2 inside of its constructor. class Form1 { const int NodeLimit=30; Node nodeArray=new Node;
0
8397
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8310
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
8827
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...
1
8503
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,...
0
8605
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2731
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 we have to send another system
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1620
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.