Constructor problems

S

sureshsundar007

Hi all,

I'm trying to inherit the SimpleWorkerRequest class.

my code is like this..
public class Request : SimpleWorkerRequest
{
public Request(): base(String.Empty,String.Empty,null)
{
}
}
(Here the constructor is argumentles..but i tried with some different
parameters also)

I'm getting an error while creating a new Request Object ..

"An unhandled exception of type 'System.NullReferenceException'
occurred in system.web.dll

Additional information: Object reference not set to an instance of an
object."

what i'm doing wrong here?

Can anyone help me to fix this?

Thanks for ur help,
Suresh.
 
M

Mark Broadbent

your problem is being caused by the null reference in the argument list when
calling the base constructor. Please refer to the class documentation of the
SimpleWorkerRequest for the correct constructor/s.


ms-help://MS.VSCC.2003/MS.MSDNQTR.2003FEB.1033/cpref/html/frlrfsystemwebhost
ingsimpleworkerrequestmemberstopic.htm
--


Br,
Mark Broadbent
mcdba , mcse+i
=============
sureshsundar007 said:
Hi all,

I'm trying to inherit the SimpleWorkerRequest class.

my code is like this..
public class Request : SimpleWorkerRequest
{
public Request(): base(String.Empty,String.Empty,null)
{
}
}
(Here the constructor is argumentles..but i tried with some different
parameters also)

I'm getting an error while creating a new Request Object ..

"An unhandled exception of type 'System.NullReferenceException'
occurred in system.web.dll

Additional information: Object reference not set to an instance of an
object."

what i'm doing wrong here?

Can anyone help me to fix this?

Thanks for ur help,
Suresh.
 
C

Cecil Howell

Suresh,
You are calling the SimpleWorkerRequest classes constructor, the
constructor takes three arguments and it expects those arguments to
have a value. Some methods or constructors that take an object may
consider null a valid argument but most do not, they expect a value.
The call to your bases constructor is choking on the null, my guess is
it will also choke on the string.Empty. In order for the class to
operate it requires values for these arguments.

Cecil Howell
MCSD, MCT



Hi all,

I'm trying to inherit the SimpleWorkerRequest class.

my code is like this..
public class Request : SimpleWorkerRequest
{
public Request(): base(String.Empty,String.Empty,null)
{
}
}
(Here the constructor is argumentles..but i tried with some different
parameters also)

I'm getting an error while creating a new Request Object ..

"An unhandled exception of type 'System.NullReferenceException'
occurred in system.web.dll

Additional information: Object reference not set to an instance of an
object."

what i'm doing wrong here?

Can anyone help me to fix this?

Thanks for ur help,
Suresh.
 
S

sureshsundar007

Thanks for the replies..

I tried by giving values to the base class constructor parameters..but
the reult is same.I'm getting the same Exception when the new Request
object is created.

I saw a piece of code in Cassini Web server which also extends the
SimpleWrokerRequest with the constructor is like this...

public Request(Host host,Connection conn) : base
(String.Empty,String.Empty,null)
{
_host = host;
_conn = conn;
}

and it works without any problems.So it means that SimpleWorkerRequest
constructor accepts null values...correct?

I'm clueless about this exception....please help to resolve this...

Thanks,
Suresh.
 
J

Jon Skeet [C# MVP]

sureshsundar007 said:
Thanks for the replies..

I tried by giving values to the base class constructor parameters..but
the reult is same.I'm getting the same Exception when the new Request
object is created.

I saw a piece of code in Cassini Web server which also extends the
SimpleWrokerRequest with the constructor is like this...

public Request(Host host,Connection conn) : base
(String.Empty,String.Empty,null)
{
_host = host;
_conn = conn;
}

and it works without any problems.So it means that SimpleWorkerRequest
constructor accepts null values...correct?

I'm clueless about this exception....please help to resolve this...

It could be that Cassini doesn't use whatever it is that causes the
exception, or sets the writer some other way.
 
S

sureshsundar007

at last this is what i tried...

public class Request : SimpleWorkerRequest
{
public Request(string page,string query,StringWriter wr):base
(page,query,wr)
{
MessageBox.Show("hai");
}
}

But still i'm getting that exception with the exception is highlighted
on the line MessageBox.Show("hai").

Any help?

Suresh.
 
J

Jon Skeet [C# MVP]

sureshsundar007 said:
at last this is what i tried...

public class Request : SimpleWorkerRequest
{
public Request(string page,string query,StringWriter wr):base
(page,query,wr)
{
MessageBox.Show("hai");
}
}

But still i'm getting that exception with the exception is highlighted
on the line MessageBox.Show("hai").

Any help?

And what are you passing into your constructor?
 
C

Cecil Howell

Suresh,
If you are still having trouble post the stack dump from the
exception. This should provide a big clue.

Cecil Howell
MCSD, MCT


at last this is what i tried...

public class Request : SimpleWorkerRequest
{
public Request(string page,string query,StringWriter wr):base
(page,query,wr)
{
MessageBox.Show("hai");
}
}

But still i'm getting that exception with the exception is highlighted
on the line MessageBox.Show("hai").

Any help?

Suresh.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top