Thursday, March 29, 2012
Object Oriented
I Have 2 questions:
1) what is the difference betweenObject oriented design andObject oriented programming?
2) what is "Client/Server programming-3-tier architecture" ?(the red sentence)
Thank youHi, it is lengthy to give you the full definition of 3-tier architecture and distinct difference betwween the OOD and OOP. You can get the answer fromhttp://en.wikipedia.org/ or Google by typing "define:keyword" here.
Hope this helps...
Answer to 2
- http://www.corba.ch/e/3tier.html
thank you ...It was very helpful
object oriented design books
particularly with regards to building an asp.net/sql server application. I
don't mean a book explaining concepts like inheritance etc. but one that
actually tells you how to design a system. I have read a few and although
they sound ok in theory they tend to be rather impractial when it actually
comes to implementing anything.
--
ScottThere are an infinite number of potential applications, and therefore an
infinite number of ways to design them.
This book is great for helping you figure out how to design the object model
behind large and complex applications:
Expert One-on-One Visual Basic .NET Business Objects (by Rockford Lhotka)
http://www.amazon.com/exec/obidos/A...3&link_code=as1
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"scottrm" <scottrm@.newsgroup.nospam> wrote in message
news:4A9F0DBD-7A30-4EC8-9D79-E9B6F00C31EE@.microsoft.com...
> Any recommendations for a good book/article/sample on object oriented
> design
> particularly with regards to building an asp.net/sql server application. I
> don't mean a book explaining concepts like inheritance etc. but one that
> actually tells you how to design a system. I have read a few and although
> they sound ok in theory they tend to be rather impractial when it actually
> comes to implementing anything.
> --
> Scott
object oriented design books
particularly with regards to building an asp.net/sql server application. I
don't mean a book explaining concepts like inheritance etc. but one that
actually tells you how to design a system. I have read a few and although
they sound ok in theory they tend to be rather impractial when it actually
comes to implementing anything.
--
ScottThere are an infinite number of potential applications, and therefore an
infinite number of ways to design them.
This book is great for helping you figure out how to design the object model
behind large and complex applications:
Expert One-on-One Visual Basic .NET Business Objects (by Rockford Lhotka)
http://www.amazon.com/exec/obidos/A...3&link_code=as1
--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://SteveOrr.net
"scottrm" <scottrm@.newsgroup.nospam> wrote in message
news:4A9F0DBD-7A30-4EC8-9D79-E9B6F00C31EE@.microsoft.com...
> Any recommendations for a good book/article/sample on object oriented
> design
> particularly with regards to building an asp.net/sql server application. I
> don't mean a book explaining concepts like inheritance etc. but one that
> actually tells you how to design a system. I have read a few and although
> they sound ok in theory they tend to be rather impractial when it actually
> comes to implementing anything.
> --
> Scott
Monday, March 26, 2012
Object reference not set
two other server side tables on it that have been working great. In Visual
Studio everything works great. When I put the page on the production server
,
the first time in the page works great. If I navigate to any other page on
the site and then try to return to the home page the control I added throws
the following:
Server Error in '/' Application.
----
--
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information abou
t
the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
MAFE.home.LoadBWOM()
MAFE.home.Page_Load(Object sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +761
If I comment out the line of code where I store a row in the new table, all
works just fine. Anyone have any ideas?
Charlie Jursch
Patotech Software, Inc.
Danville, CAcan you show us the line of code that you comment out to make it work, and
all relevant lines of code? Clearly something's null. It's easy to debug if
you step through it and add a breakpoint on that line...
Karl
http://www.openmymind.net/
http://www.fuelindustries.com/
"Charlie J" <CharlieJ@.discussions.microsoft.com> wrote in message
news:F5A9B425-AF2C-45C3-AF7B-DA5DC5CBC3F8@.microsoft.com...
>I have a real stumper. I added a server side table to a home page that has
> two other server side tables on it that have been working great. In
> Visual
> Studio everything works great. When I put the page on the production
> server,
> the first time in the page works great. If I navigate to any other page
> on
> the site and then try to return to the home page the control I added
> throws
> the following:
> Server Error in '/' Application.
> ----
--
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about
> the error and where it originated in the code.
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
> Source Error:
> An unhandled exception was generated during the execution of the current
> web
> request. Information regarding the origin and location of the exception
> can
> be identified using the exception stack trace below.
> Stack Trace:
>
> [NullReferenceException: Object reference not set to an instance of an
> object.]
> MAFE.home.LoadBWOM()
> MAFE.home.Page_Load(Object sender, EventArgs e)
> System.Web.UI.Control.OnLoad(EventArgs e) +67
> System.Web.UI.Control.LoadRecursive() +35
> System.Web.UI.Page.ProcessRequestMain() +761
> If I comment out the line of code where I store a row in the new table,
> all
> works just fine. Anyone have any ideas?
> --
> Charlie Jursch
> Patotech Software, Inc.
> Danville, CA
Charlie, you may wish to read the reply I made to your original post - I
crossposted it to this group so it still has the original subject: "Re:
ASP.NET Problem with return to home page".
The conversation about this topic should, of course, continue in this
thread. I just wanted to draw your attention to what I said.
Bob Barrows
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Here is the line of code:
tdBWOM.InnerHtml = sb1.ToString();
In an attempt to isolate what is happening, I changed the html file to use a
html table instead of an asp:Table. I get the same result.
I cannot get this to fail on my test system, only on the production server.
When the page first displays, the text I put in the cell displays perfectly.
There is no error. Only when I navigate to another page on the site and the
n
navigate back to this page do I get the error. If you want to see the aspx
page after it is generated, go to www.mafe.org. It is the home page for the
site (default.aspx) that I am having the problem with. I currently have the
line of code above commented out in the code behind file.
--
Charlie Jursch
Patotech Software, Inc.
Danville, CA
"Karl Seguin [MVP]" wrote:
> can you show us the line of code that you comment out to make it work, and
> all relevant lines of code? Clearly something's null. It's easy to debug
if
> you step through it and add a breakpoint on that line...
> Karl
> --
> http://www.openmymind.net/
> http://www.fuelindustries.com/
>
> "Charlie J" <CharlieJ@.discussions.microsoft.com> wrote in message
> news:F5A9B425-AF2C-45C3-AF7B-DA5DC5CBC3F8@.microsoft.com...
>
>
Bob,
Thanks for your input. I have updated the web.config accordingly.
--
Charlie Jursch
Patotech Software, Inc.
Danville, CA
"Bob Barrows [MVP]" wrote:
> Charlie, you may wish to read the reply I made to your original post - I
> crossposted it to this group so it still has the original subject: "Re:
> ASP.NET Problem with return to home page".
> The conversation about this topic should, of course, continue in this
> thread. I just wanted to draw your attention to what I said.
> Bob Barrows
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>
You still have not shown enough code to enable us to see what's happening.
All I can say is that you should determine which object it is complaining
about : tdBWOM or sb1. Insert some code to verify that both of these
variables are set to the appropriate objects.
You should do this before posting more code. :-)
Bob Barrows
Charlie J wrote:
> Here is the line of code:
> tdBWOM.InnerHtml = sb1.ToString();
> In an attempt to isolate what is happening, I changed the html file
> to use a html table instead of an asp:Table. I get the same result.
> I cannot get this to fail on my test system, only on the production
> server. When the page first displays, the text I put in the cell
> displays perfectly. There is no error. Only when I navigate to
> another page on the site and then navigate back to this page do I get
> the error. If you want to see the aspx page after it is generated,
> go to www.mafe.org. It is the home page for the site (default.aspx)
> that I am having the problem with. I currently have the line of code
> above commented out in the code behind file. --
> Charlie Jursch
> Patotech Software, Inc.
> Danville, CA
>
> "Karl Seguin [MVP]" wrote:
>
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
agreed.
If that's the line, it's clear that either sb is null or tdBWOM is null.
Karl
http://www.openmymind.net/
http://www.fuelindustries.com/
"Bob Barrows [MVP]" <reb01501@.NOyahoo.SPAMcom> wrote in message
news:OUxytzFRGHA.5552@.TK2MSFTNGP14.phx.gbl...
> You still have not shown enough code to enable us to see what's happening.
> All I can say is that you should determine which object it is complaining
> about : tdBWOM or sb1. Insert some code to verify that both of these
> variables are set to the appropriate objects.
> You should do this before posting more code. :-)
> Bob Barrows
> Charlie J wrote:
> --
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
... which leaves unanswered the question of why one of them is null, which
can best be answered by stepping through the code (not recommended in a
production environment, but a duplicate app could be created for testing, I
suppose). If stepping is not an option, then you have to manually backtrace
the lines of code leading up to this line and see if you can identify the
failure to instantiate the object.
Karl Seguin [MVP] wrote:
> agreed.
> If that's the line, it's clear that either sb is null or tdBWOM is
> null.
> Karl
> --
> http://www.openmymind.net/
> http://www.fuelindustries.com/
>
> "Bob Barrows [MVP]" <reb01501@.NOyahoo.SPAMcom> wrote in message
> news:OUxytzFRGHA.5552@.TK2MSFTNGP14.phx.gbl...
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
I resolved this issue by upgrading the application to APS.NET 2.0. This all
started to happen right after I had installed 2.0 on the servers. I cannot
explain why it was happening, only that after I converted the application to
2.0 everything started to work normally.
Thanks for your assistance.
--
Charlie Jursch
Patotech Software, Inc.
Danville, CA
"Charlie J" wrote:
> I have a real stumper. I added a server side table to a home page that ha
s
> two other server side tables on it that have been working great. In Visua
l
> Studio everything works great. When I put the page on the production serv
er,
> the first time in the page works great. If I navigate to any other page o
n
> the site and then try to return to the home page the control I added throw
s
> the following:
> Server Error in '/' Application.
> ----
--
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information ab
out
> the error and where it originated in the code.
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
> Source Error:
> An unhandled exception was generated during the execution of the current w
eb
> request. Information regarding the origin and location of the exception ca
n
> be identified using the exception stack trace below.
> Stack Trace:
>
> [NullReferenceException: Object reference not set to an instance of an
> object.]
> MAFE.home.LoadBWOM()
> MAFE.home.Page_Load(Object sender, EventArgs e)
> System.Web.UI.Control.OnLoad(EventArgs e) +67
> System.Web.UI.Control.LoadRecursive() +35
> System.Web.UI.Page.ProcessRequestMain() +761
> If I comment out the line of code where I store a row in the new table, al
l
> works just fine. Anyone have any ideas?
> --
> Charlie Jursch
> Patotech Software, Inc.
> Danville, CA
Object reference not set
two other server side tables on it that have been working great. In Visual
Studio everything works great. When I put the page on the production server,
the first time in the page works great. If I navigate to any other page on
the site and then try to return to the home page the control I added throws
the following:
Server Error in '/' Application.
------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set
to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the current web
request. Information regarding the origin and location of the exception can
be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
MAFE.home.LoadBWOM()
MAFE.home.Page_Load(Object sender, EventArgs e)
System.Web.UI.Control.OnLoad(EventArgs e) +67
System.Web.UI.Control.LoadRecursive() +35
System.Web.UI.Page.ProcessRequestMain() +761
If I comment out the line of code where I store a row in the new table, all
works just fine. Anyone have any ideas?
--
Charlie Jursch
Patotech Software, Inc.
Danville, CAcan you show us the line of code that you comment out to make it work, and
all relevant lines of code? Clearly something's null. It's easy to debug if
you step through it and add a breakpoint on that line...
Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Charlie J" <CharlieJ@.discussions.microsoft.com> wrote in message
news:F5A9B425-AF2C-45C3-AF7B-DA5DC5CBC3F8@.microsoft.com...
>I have a real stumper. I added a server side table to a home page that has
> two other server side tables on it that have been working great. In
> Visual
> Studio everything works great. When I put the page on the production
> server,
> the first time in the page works great. If I navigate to any other page
> on
> the site and then try to return to the home page the control I added
> throws
> the following:
> Server Error in '/' Application.
> ------------------------
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information
> about
> the error and where it originated in the code.
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
> Source Error:
> An unhandled exception was generated during the execution of the current
> web
> request. Information regarding the origin and location of the exception
> can
> be identified using the exception stack trace below.
> Stack Trace:
>
> [NullReferenceException: Object reference not set to an instance of an
> object.]
> MAFE.home.LoadBWOM()
> MAFE.home.Page_Load(Object sender, EventArgs e)
> System.Web.UI.Control.OnLoad(EventArgs e) +67
> System.Web.UI.Control.LoadRecursive() +35
> System.Web.UI.Page.ProcessRequestMain() +761
> If I comment out the line of code where I store a row in the new table,
> all
> works just fine. Anyone have any ideas?
> --
> Charlie Jursch
> Patotech Software, Inc.
> Danville, CA
Charlie, you may wish to read the reply I made to your original post - I
crossposted it to this group so it still has the original subject: "Re:
ASP.NET Problem with return to home page".
The conversation about this topic should, of course, continue in this
thread. I just wanted to draw your attention to what I said.
Bob Barrows
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Here is the line of code:
tdBWOM.InnerHtml = sb1.ToString();
In an attempt to isolate what is happening, I changed the html file to use a
html table instead of an asp:Table. I get the same result.
I cannot get this to fail on my test system, only on the production server.
When the page first displays, the text I put in the cell displays perfectly.
There is no error. Only when I navigate to another page on the site and then
navigate back to this page do I get the error. If you want to see the aspx
page after it is generated, go to www.mafe.org. It is the home page for the
site (default.aspx) that I am having the problem with. I currently have the
line of code above commented out in the code behind file.
--
Charlie Jursch
Patotech Software, Inc.
Danville, CA
"Karl Seguin [MVP]" wrote:
> can you show us the line of code that you comment out to make it work, and
> all relevant lines of code? Clearly something's null. It's easy to debug if
> you step through it and add a breakpoint on that line...
> Karl
> --
> http://www.openmymind.net/
> http://www.fuelindustries.com/
>
> "Charlie J" <CharlieJ@.discussions.microsoft.com> wrote in message
> news:F5A9B425-AF2C-45C3-AF7B-DA5DC5CBC3F8@.microsoft.com...
> >I have a real stumper. I added a server side table to a home page that has
> > two other server side tables on it that have been working great. In
> > Visual
> > Studio everything works great. When I put the page on the production
> > server,
> > the first time in the page works great. If I navigate to any other page
> > on
> > the site and then try to return to the home page the control I added
> > throws
> > the following:
> > Server Error in '/' Application.
> > ------------------------
> > Object reference not set to an instance of an object.
> > Description: An unhandled exception occurred during the execution of the
> > current web request. Please review the stack trace for more information
> > about
> > the error and where it originated in the code.
> > Exception Details: System.NullReferenceException: Object reference not set
> > to an instance of an object.
> > Source Error:
> > An unhandled exception was generated during the execution of the current
> > web
> > request. Information regarding the origin and location of the exception
> > can
> > be identified using the exception stack trace below.
> > Stack Trace:
> > [NullReferenceException: Object reference not set to an instance of an
> > object.]
> > MAFE.home.LoadBWOM()
> > MAFE.home.Page_Load(Object sender, EventArgs e)
> > System.Web.UI.Control.OnLoad(EventArgs e) +67
> > System.Web.UI.Control.LoadRecursive() +35
> > System.Web.UI.Page.ProcessRequestMain() +761
> > If I comment out the line of code where I store a row in the new table,
> > all
> > works just fine. Anyone have any ideas?
> > --
> > Charlie Jursch
> > Patotech Software, Inc.
> > Danville, CA
>
Bob,
Thanks for your input. I have updated the web.config accordingly.
--
Charlie Jursch
Patotech Software, Inc.
Danville, CA
"Bob Barrows [MVP]" wrote:
> Charlie, you may wish to read the reply I made to your original post - I
> crossposted it to this group so it still has the original subject: "Re:
> ASP.NET Problem with return to home page".
> The conversation about this topic should, of course, continue in this
> thread. I just wanted to draw your attention to what I said.
> Bob Barrows
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
You still have not shown enough code to enable us to see what's happening.
All I can say is that you should determine which object it is complaining
about: tdBWOM or sb1. Insert some code to verify that both of these
variables are set to the appropriate objects.
You should do this before posting more code. :-)
Bob Barrows
Charlie J wrote:
> Here is the line of code:
> tdBWOM.InnerHtml = sb1.ToString();
> In an attempt to isolate what is happening, I changed the html file
> to use a html table instead of an asp:Table. I get the same result.
> I cannot get this to fail on my test system, only on the production
> server. When the page first displays, the text I put in the cell
> displays perfectly. There is no error. Only when I navigate to
> another page on the site and then navigate back to this page do I get
> the error. If you want to see the aspx page after it is generated,
> go to www.mafe.org. It is the home page for the site (default.aspx)
> that I am having the problem with. I currently have the line of code
> above commented out in the code behind file. --
> Charlie Jursch
> Patotech Software, Inc.
> Danville, CA
>
> "Karl Seguin [MVP]" wrote:
>> can you show us the line of code that you comment out to make it
>> work, and all relevant lines of code? Clearly something's null.
>> It's easy to debug if you step through it and add a breakpoint on
>> that line...
>>
>> Karl
>>
>> --
>> http://www.openmymind.net/
>> http://www.fuelindustries.com/
>>
>>
>> "Charlie J" <CharlieJ@.discussions.microsoft.com> wrote in message
>> news:F5A9B425-AF2C-45C3-AF7B-DA5DC5CBC3F8@.microsoft.com...
>>> I have a real stumper. I added a server side table to a home page
>>> that has two other server side tables on it that have been working
>>> great. In Visual
>>> Studio everything works great. When I put the page on the
>>> production server,
>>> the first time in the page works great. If I navigate to any other
>>> page on
>>> the site and then try to return to the home page the control I added
>>> throws
>>> the following:
>>>
>>> Server Error in '/' Application.
>>> ----------------------
---
>>>
>>> Object reference not set to an instance of an object.
>>> Description: An unhandled exception occurred during the execution
>>> of the current web request. Please review the stack trace for more
>>> information about
>>> the error and where it originated in the code.
>>>
>>> Exception Details: System.NullReferenceException: Object reference
>>> not set to an instance of an object.
>>>
>>> Source Error:
>>>
>>> An unhandled exception was generated during the execution of the
>>> current web
>>> request. Information regarding the origin and location of the
>>> exception can
>>> be identified using the exception stack trace below.
>>>
>>> Stack Trace:
>>>
>>>
>>> [NullReferenceException: Object reference not set to an instance of
>>> an object.]
>>> MAFE.home.LoadBWOM()
>>> MAFE.home.Page_Load(Object sender, EventArgs e)
>>> System.Web.UI.Control.OnLoad(EventArgs e) +67
>>> System.Web.UI.Control.LoadRecursive() +35
>>> System.Web.UI.Page.ProcessRequestMain() +761
>>>
>>> If I comment out the line of code where I store a row in the new
>>> table, all
>>> works just fine. Anyone have any ideas?
>>>
>>> --
>>> Charlie Jursch
>>> Patotech Software, Inc.
>>> Danville, CA
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
agreed.
If that's the line, it's clear that either sb is null or tdBWOM is null.
Karl
--
http://www.openmymind.net/
http://www.fuelindustries.com/
"Bob Barrows [MVP]" <reb01501@.NOyahoo.SPAMcom> wrote in message
news:OUxytzFRGHA.5552@.TK2MSFTNGP14.phx.gbl...
> You still have not shown enough code to enable us to see what's happening.
> All I can say is that you should determine which object it is complaining
> about: tdBWOM or sb1. Insert some code to verify that both of these
> variables are set to the appropriate objects.
> You should do this before posting more code. :-)
> Bob Barrows
> Charlie J wrote:
>> Here is the line of code:
>>
>> tdBWOM.InnerHtml = sb1.ToString();
>>
>> In an attempt to isolate what is happening, I changed the html file
>> to use a html table instead of an asp:Table. I get the same result.
>>
>> I cannot get this to fail on my test system, only on the production
>> server. When the page first displays, the text I put in the cell
>> displays perfectly. There is no error. Only when I navigate to
>> another page on the site and then navigate back to this page do I get
>> the error. If you want to see the aspx page after it is generated,
>> go to www.mafe.org. It is the home page for the site (default.aspx)
>> that I am having the problem with. I currently have the line of code
>> above commented out in the code behind file. --
>> Charlie Jursch
>> Patotech Software, Inc.
>> Danville, CA
>>
>>
>> "Karl Seguin [MVP]" wrote:
>>
>>> can you show us the line of code that you comment out to make it
>>> work, and all relevant lines of code? Clearly something's null.
>>> It's easy to debug if you step through it and add a breakpoint on
>>> that line...
>>>
>>> Karl
>>>
>>> --
>>> http://www.openmymind.net/
>>> http://www.fuelindustries.com/
>>>
>>>
>>> "Charlie J" <CharlieJ@.discussions.microsoft.com> wrote in message
>>> news:F5A9B425-AF2C-45C3-AF7B-DA5DC5CBC3F8@.microsoft.com...
>>>> I have a real stumper. I added a server side table to a home page
>>>> that has two other server side tables on it that have been working
>>>> great. In Visual
>>>> Studio everything works great. When I put the page on the
>>>> production server,
>>>> the first time in the page works great. If I navigate to any other
>>>> page on
>>>> the site and then try to return to the home page the control I added
>>>> throws
>>>> the following:
>>>>
>>>> Server Error in '/' Application.
>>>> ----------------------
> ---
>>>>
>>>> Object reference not set to an instance of an object.
>>>> Description: An unhandled exception occurred during the execution
>>>> of the current web request. Please review the stack trace for more
>>>> information about
>>>> the error and where it originated in the code.
>>>>
>>>> Exception Details: System.NullReferenceException: Object reference
>>>> not set to an instance of an object.
>>>>
>>>> Source Error:
>>>>
>>>> An unhandled exception was generated during the execution of the
>>>> current web
>>>> request. Information regarding the origin and location of the
>>>> exception can
>>>> be identified using the exception stack trace below.
>>>>
>>>> Stack Trace:
>>>>
>>>>
>>>> [NullReferenceException: Object reference not set to an instance of
>>>> an object.]
>>>> MAFE.home.LoadBWOM()
>>>> MAFE.home.Page_Load(Object sender, EventArgs e)
>>>> System.Web.UI.Control.OnLoad(EventArgs e) +67
>>>> System.Web.UI.Control.LoadRecursive() +35
>>>> System.Web.UI.Page.ProcessRequestMain() +761
>>>>
>>>> If I comment out the line of code where I store a row in the new
>>>> table, all
>>>> works just fine. Anyone have any ideas?
>>>>
>>>> --
>>>> Charlie Jursch
>>>> Patotech Software, Inc.
>>>> Danville, CA
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
... which leaves unanswered the question of why one of them is null, which
can best be answered by stepping through the code (not recommended in a
production environment, but a duplicate app could be created for testing, I
suppose). If stepping is not an option, then you have to manually backtrace
the lines of code leading up to this line and see if you can identify the
failure to instantiate the object.
Karl Seguin [MVP] wrote:
> agreed.
> If that's the line, it's clear that either sb is null or tdBWOM is
> null.
> Karl
> --
> http://www.openmymind.net/
> http://www.fuelindustries.com/
>
> "Bob Barrows [MVP]" <reb01501@.NOyahoo.SPAMcom> wrote in message
> news:OUxytzFRGHA.5552@.TK2MSFTNGP14.phx.gbl...
>> You still have not shown enough code to enable us to see what's
>> happening. All I can say is that you should determine which object
>> it is complaining about: tdBWOM or sb1. Insert some code to verify
>> that both of these variables are set to the appropriate objects.
>> You should do this before posting more code. :-)
>>
>> Bob Barrows
>> Charlie J wrote:
>>> Here is the line of code:
>>>
>>> tdBWOM.InnerHtml = sb1.ToString();
>>>
>>> In an attempt to isolate what is happening, I changed the html file
>>> to use a html table instead of an asp:Table. I get the same result.
>>>
>>> I cannot get this to fail on my test system, only on the production
>>> server. When the page first displays, the text I put in the cell
>>> displays perfectly. There is no error. Only when I navigate to
>>> another page on the site and then navigate back to this page do I
>>> get the error. If you want to see the aspx page after it is
>>> generated, go to www.mafe.org. It is the home page for the site
>>> (default.aspx) that I am having the problem with. I currently have
>>> the line of code above commented out in the code behind file. --
>>> Charlie Jursch
>>> Patotech Software, Inc.
>>> Danville, CA
>>>
>>>
>>> "Karl Seguin [MVP]" wrote:
>>>
>>>> can you show us the line of code that you comment out to make it
>>>> work, and all relevant lines of code? Clearly something's null.
>>>> It's easy to debug if you step through it and add a breakpoint on
>>>> that line...
>>>>
>>>> Karl
>>>>
>>>> --
>>>> http://www.openmymind.net/
>>>> http://www.fuelindustries.com/
>>>>
>>>>
>>>> "Charlie J" <CharlieJ@.discussions.microsoft.com> wrote in message
>>>> news:F5A9B425-AF2C-45C3-AF7B-DA5DC5CBC3F8@.microsoft.com...
>>>>> I have a real stumper. I added a server side table to a home page
>>>>> that has two other server side tables on it that have been working
>>>>> great. In Visual
>>>>> Studio everything works great. When I put the page on the
>>>>> production server,
>>>>> the first time in the page works great. If I navigate to any
>>>>> other page on
>>>>> the site and then try to return to the home page the control I
>>>>> added throws
>>>>> the following:
>>>>>
>>>>> Server Error in '/' Application.
>>>>> ----------------------
--
>>>>> ---
>>>>>
>>>>> Object reference not set to an instance of an object.
>>>>> Description: An unhandled exception occurred during the execution
>>>>> of the current web request. Please review the stack trace for more
>>>>> information about
>>>>> the error and where it originated in the code.
>>>>>
>>>>> Exception Details: System.NullReferenceException: Object reference
>>>>> not set to an instance of an object.
>>>>>
>>>>> Source Error:
>>>>>
>>>>> An unhandled exception was generated during the execution of the
>>>>> current web
>>>>> request. Information regarding the origin and location of the
>>>>> exception can
>>>>> be identified using the exception stack trace below.
>>>>>
>>>>> Stack Trace:
>>>>>
>>>>>
>>>>> [NullReferenceException: Object reference not set to an instance
>>>>> of an object.]
>>>>> MAFE.home.LoadBWOM()
>>>>> MAFE.home.Page_Load(Object sender, EventArgs e)
>>>>> System.Web.UI.Control.OnLoad(EventArgs e) +67
>>>>> System.Web.UI.Control.LoadRecursive() +35
>>>>> System.Web.UI.Page.ProcessRequestMain() +761
>>>>>
>>>>> If I comment out the line of code where I store a row in the new
>>>>> table, all
>>>>> works just fine. Anyone have any ideas?
>>>>>
>>>>> --
>>>>> Charlie Jursch
>>>>> Patotech Software, Inc.
>>>>> Danville, CA
>>
>> --
>> Microsoft MVP -- ASP/ASP.NET
>> Please reply to the newsgroup. The email account listed in my From
>> header is my spam trap, so I don't check it very often. You will get
>> a quicker response by posting to the newsgroup.
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
I resolved this issue by upgrading the application to APS.NET 2.0. This all
started to happen right after I had installed 2.0 on the servers. I cannot
explain why it was happening, only that after I converted the application to
2.0 everything started to work normally.
Thanks for your assistance.
--
Charlie Jursch
Patotech Software, Inc.
Danville, CA
"Charlie J" wrote:
> I have a real stumper. I added a server side table to a home page that has
> two other server side tables on it that have been working great. In Visual
> Studio everything works great. When I put the page on the production server,
> the first time in the page works great. If I navigate to any other page on
> the site and then try to return to the home page the control I added throws
> the following:
> Server Error in '/' Application.
> ------------------------
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of the
> current web request. Please review the stack trace for more information about
> the error and where it originated in the code.
> Exception Details: System.NullReferenceException: Object reference not set
> to an instance of an object.
> Source Error:
> An unhandled exception was generated during the execution of the current web
> request. Information regarding the origin and location of the exception can
> be identified using the exception stack trace below.
> Stack Trace:
>
> [NullReferenceException: Object reference not set to an instance of an
> object.]
> MAFE.home.LoadBWOM()
> MAFE.home.Page_Load(Object sender, EventArgs e)
> System.Web.UI.Control.OnLoad(EventArgs e) +67
> System.Web.UI.Control.LoadRecursive() +35
> System.Web.UI.Page.ProcessRequestMain() +761
> If I comment out the line of code where I store a row in the new table, all
> works just fine. Anyone have any ideas?
> --
> Charlie Jursch
> Patotech Software, Inc.
> Danville, CA
object reference not set to an instance of an object
I'm getting this error saying that Server Error 'in
'/mcsdWebApps/Chapter5/DBruntime' Application.
Object reference not set to an instance of an object. It says the error is
on line 39 which is
Dim rowInsert As DataRow = dsContacts.Tables("Contacts").NewRow
Thanks in advance for any help!
Here is the full code:
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e as System.EventArgs) Handles MyBase.Load
'1. Create the data connection.
Dim ContactMgmt As New SqlConnection _
(" Server=(local);database=Contacts;Trusted
_Connection=yes")
'Create an adapter.
Dim adptContactMgmt As New _
SqlDataAdapter("select * from Contacts", ContactMgmt)
'2. Create a data set.
Dim dsContacts As New DataSet()
'Set select command.
adptContactMgmt.SelectCommand.CommandText = _
"SELECT * FROM Contacts"
'3. Create, insert, delete, and update commands automatically.
Dim cmdContactMgmt As SqlCommandBuilder = New _
SqlCommandBuilder(adptContactMgmt)
'4. Create a new row.
'HERE'S WHERE I'M GETTING THE ERROR!
Dim rowInsert as DataRow = dsContacts.Tables("Contacts").NewRow
'Add data to fields in the row.
rowInsert("ContactId") = 3
rowInsert("FirstName") = "Mary"
rowInsert("LastName") = "Smith"
rowInsert("WorkPhone") = "(444) 222-2222"
'Add the row to the data set.
dsContacts.Tables("Contacts").Rows.Add(rowInsert)
'5. Update the database.
adptContactMgmt.Update(dsContacts.Tables("Contacts"))
End SubHi,
The problem is that you have not filled your dataset so the dataset does not
have a table called Contacts.
Here is a modified version of the code that should get you going.
Private Sub Page_Load(ByVal sender As System.Object, _
ByVal e as System.EventArgs) Handles MyBase.Load
'1. Create the data connection.
Dim ContactMgmt As New SqlConnection _
(" Server=(local);database=Contacts;Trusted
_Connection=yes")
'Create an adapter.
Dim adptContactMgmt As New _
SqlDataAdapter("select * from Contacts", ContactMgmt)
'2. Create a data set.
Dim dsContacts As New DataSet()
'Set select command. This is not needed since this was set when you
constructed the SqlDataAdapter
'3. Create, insert, delete, and update commands automatically.
Dim cmdContactMgmt As SqlCommandBuilder = New _
SqlCommandBuilder(adptContactMgmt)
'*** The missing part, Fill the dataset using the DataAdapter and pass the
table name that you want
' the DataAdapter to use.
adptContactMgmt.Fill(dsContacts, "Contacts")
'4. Create a new row.
Dim rowInsert as DataRow = dsContacts.Tables("Contacts").NewRow
'Add data to fields in the row.
rowInsert("ContactId") = 3
rowInsert("FirstName") = "Mary"
rowInsert("LastName") = "Smith"
rowInsert("WorkPhone") = "(444) 222-2222"
'Add the row to the data set.
dsContacts.Tables("Contacts").Rows.Add(rowInsert)
'5. Update the database.
adptContactMgmt.Update(dsContacts.Tables("Contacts"))
End Sub
Hope this helps
Chris Taylor
http://dotnetjunkies.com/weblog/chris.taylor
"student" <mr_chat123@.yahoo.com> wrote in message
news:24HBd.9293$by5.9098@.newssvr19.news.prodigy.com...
> Hello all, I have this problem in this code I am studying.
> I'm getting this error saying that Server Error 'in
> '/mcsdWebApps/Chapter5/DBruntime' Application.
> Object reference not set to an instance of an object. It says the error is
> on line 39 which is
> Dim rowInsert As DataRow = dsContacts.Tables("Contacts").NewRow
> Thanks in advance for any help!
> Here is the full code:
> Private Sub Page_Load(ByVal sender As System.Object, _
> ByVal e as System.EventArgs) Handles MyBase.Load
> '1. Create the data connection.
> Dim ContactMgmt As New SqlConnection _
> (" Server=(local);database=Contacts;Trusted
_Connection=yes")
> 'Create an adapter.
> Dim adptContactMgmt As New _
> SqlDataAdapter("select * from Contacts", ContactMgmt)
> '2. Create a data set.
> Dim dsContacts As New DataSet()
> 'Set select command.
> adptContactMgmt.SelectCommand.CommandText = _
> "SELECT * FROM Contacts"
> '3. Create, insert, delete, and update commands automatically.
> Dim cmdContactMgmt As SqlCommandBuilder = New _
> SqlCommandBuilder(adptContactMgmt)
> '4. Create a new row.
> 'HERE'S WHERE I'M GETTING THE ERROR!
> Dim rowInsert as DataRow = dsContacts.Tables("Contacts").NewRow
> 'Add data to fields in the row.
> rowInsert("ContactId") = 3
> rowInsert("FirstName") = "Mary"
> rowInsert("LastName") = "Smith"
> rowInsert("WorkPhone") = "(444) 222-2222"
> 'Add the row to the data set.
> dsContacts.Tables("Contacts").Rows.Add(rowInsert)
> '5. Update the database.
> adptContactMgmt.Update(dsContacts.Tables("Contacts"))
> End Sub
>
Thanks for the help that got rid of the error, only now I'm getting a blank
screen when I view the code in a browser Internet Explorer, any idea as to
what is causing this'
thanks,
student
"Chris Taylor" <chris_taylor_za@.hotmail.com> wrote in message
news:%23TeGJtG8EHA.2700@.TK2MSFTNGP14.phx.gbl...
> Hi,
> The problem is that you have not filled your dataset so the dataset does
not
> have a table called Contacts.
> Here is a modified version of the code that should get you going.
> Private Sub Page_Load(ByVal sender As System.Object, _
> ByVal e as System.EventArgs) Handles MyBase.Load
> '1. Create the data connection.
> Dim ContactMgmt As New SqlConnection _
> (" Server=(local);database=Contacts;Trusted
_Connection=yes")
> 'Create an adapter.
> Dim adptContactMgmt As New _
> SqlDataAdapter("select * from Contacts", ContactMgmt)
> '2. Create a data set.
> Dim dsContacts As New DataSet()
> 'Set select command. This is not needed since this was set when you
> constructed the SqlDataAdapter
> '3. Create, insert, delete, and update commands automatically.
> Dim cmdContactMgmt As SqlCommandBuilder = New _
> SqlCommandBuilder(adptContactMgmt)
> '*** The missing part, Fill the dataset using the DataAdapter and pass
the
> table name that you want
> ' the DataAdapter to use.
> adptContactMgmt.Fill(dsContacts, "Contacts")
> '4. Create a new row.
> Dim rowInsert as DataRow = dsContacts.Tables("Contacts").NewRow
> 'Add data to fields in the row.
> rowInsert("ContactId") = 3
> rowInsert("FirstName") = "Mary"
> rowInsert("LastName") = "Smith"
> rowInsert("WorkPhone") = "(444) 222-2222"
> 'Add the row to the data set.
> dsContacts.Tables("Contacts").Rows.Add(rowInsert)
> '5. Update the database.
> adptContactMgmt.Update(dsContacts.Tables("Contacts"))
> End Sub
>
> Hope this helps
> --
> Chris Taylor
> http://dotnetjunkies.com/weblog/chris.taylor
> "student" <mr_chat123@.yahoo.com> wrote in message
> news:24HBd.9293$by5.9098@.newssvr19.news.prodigy.com...
is
>
Hi,
I do not see what data control you are using, but one thing with ASP.NET is
that once you have setup the databinding you have to call DataBind()
otherwise no binding happens.
Hope this helps
Chris Taylor
http://dotnetjunkies.com/weblog/chris.taylor
"student" <mr_chat123@.yahoo.com> wrote in message
news:ZQ_Bd.9661$by5.495@.newssvr19.news.prodigy.com...
> Thanks for the help that got rid of the error, only now I'm getting a
blank
> screen when I view the code in a browser Internet Explorer, any idea as to
> what is causing this'
> thanks,
> student
> "Chris Taylor" <chris_taylor_za@.hotmail.com> wrote in message
> news:%23TeGJtG8EHA.2700@.TK2MSFTNGP14.phx.gbl...
> not
> the
error
> is
>
object reference not set to an instance of an object
I looked up posts on how to get a javascript confirm on the onclick of a
button to determine whether to run server code and i wrote this on the page
load..
string jsalert = "java script:if(confirm ('Is the employee a rehire?') ==
false) return false";
btnEdit.Attributes["onclick"]=jsalert;
however I'm getting the error message in my subject heading. what have i
done wrong? when i start to write it i get intellisense so i know it
recognises btnEdit.Hi,
Make sure in your HTML that your id tag is exactly "btnEdit" with the
correct case. You receive it in intellisense because it is declared in your
code behind which doesn't necessarily mean it is in your .aspx file. Good
luck! Ken.
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.
"louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
message news:25C2CE14-0C92-41CC-B349-4F82055E0336@.microsoft.com...
> hi there,
> I looked up posts on how to get a javascript confirm on the onclick of a
> button to determine whether to run server code and i wrote this on the
page
> load..
> string jsalert = "java script:if(confirm ('Is the employee a rehire?') ==
> false) return false";
> btnEdit.Attributes["onclick"]=jsalert;
> however I'm getting the error message in my subject heading. what have i
> done wrong? when i start to write it i get intellisense so i know it
> recognises btnEdit.
Try the following:
btnEdit.Attributes.Add("onclick", jsalert);
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
message news:25C2CE14-0C92-41CC-B349-4F82055E0336@.microsoft.com...
> hi there,
> I looked up posts on how to get a javascript confirm on the onclick of a
> button to determine whether to run server code and i wrote this on the
page
> load..
> string jsalert = "java script:if(confirm ('Is the employee a rehire?') ==
> false) return false";
> btnEdit.Attributes["onclick"]=jsalert;
> however I'm getting the error message in my subject heading. what have i
> done wrong? when i start to write it i get intellisense so i know it
> recognises btnEdit.
hiya. yes. its as btnEdit in both my aspx, my declarations and my code ?
"Ken Dopierala Jr." wrote:
> Hi,
> Make sure in your HTML that your id tag is exactly "btnEdit" with the
> correct case. You receive it in intellisense because it is declared in yo
ur
> code behind which doesn't necessarily mean it is in your .aspx file. Good
> luck! Ken.
> --
> Ken Dopierala Jr.
> For great ASP.Net web hosting try:
> http://www.webhost4life.com/default.asp?refid=Spinlight
> If you sign up under me and need help, email me.
> "louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
> message news:25C2CE14-0C92-41CC-B349-4F82055E0336@.microsoft.com...
> page
>
>
yes i did actually try that syntax. same error message:
System.NullReferenceException: Object reference not set to an instance of an
object
"louise raisbeck" wrote:
> hi there,
> I looked up posts on how to get a javascript confirm on the onclick of a
> button to determine whether to run server code and i wrote this on the pag
e
> load..
> string jsalert = "java script:if(confirm ('Is the employee a rehire?') ==
> false) return false";
> btnEdit.Attributes["onclick"]=jsalert;
> however I'm getting the error message in my subject heading. what have i
> done wrong? when i start to write it i get intellisense so i know it
> recognises btnEdit.
Hi,
Do you have the runat="server" tag in your btnEdit? Also, where and when
are you getting the error? Are you sure it happens on the
btnEdit.Attributes line? Also I would definitely switch your syntax to what
Kevin showed, that's how I've always done it. Try commenting out the
attributes line and do something else with the button. Like btnEdit.Visible
= True, if this gives you the same error then there is a problem with either
your button tag or your button declaration, if no error then we have
narrowed it down to how you are adding your attribute. Good luck! Ken.
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.
"louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
message news:3728851E-41F0-4369-81A1-6181B8FFA60D@.microsoft.com...
> yes i did actually try that syntax. same error message:
> System.NullReferenceException: Object reference not set to an instance of
an
> object
> "louise raisbeck" wrote:
>
page
Well, Louise, you have 2 possibilities:
btnEdit is Null;
btnEdit.Attributes is null;
What exactly IS "btnEdit?"
--
HTH,
Kevin Spencer
.Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
message news:3728851E-41F0-4369-81A1-6181B8FFA60D@.microsoft.com...
> yes i did actually try that syntax. same error message:
> System.NullReferenceException: Object reference not set to an instance of
an
> object
> "louise raisbeck" wrote:
>
page
Object reference not set to an instance of an object
<%@dotnet.itags.org. Page Language="VB" Debug="True" CodePage="28599" %>
<%@dotnet.itags.org. Import NameSpace="System.Data" %>
<script runat="server">
Sub Page_Load(Obj As Object,E As EventArgs)
'DataSet Nesnesini Olustur -------
Dim ds as new DataSet("ornek_dataset")
'Tablo Olustur-----------
Dim musteritable as New DataTable("müsteriler")
'Tabloya Sutunlar Ekle--------
musteritable.Columns.Add ("ad",System.Type.GetType("System.String"))
musteritable.Columns.Add ("soyad",System.Type.GetType("System.String"))
musteritable.Columns.Add ("meslek",System.Type.GetType("System.String"))
musteritable.Columns.Add ("yas",System.Type.GetType("System.Int32"))
'Tabloyu DataSete Ekle --------
ds.Tables.Add(musteritable)
'Satir Olusturup, Veri Gir-------
Dim sira As DataRow = musteritable.NewRow
sira("ad")="Zafer"
sira("soyad")="Demirkol"
sira("meslek")="Web Programcýsý"
sira("yas")="33"
musteritable.rows.Add(sira)
Dim sira1 As DataRow = musteritable.NewRow
sira("ad")="Serdar"
sira("soyad")="Benli"
sira("meslek")="Pazarlamacý"
sira("yas")="32"
musteritable.rows.Add(sira1)
Dim sira2 As DataRow = musteritable.NewRow
sira("ad")="Denizhan"
sira("soyad")="Akkaya"
sira("meslek")="Muhasebeci"
sira("yas")="26"
musteritable.rows.Add(sira2)
Dim sira3 As DataRow = musteritable.NewRow
sira("ad")="Levent"
sira("soyad")="Demirkol"
sira("meslek")="Aþcý"
sira("yas")="28"
musteritable.rows.Add(sira3)
'----~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-----
Response.Write(ds.Tables("musteriler").rows(2)("ad") & "<br>")
Dim satir_3 As Datarow
satir_3 = ds.Tables("musteriler").rows(2)
Response.Write(satir_3(0) & "<br>")
Dim siralar As DataRowCollection
siralar=ds.Tables("musteriler").rows
Response.Write(siralar(2)("ad") & "<br>")
Dim tablo_degiskenim As DataTable
tablo_degiskenim = ds.Tables("musteriler")
Response.Write(tablo_degiskenim.rows(2)(0) & "<br>")
End sub
</script
AND THE ERROR PAGE;
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not set to an instance of an object.
Source Error:
Line 43: musteritable.rows.Add(sira3)
Line 44: '----~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~-----
Line 45: Response.Write(ds.Tables("musteriler").rows(2)("ad") & "<br>")
Line 46:
Line 47: Dim satir_3 As Datarow
Source File: D:\ASP.NET\dataset_olustur2.aspx Line: 45
I COULDN'T SEE THE MISTAKE, CAN YOU HELP ME?
THANX ...When you created the table, you called it "müsteriler".
Then, when you referenced it on Line 45, you called it "musteriler" ... with no accent ...
Oh yeah ! :)
...
I am bad at my native-lang "Turkish" just like I am bad at English ...
ü is a fuckin' letter in our keyboards ...
...
Thanx NewKid2 ...
If you find this happening too often, considerchanging the language of your computer.
Object reference not set to an instance of an object
here is my code.. i am trying to get the zipcode information from an active directory server
<%
Dim entry As New DirectoryServices.DirectoryEntry("LDAP://schpdc")
Dim Dsearch As New DirectoryServices.DirectorySearcher(entry)
Dim zip As String
Dim UserName As String
Dim testname As String
zip = "error"
UserName = System.Security.Principal.WindowsIdentity.GetCurrent().Name.Split("\")(1)
Response.Write(UserName & "<br>")
Dsearch.Filter = "(cn=" + UserName + ")"
Response.Write(Dsearch.Filter)
Try
zip = Dsearch.FindOne.Properties("zipcode").ToString()
Catch E As Exception
zip = "Error: " & E.Message
End Try
Response.Write(zip)
%>
please help.. i am now just spinning my wheels!!!
Which line is throwing the error?
To be honest i am not sure what is causing the error.. however i am pretty sure it is in the try statement as that is what actually writes it out and it always runs the catch. (sorry for the delay in reply.. i was sick yesterday)
Put breakPoint to debud the error. Usually, the error happened in Name.Split("\")(1) or Properties("zipcode").ToString(). Because you already put try.. catch for Properties("zipcode").ToString(), I am afraid the error was caused by Name.Split("\")(1).
i dont think that is the case.. i added a line to make the username = to the full return (instead of the split return) here is what i get
FORTITECH\intranet
intranet
(& (objectClass=user)(cn=intranet))Error: Object reference not set to an instance of an object.
the first line is the return unsplit user name... the second is the split user name (the user whos AD values i want returned)
line 3 is split a little all return within the () is the Dsearch.Filter and everything after is from the try statement (the catch side of course).
You know Try..Catch, right? Therefore, the error should happen before TRY. Put breakpoint at the line before Try, then debug it step by step, you should be easy to find which line caused the error.
this will probably sound incredibly stupid but i am working on a dotnetnuke module and can not find anyway to run this outside of a web browser. web developer 05 allows me to add breakpoints but will not let me run the code independently...
Try to comment out line one by one. Start from Response.Write(Dsearch.Filter). You will find the line that causes the error.
if i dont declare a dsearch.filter i get the following
(objectClass=*)Error: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index
it looks as though either this line isnt pulling the right row...
Dsearch.Filter = "(& (objectClass=user)(cn=" + UserName + "))"
or this line isnt referring to a proper column
Dsearch.FindOne.Properties("postalCode")(0).ToString()
do you know a way to return the entire row? if so i could narrow it down to the first line... hopefully
I did Active Directory project long time before, I had some code as following:
search.Filter = "(SAMAccountName=" + userName + ")";
search.PropertiesToLoad.Add("cn");
SearchResult result = search.FindOne();
if(null == result)
{
return false;
}
// Update the new path to the user in the directory
_path = result.Path;
_filterAttribute = (String)result.Properties["cn"][0];
Please search Active Directory and ASP.NET online to find helps.
could you walk me through this please?
Did you check to make sure zip code in AD called "ZipCode"? I though it called "postalCode".
Also, here is the forum on Active Directory. Please search your issue here.
http://forums.asp.net/93.aspx
i have tried both. neither seemed to work as a direct replacement.
che3358:
Did you check to make sure zip code in AD called "ZipCode"? I though it called "postalCode".
Do you know what the login name property is called within active directory?
Saturday, March 24, 2012
Object reference not set to an instance of an object
My application works fine on the localhost but spits this error as soon
as I put it on the server. I know this error occurs when an object has
not been instantiated prior to a reference, but why shouldn't it happen
in the localhost?
Here's what the the whole error msg looks like:
Server Error in '/' Application.
----
--
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Auction002.login.UserExists() in
C:\Inetpub\wwwroot\Auction002\login.aspx.vb:82
Auction002.login.btnLogin_Click(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\Auction002\login.aspx.vb:54
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePo
stBackEvent(String
eventArgument) +57
System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1292
----
--
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300
I'll really appreciate any help.
thanxHi nemo,
I cannot answer why it would happen in one environment and not in another,
as I have no idea what sort of object is being used, and for what purpose.
Neither do I know what may be different about the 2 environments or the 2
applications. Assuming that the applications are identical (and for me that
is a large assumption), it would have to be something about how the
application interacts with the enviroment.
One (of many) guess I could take would be that your app is logging in the
user with some sort of external dependency, either on Active Directory,
local machine users, or a database. Perhaps something is preventing access
to the external resource.
I would suggest you take a look at
C:\Inetpub\wwwroot\Auction002\login.aspx.vb:82
Auction002.login.btnLogin_Click(Object sender, EventArgs e)
This would be line 82 in that code file. Figure out what object references
are there, and which of them might or might not exist. If you have Visual
Studio.Net, you can set a break point there and examine the objects that are
in use. Otherwise, you can use Try/Catch to catch the exception, and perhaps
log the details of it to the Event Log.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Paranoia is just a state of mind.
"nemo" <pallabs@.gmail.com> wrote in message
news:1125329035.242227.112120@.g47g2000cwa.googlegroups.com...
> Hi,
> My application works fine on the localhost but spits this error as soon
> as I put it on the server. I know this error occurs when an object has
> not been instantiated prior to a reference, but why shouldn't it happen
> in the localhost?
> Here's what the the whole error msg looks like:
>
> Server Error in '/' Application.
> ----
--
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of
> the current web request. Please review the stack trace for more
> information about the error and where it originated in the code.
> Exception Details: System.NullReferenceException: Object reference not
> set to an instance of an object.
> Source Error:
> An unhandled exception was generated during the execution of the
> current web request. Information regarding the origin and location of
> the exception can be identified using the exception stack trace below.
>
> Stack Trace:
>
> [NullReferenceException: Object reference not set to an instance of an
> object.]
> Auction002.login.UserExists() in
> C:\Inetpub\wwwroot\Auction002\login.aspx.vb:82
> Auction002.login.btnLogin_Click(Object sender, EventArgs e) in
> C:\Inetpub\wwwroot\Auction002\login.aspx.vb:54
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
> System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.Raise
PostBackEvent(String
> eventArgument) +57
> System.Web.UI.Page. RaisePostBackEvent(IPostBackEventHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData)
> +33
> System.Web.UI.Page.ProcessRequestMain() +1292
>
> ----
--
> Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
> ASP.NET Version:1.1.4322.2300
>
> I'll really appreciate any help.
> thanx
>
Thanks for your response Kevin. Yes the applications are identical and
I'm indeed using VS.Net. I checked line 82 in the file where the error
is occuring and here's the code:
Dim i, j As Integer
Dim UserArray() As String
UserArray = Application("userarray")
j = UserArray.Length <-- this is line 82
I have defined the application variable "userarray" in the
"Application_Start" subroutine in the global.asax file before it
reaches the above code.
Still wondering why this should not be a problem in localhost but would
in the server.
thanx
Hi nemo,
In that case, the problem lies in your setting of the
Applcation("userarray") in the Application_Start. Apparently, something is
preventing it from being created. It is probably null.
HTH,
Kevin Spencer
Microsoft MVP
.Net Developer
Paranoia is just a state of mind.
"nemo" <pallabs@.gmail.com> wrote in message
news:1125333765.190206.275700@.o13g2000cwo.googlegroups.com...
> Thanks for your response Kevin. Yes the applications are identical and
> I'm indeed using VS.Net. I checked line 82 in the file where the error
> is occuring and here's the code:
> Dim i, j As Integer
> Dim UserArray() As String
> UserArray = Application("userarray")
> j = UserArray.Length <-- this is line 82
>
> I have defined the application variable "userarray" in the
> "Application_Start" subroutine in the global.asax file before it
> reaches the above code.
> Still wondering why this should not be a problem in localhost but would
> in the server.
> thanx
>
object reference not set to an instance of an object
I looked up posts on how to get a javascript confirm on the onclick of a
button to determine whether to run server code and i wrote this on the page
load..
string jsalert = "javascript:if(confirm ('Is the employee a rehire?') ==
false) return false";
btnEdit.Attributes["onclick"]=jsalert;
however I'm getting the error message in my subject heading. what have i
done wrong? when i start to write it i get intellisense so i know it
recognises btnEdit.Hi,
Make sure in your HTML that your id tag is exactly "btnEdit" with the
correct case. You receive it in intellisense because it is declared in your
code behind which doesn't necessarily mean it is in your .aspx file. Good
luck! Ken.
--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.
"louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
message news:25C2CE14-0C92-41CC-B349-4F82055E0336@.microsoft.com...
> hi there,
> I looked up posts on how to get a javascript confirm on the onclick of a
> button to determine whether to run server code and i wrote this on the
page
> load..
> string jsalert = "javascript:if(confirm ('Is the employee a rehire?') ==
> false) return false";
> btnEdit.Attributes["onclick"]=jsalert;
> however I'm getting the error message in my subject heading. what have i
> done wrong? when i start to write it i get intellisense so i know it
> recognises btnEdit.
Try the following:
btnEdit.Attributes.Add("onclick", jsalert);
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
message news:25C2CE14-0C92-41CC-B349-4F82055E0336@.microsoft.com...
> hi there,
> I looked up posts on how to get a javascript confirm on the onclick of a
> button to determine whether to run server code and i wrote this on the
page
> load..
> string jsalert = "javascript:if(confirm ('Is the employee a rehire?') ==
> false) return false";
> btnEdit.Attributes["onclick"]=jsalert;
> however I'm getting the error message in my subject heading. what have i
> done wrong? when i start to write it i get intellisense so i know it
> recognises btnEdit.
hiya. yes. its as btnEdit in both my aspx, my declarations and my code ?
"Ken Dopierala Jr." wrote:
> Hi,
> Make sure in your HTML that your id tag is exactly "btnEdit" with the
> correct case. You receive it in intellisense because it is declared in your
> code behind which doesn't necessarily mean it is in your .aspx file. Good
> luck! Ken.
> --
> Ken Dopierala Jr.
> For great ASP.Net web hosting try:
> http://www.webhost4life.com/default.asp?refid=Spinlight
> If you sign up under me and need help, email me.
> "louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
> message news:25C2CE14-0C92-41CC-B349-4F82055E0336@.microsoft.com...
> > hi there,
> > I looked up posts on how to get a javascript confirm on the onclick of a
> > button to determine whether to run server code and i wrote this on the
> page
> > load..
> > string jsalert = "javascript:if(confirm ('Is the employee a rehire?') ==
> > false) return false";
> > btnEdit.Attributes["onclick"]=jsalert;
> > however I'm getting the error message in my subject heading. what have i
> > done wrong? when i start to write it i get intellisense so i know it
> > recognises btnEdit.
>
yes i did actually try that syntax. same error message:
System.NullReferenceException: Object reference not set to an instance of an
object
"louise raisbeck" wrote:
> hi there,
> I looked up posts on how to get a javascript confirm on the onclick of a
> button to determine whether to run server code and i wrote this on the page
> load..
> string jsalert = "javascript:if(confirm ('Is the employee a rehire?') ==
> false) return false";
> btnEdit.Attributes["onclick"]=jsalert;
> however I'm getting the error message in my subject heading. what have i
> done wrong? when i start to write it i get intellisense so i know it
> recognises btnEdit.
Hi,
Do you have the runat="server" tag in your btnEdit? Also, where and when
are you getting the error? Are you sure it happens on the
btnEdit.Attributes line? Also I would definitely switch your syntax to what
Kevin showed, that's how I've always done it. Try commenting out the
attributes line and do something else with the button. Like btnEdit.Visible
= True, if this gives you the same error then there is a problem with either
your button tag or your button declaration, if no error then we have
narrowed it down to how you are adding your attribute. Good luck! Ken.
--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.
"louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
message news:3728851E-41F0-4369-81A1-6181B8FFA60D@.microsoft.com...
> yes i did actually try that syntax. same error message:
> System.NullReferenceException: Object reference not set to an instance of
an
> object
> "louise raisbeck" wrote:
> > hi there,
> > I looked up posts on how to get a javascript confirm on the onclick of a
> > button to determine whether to run server code and i wrote this on the
page
> > load..
> > string jsalert = "javascript:if(confirm ('Is the employee a rehire?') ==
> > false) return false";
> > btnEdit.Attributes["onclick"]=jsalert;
> > however I'm getting the error message in my subject heading. what have i
> > done wrong? when i start to write it i get intellisense so i know it
> > recognises btnEdit.
Well, Louise, you have 2 possibilities:
btnEdit is Null;
btnEdit.Attributes is null;
What exactly IS "btnEdit?"
--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
Neither a follower
nor a lender be.
"louise raisbeck" <louiseraisbeck@.discussions.microsoft.com> wrote in
message news:3728851E-41F0-4369-81A1-6181B8FFA60D@.microsoft.com...
> yes i did actually try that syntax. same error message:
> System.NullReferenceException: Object reference not set to an instance of
an
> object
> "louise raisbeck" wrote:
> > hi there,
> > I looked up posts on how to get a javascript confirm on the onclick of a
> > button to determine whether to run server code and i wrote this on the
page
> > load..
> > string jsalert = "javascript:if(confirm ('Is the employee a rehire?') ==
> > false) return false";
> > btnEdit.Attributes["onclick"]=jsalert;
> > however I'm getting the error message in my subject heading. what have i
> > done wrong? when i start to write it i get intellisense so i know it
> > recognises btnEdit.
Object reference not set to an instance of an object
I want to access in code-behind a label within the ItemTemplate of a
Formview.
<asp:FormView ID="FormView1" runat="server" DataKeyNames="id"
DataSourceID="SqlDataSource1" >
<ItemTemplate>
<asp:Label ID="nameLabel" runat="server" Text='<%# Bind("name")
%>'></asp:Label>
code-behind:
Dim name As String = CType(FormView1.FindControl("nameLabel"), Label).Text
I get the error: "Object reference not set to an instance of an object"
Could somebody tell me what's wrong in my code?
Thanks
BenTry
FormView1.Row.FindControl(...)
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net
"Ben" <b@.bnwrote in message
news:%23obfXb8tHHA.3364@.TK2MSFTNGP02.phx.gbl...
Quote:
Originally Posted by
Hi,
>
I want to access in code-behind a label within the ItemTemplate of a
Formview.
>
<asp:FormView ID="FormView1" runat="server" DataKeyNames="id"
DataSourceID="SqlDataSource1" >
<ItemTemplate>
<asp:Label ID="nameLabel" runat="server" Text='<%# Bind("name")
%>'></asp:Label>
>
code-behind:
Dim name As String = CType(FormView1.FindControl("nameLabel"), Label).Text
>
>
I get the error: "Object reference not set to an instance of an object"
>
Could somebody tell me what's wrong in my code?
Thanks
Ben
>
>
>
On Jun 26, 2:06 pm, "Eliyahu Goldin"
<REMOVEALLCAPITALSeEgGoldD...@.mMvVpPsS.orgwrote:
Quote:
Originally Posted by
Try
>
FormView1.Row.FindControl(...)
>
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]http://msmvps.com/blogs/egoldinhttp://usableasp.net
>
"Ben" <b@.bnwrote in message
>
news:%23obfXb8tHHA.3364@.TK2MSFTNGP02.phx.gbl...
>
Quote:
Originally Posted by
Hi,
>
Quote:
Originally Posted by
I want to access in code-behind a label within the ItemTemplate of a
Formview.
>
Quote:
Originally Posted by
<asp:FormView ID="FormView1" runat="server" DataKeyNames="id"
DataSourceID="SqlDataSource1" >
<ItemTemplate>
<asp:Label ID="nameLabel" runat="server" Text='<%# Bind("name")
%>'></asp:Label>
>
Quote:
Originally Posted by
code-behind:
Dim name As String = CType(FormView1.FindControl("nameLabel"), Label).Text
>
Quote:
Originally Posted by
I get the error: "Object reference not set to an instance of an object"
>
Quote:
Originally Posted by
Could somebody tell me what's wrong in my code?
Thanks
Ben
hi
,
if (FormView1.DefaultMode == FormViewMode.ReadOnly)
{
Label lbl = (Label) FormView1.FindControl("nameLabel");
}
thanks
Masudur
As a general rule, it's a good idea to break up the statements in a single
line multi-expression code line into their own lines of code to facilitate
setting breakpoints and being able to examine values. The way you have it
now, it would be extremely difficult to tell what is going on.
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
BlogMetaFinder(BETA): http://www.blogmetafinder.com
"Ben" wrote:
Quote:
Originally Posted by
Hi,
>
I want to access in code-behind a label within the ItemTemplate of a
Formview.
>
<asp:FormView ID="FormView1" runat="server" DataKeyNames="id"
DataSourceID="SqlDataSource1" >
<ItemTemplate>
<asp:Label ID="nameLabel" runat="server" Text='<%# Bind("name")
%>'></asp:Label>
>
code-behind:
Dim name As String = CType(FormView1.FindControl("nameLabel"), Label).Text
>
>
I get the error: "Object reference not set to an instance of an object"
>
Could somebody tell me what's wrong in my code?
Thanks
Ben
>
>
>
>
Object reference not set to an instance of an object
My application works fine on the localhost but spits this error as soon
as I put it on the server. I know this error occurs when an object has
not been instantiated prior to a reference, but why shouldn't it happen
in the localhost?
Here's what the the whole error msg looks like:
Server Error in '/' Application.
------------------------
Object reference not set to an instance of an object.
Description: An unhandled exception occurred during the execution of
the current web request. Please review the stack trace for more
information about the error and where it originated in the code.
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
An unhandled exception was generated during the execution of the
current web request. Information regarding the origin and location of
the exception can be identified using the exception stack trace below.
Stack Trace:
[NullReferenceException: Object reference not set to an instance of an
object.]
Auction002.login.UserExists() in
C:\Inetpub\wwwroot\Auction002\login.aspx.vb:82
Auction002.login.btnLogin_Click(Object sender, EventArgs e) in
C:\Inetpub\wwwroot\Auction002\login.aspx.vb:54
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
eventArgument) +57
System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
sourceControl, String eventArgument) +18
System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
+33
System.Web.UI.Page.ProcessRequestMain() +1292
------------------------
Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
ASP.NET Version:1.1.4322.2300
I'll really appreciate any help.
thanxHi nemo,
I cannot answer why it would happen in one environment and not in another,
as I have no idea what sort of object is being used, and for what purpose.
Neither do I know what may be different about the 2 environments or the 2
applications. Assuming that the applications are identical (and for me that
is a large assumption), it would have to be something about how the
application interacts with the enviroment.
One (of many) guess I could take would be that your app is logging in the
user with some sort of external dependency, either on Active Directory,
local machine users, or a database. Perhaps something is preventing access
to the external resource.
I would suggest you take a look at
C:\Inetpub\wwwroot\Auction002\login.aspx.vb:82
Auction002.login.btnLogin_Click(Object sender, EventArgs e)
This would be line 82 in that code file. Figure out what object references
are there, and which of them might or might not exist. If you have Visual
Studio.Net, you can set a break point there and examine the objects that are
in use. Otherwise, you can use Try/Catch to catch the exception, and perhaps
log the details of it to the Event Log.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Paranoia is just a state of mind.
"nemo" <pallabs@.gmail.com> wrote in message
news:1125329035.242227.112120@.g47g2000cwa.googlegr oups.com...
> Hi,
> My application works fine on the localhost but spits this error as soon
> as I put it on the server. I know this error occurs when an object has
> not been instantiated prior to a reference, but why shouldn't it happen
> in the localhost?
> Here's what the the whole error msg looks like:
>
> Server Error in '/' Application.
> ------------------------
> Object reference not set to an instance of an object.
> Description: An unhandled exception occurred during the execution of
> the current web request. Please review the stack trace for more
> information about the error and where it originated in the code.
> Exception Details: System.NullReferenceException: Object reference not
> set to an instance of an object.
> Source Error:
> An unhandled exception was generated during the execution of the
> current web request. Information regarding the origin and location of
> the exception can be identified using the exception stack trace below.
>
> Stack Trace:
>
> [NullReferenceException: Object reference not set to an instance of an
> object.]
> Auction002.login.UserExists() in
> C:\Inetpub\wwwroot\Auction002\login.aspx.vb:82
> Auction002.login.btnLogin_Click(Object sender, EventArgs e) in
> C:\Inetpub\wwwroot\Auction002\login.aspx.vb:54
> System.Web.UI.WebControls.Button.OnClick(EventArgs e) +108
> System.Web.UI.WebControls.Button.System.Web.UI.IPo stBackEventHandler.RaisePostBackEvent(String
> eventArgument) +57
> System.Web.UI.Page.RaisePostBackEvent(IPostBackEve ntHandler
> sourceControl, String eventArgument) +18
> System.Web.UI.Page.RaisePostBackEvent(NameValueCol lection postData)
> +33
> System.Web.UI.Page.ProcessRequestMain() +1292
>
> ------------------------
> Version Information: Microsoft .NET Framework Version:1.1.4322.2300;
> ASP.NET Version:1.1.4322.2300
>
> I'll really appreciate any help.
> thanx
Thanks for your response Kevin. Yes the applications are identical and
I'm indeed using VS.Net. I checked line 82 in the file where the error
is occuring and here's the code:
Dim i, j As Integer
Dim UserArray() As String
UserArray = Application("userarray")
j = UserArray.Length <-- this is line 82
I have defined the application variable "userarray" in the
"Application_Start" subroutine in the global.asax file before it
reaches the above code.
Still wondering why this should not be a problem in localhost but would
in the server.
thanx
Hi nemo,
In that case, the problem lies in your setting of the
Applcation("userarray") in the Application_Start. Apparently, something is
preventing it from being created. It is probably null.
--
HTH,
Kevin Spencer
Microsoft MVP
..Net Developer
Paranoia is just a state of mind.
"nemo" <pallabs@.gmail.com> wrote in message
news:1125333765.190206.275700@.o13g2000cwo.googlegr oups.com...
> Thanks for your response Kevin. Yes the applications are identical and
> I'm indeed using VS.Net. I checked line 82 in the file where the error
> is occuring and here's the code:
> Dim i, j As Integer
> Dim UserArray() As String
> UserArray = Application("userarray")
> j = UserArray.Length <-- this is line 82
>
> I have defined the application variable "userarray" in the
> "Application_Start" subroutine in the global.asax file before it
> reaches the above code.
> Still wondering why this should not be a problem in localhost but would
> in the server.
> thanx
Object reference not set to an instance of an object
I want to dispaly the content of a file in a literal server control.
I've created a class utils.vb
Imports System.IO
Public Class Utils
Inherits System.Web.UI.Page
Public Function ReadFile(ByVal pFile) ' As String
Dim ForReading As Integer = 1
Dim fso As Object
Dim ts
Dim s
fso = CreateObject("Scripting.FileSystemObject")
ts = fso.OpenTextFile(MapPath(pFile), ForReading)
s = ts.ReadAll
ts.Close()
ReadFile = s
End Function
End Class
on the aspx page I use
Dim utl As Utils = New Utils
Dim lBody As String = utl.ReadFile( strFile )
litContent.Text = lBody
If I have the ReadFile function in the code behind page of the calling
aspx page it works.
When I move the function to the utils.vb class I get the following
error:
System.NullReferenceException: Object reference not set to an instance
of an object
Line 11: Dim s
Line 12: fso = CreateObject("Scripting.FileSystemObject")
Line 13: ts = fso.OpenTextFile(MapPath(pFile), ForReading)
Line 14: s = ts.ReadAll
Line 15: ts.Close()
Source File: c:\inetpub\wwwroot\project\Utils.vb Line: 13
I figure its the dim ts part of ReadFile function. But ...?
/MortenHi, hainsiman,
It is the call to MapPath() that is throwing the exception. Try:
HttpContext.Current.Server.MapPath()
instead.
Greetings
Martin
"hansiman" <hansi@.hotmail.com> wrote in message
news:s0fr30hrhlqctbupmovvkspidhj4m5v5nr@.4ax.com...
> Coming from classic asp, I'm a bit in the dark here.
> I want to dispaly the content of a file in a literal server control.
> I've created a class utils.vb
> Imports System.IO
> Public Class Utils
> Inherits System.Web.UI.Page
> Public Function ReadFile(ByVal pFile) ' As String
> Dim ForReading As Integer = 1
> Dim fso As Object
> Dim ts
> Dim s
> fso = CreateObject("Scripting.FileSystemObject")
> ts = fso.OpenTextFile(MapPath(pFile), ForReading)
> s = ts.ReadAll
> ts.Close()
> ReadFile = s
> End Function
> End Class
> on the aspx page I use
> Dim utl As Utils = New Utils
> Dim lBody As String = utl.ReadFile( strFile )
> litContent.Text = lBody
> If I have the ReadFile function in the code behind page of the calling
> aspx page it works.
> When I move the function to the utils.vb class I get the following
> error:
> System.NullReferenceException: Object reference not set to an instance
> of an object
> Line 11: Dim s
> Line 12: fso = CreateObject("Scripting.FileSystemObject")
> Line 13: ts = fso.OpenTextFile(MapPath(pFile), ForReading)
> Line 14: s = ts.ReadAll
> Line 15: ts.Close()
> Source File: c:\inetpub\wwwroot\project\Utils.vb Line: 13
> I figure its the dim ts part of ReadFile function. But ...?
> /Morten
Hi Martin
I still get the error even when I change the mappath part (see below).
The strange thing is that if I put the ReadFile function in the code
behind page of the aspx file it works with simply MatPath (pFile)...
utils.vb
Public Function ReadFile(ByVal pFile)
Dim ForReading As Integer = 1
Dim fso As Object = CreateObject("Scripting.FileSystemObject")
Dim ts, s
ts =
fso.OpenTextFile(MapPath(HttpContext.Current.Serve r.MapPath(pFile)),
ForReading)
s = ts.ReadAll
ts.Close()
ReadFile = s
End Function
Call from aspx file:
Dim utl As Utils = New Utils
Dim lBody As String = utl.ReadFile( strFile )
litContent.Text = lBody
Error:
Exception Details: System.NullReferenceException: Object reference not
set to an instance of an object.
Source Error:
Line 11: Dim ts, s
Line 12: 'ts = fso.OpenTextFile(MapPath(pFile), ForReading)
Line 13: ts =
fso.OpenTextFile(MapPath(HttpContext.Current.Serve r.MapPath(pFile)),
ForReading)
Line 14: s = ts.ReadAll
Line 15: ts.Close()
Source File: c:\inetpub\wwwroot\customersurveyanalysis\mmaUtils .vb
Line: 13
On Thu, 26 Feb 2004 10:47:31 +0100, "Martin Dechev"
<detcheff_@.hotmail.com> wrote:
>Hi, hainsiman,
>It is the call to MapPath() that is throwing the exception. Try:
>HttpContext.Current.Server.MapPath()
>instead.
>Greetings
>Martin
>"hansiman" <hansi@.hotmail.com> wrote in message
>news:s0fr30hrhlqctbupmovvkspidhj4m5v5nr@.4ax.com...
>> Coming from classic asp, I'm a bit in the dark here.
>>
>> I want to dispaly the content of a file in a literal server control.
>>
>> I've created a class utils.vb
>>
>> Imports System.IO
>>
>> Public Class Utils
>> Inherits System.Web.UI.Page
>> Public Function ReadFile(ByVal pFile) ' As String
>> Dim ForReading As Integer = 1
>> Dim fso As Object
>> Dim ts
>> Dim s
>> fso = CreateObject("Scripting.FileSystemObject")
>> ts = fso.OpenTextFile(MapPath(pFile), ForReading)
>> s = ts.ReadAll
>> ts.Close()
>> ReadFile = s
>> End Function
>> End Class
>>
>> on the aspx page I use
>>
>> Dim utl As Utils = New Utils
>> Dim lBody As String = utl.ReadFile( strFile )
>>
>> litContent.Text = lBody
>>
>> If I have the ReadFile function in the code behind page of the calling
>> aspx page it works.
>>
>> When I move the function to the utils.vb class I get the following
>> error:
>>
>> System.NullReferenceException: Object reference not set to an instance
>> of an object
>>
>> Line 11: Dim s
>> Line 12: fso = CreateObject("Scripting.FileSystemObject")
>> Line 13: ts = fso.OpenTextFile(MapPath(pFile), ForReading)
>> Line 14: s = ts.ReadAll
>> Line 15: ts.Close()
>>
>> Source File: c:\inetpub\wwwroot\project\Utils.vb Line: 13
>>
>> I figure its the dim ts part of ReadFile function. But ...?
>>
>> /Morten
>
> fso.OpenTextFile(MapPath(HttpContext.Current.Serve r.MapPath(pFile)),
should be:
fso.OpenTextFile(HttpContext.Current.Server.MapPat h(pFile)),
Greetings
Martin
ahhh, of course... thanx
On Fri, 27 Feb 2004 14:14:23 +0100, "Martin Dechev"
<detcheff_@.hotmail.com> wrote:
>> fso.OpenTextFile(MapPath(HttpContext.Current.Serve r.MapPath(pFile)),
>should be:
>fso.OpenTextFile(HttpContext.Current.Server.MapPat h(pFile)),
>Greetings
>Martin