468,133 Members | 1,250 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

Where's this "server" object?!

Hi peeps

I'm just following this HOW-TO from MSDN..
http://support.microsoft.com/default...b;en-us;306355

But I've got a problem. I've adding the #using System.Diagnostics; line to
my cs file, but when I try and type the following line...

Exception objErr = Server.GetLastError().GetBaseException();

the IDE isn't picking up on the Server. - it's not giving me any
intellisense, which makes me assume it doesn't understand.

What do I need to be #using to get the Server object?!

Cheers
Dan
Feb 23 '06 #1
7 3512
Jon
Hello Mate,

Server is under System.Web.HttpServerUtility, so including System.Web.

HTH,

Jon

"dhnriverside" wrote:
Hi peeps

I'm just following this HOW-TO from MSDN..
http://support.microsoft.com/default...b;en-us;306355

But I've got a problem. I've adding the #using System.Diagnostics; line to
my cs file, but when I try and type the following line...

Exception objErr = Server.GetLastError().GetBaseException();

the IDE isn't picking up on the Server. - it's not giving me any
intellisense, which makes me assume it doesn't understand.

What do I need to be #using to get the Server object?!

Cheers
Dan

Feb 23 '06 #2
Cheers Jon!

"Jon" wrote:
Hello Mate,

Server is under System.Web.HttpServerUtility, so including System.Web.

HTH,

Jon

"dhnriverside" wrote:
Hi peeps

I'm just following this HOW-TO from MSDN..
http://support.microsoft.com/default...b;en-us;306355

But I've got a problem. I've adding the #using System.Diagnostics; line to
my cs file, but when I try and type the following line...

Exception objErr = Server.GetLastError().GetBaseException();

the IDE isn't picking up on the Server. - it's not giving me any
intellisense, which makes me assume it doesn't understand.

What do I need to be #using to get the Server object?!

Cheers
Dan

Feb 23 '06 #3
Or not... :)

I've included System.Web and it's still not giving me anything. Is this
something to do with the fact that I'm trying to use this from my own class
rather than a Page?!

Don't understand... here's the code...

using System;
using System.Diagnostics;
using System.Web;
using System.Web.UI;

namespace DansSpace
{
public class CrashRecovery
{
...

private void StoreBug()
{
Exception excp = Server. (wont give me anything...)
}
}
}

What am I doing wrong!?!

Cheers
Dan

"Jon" wrote:
Hello Mate,

Server is under System.Web.HttpServerUtility, so including System.Web.

HTH,

Jon

"dhnriverside" wrote:
Hi peeps

I'm just following this HOW-TO from MSDN..
http://support.microsoft.com/default...b;en-us;306355

But I've got a problem. I've adding the #using System.Diagnostics; line to
my cs file, but when I try and type the following line...

Exception objErr = Server.GetLastError().GetBaseException();

the IDE isn't picking up on the Server. - it's not giving me any
intellisense, which makes me assume it doesn't understand.

What do I need to be #using to get the Server object?!

Cheers
Dan

Feb 23 '06 #4
"dhnriverside" wrote:
I've included System.Web and it's still not giving me anything. Is this
something to do with the fact that I'm trying to use this from my own
class
rather than a Page?!


Yes, Server is a property of the page object. If your class doesn't inherit
from Page, include the following line:

System.Web.HttpServerUtility Server = HttpContext.Current.Server;

Steven

- - -
Feb 23 '06 #5
Okay, done that, it compiles but crashes with an "object reference not set to
an object" error..

System.Web.HttpServerUtility Server = HttpContext.Current.Server;
Exception ex = Server.GetLastError().GetBaseException(); // this line fails

What's am I missing here?! I'm trying to Google for info, but I'm not
finding anything about why this is happening, or how to achieve this.

Thanks all for your continuing help...


"Steven Spits" wrote:
"dhnriverside" wrote:
I've included System.Web and it's still not giving me anything. Is this
something to do with the fact that I'm trying to use this from my own
class
rather than a Page?!


Yes, Server is a property of the page object. If your class doesn't inherit
from Page, include the following line:

System.Web.HttpServerUtility Server = HttpContext.Current.Server;

Steven

- - -

Feb 23 '06 #6
"dhnriverside" wrote:
Okay, done that, it compiles but crashes with an "object reference not set
to
an object" error..

System.Web.HttpServerUtility Server = HttpContext.Current.Server;
Exception ex = Server.GetLastError().GetBaseException(); // this line
fails


Is Server null or does GetLastError() return null? My guess is the latter.

If GetLastError() return null, it means there isn't an error or it was
already reset. Try calling this method earlier and pass the exception as a
parameter.

Without more code, this is the best advice I can give you.

Steven

- - -
Feb 23 '06 #7
In article <20**********************************@microsoft.co m>,
dhnriverside <da*@musoswire.com> writes
Okay, done that, it compiles but crashes with an "object reference not
set to an object" error..

System.Web.HttpServerUtility Server = HttpContext.Current.Server;
Exception ex = Server.GetLastError().GetBaseException(); // this line
fails


Note Steve's words "If your class doesn't inherit from Page"

Have you tried inheriting from Page? That's what I tend to do and it
gives access to such things as Server.

public class CrashRecovery : Page {

HTH

--
Alan Silver
(anything added below this line is nothing to do with me)
Feb 28 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by Mikkky | last post: by
6 posts views Thread by Martin Eyles | last post: by
4 posts views Thread by julian.tklim | last post: by
6 posts views Thread by alessandro | last post: by
6 posts views Thread by teddysnips | last post: by
19 posts views Thread by Scott M. | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.