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

Home Posts Topics Members FAQ

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.Diagnost ics; line to
my cs file, but when I try and type the following line...

Exception objErr = Server.GetLastE rror().GetBaseE xception();

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 3787
Jon
Hello Mate,

Server is under System.Web.Http ServerUtility, so including System.Web.

HTH,

Jon

"dhnriversi de" 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.Diagnost ics; line to
my cs file, but when I try and type the following line...

Exception objErr = Server.GetLastE rror().GetBaseE xception();

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.Http ServerUtility, so including System.Web.

HTH,

Jon

"dhnriversi de" 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.Diagnost ics; line to
my cs file, but when I try and type the following line...

Exception objErr = Server.GetLastE rror().GetBaseE xception();

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.Diagnost ics;
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.Http ServerUtility, so including System.Web.

HTH,

Jon

"dhnriversi de" 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.Diagnost ics; line to
my cs file, but when I try and type the following line...

Exception objErr = Server.GetLastE rror().GetBaseE xception();

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
"dhnriversi de" 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.Http ServerUtility Server = HttpContext.Cur rent.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.Http ServerUtility Server = HttpContext.Cur rent.Server;
Exception ex = Server.GetLastE rror().GetBaseE xception(); // 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:
"dhnriversi de" 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.Http ServerUtility Server = HttpContext.Cur rent.Server;

Steven

- - -

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

System.Web.Http ServerUtility Server = HttpContext.Cur rent.Server;
Exception ex = Server.GetLastE rror().GetBaseE xception(); // 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************ *************** *******@microso ft.com>,
dhnriverside <da*@musoswire. com> writes
Okay, done that, it compiles but crashes with an "object reference not
set to an object" error..

System.Web.Htt pServerUtility Server = HttpContext.Cur rent.Server;
Exception ex = Server.GetLastE rror().GetBaseE xception(); // 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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
1401
by: arc | last post by:
I have a server object that performs zipcode validation based on zipcode entered in the web form. Ideally this should work as follows: Once the zip code is entered in the edit box it should validate the entry with this server object before moving to enter state in the next dropdown field. - What is the event by which we can do this for the edit box? (OnBlur doesnt seem to capture the text though it fires up the server object) - This...
3
6205
by: Mikkky | last post by:
The sample code below returns and error " The type or namspace name 'Server' could not be found". Please help. using System;using System.IO; using System.Xml;using System.Diagnostics; using System.Collections;using System.Web;using System.Web.UI; using System.Web.UI.WebControls;using System.Web.UI.HtmlControls; public class Business { XmlDocument doc = new XmlDocument(); doc.Load(Server.MapPath("Rules.xml"));
6
2712
by: Martin Eyles | last post by:
Hi, I have a page that contains the following <div runat="server" id="Pikea"> <object runat="server" id="PiTV" style="width:560px; height:560px" classid="clsid:{3DF152A5-521D-4330-A8DC-1424CEB66BAA}" VIEWASTEXT> </object> </div>
0
1475
by: Jan | last post by:
I just started using .NET Remoting. I have a test system (client) which connects to our device (server) running XP Embedded. When my server object is called it uses a library where reflection (Type.InvokeMethod) is used to dynamically invoke a "command-object" in a list. The list of objects are created when server is started (in UI-thread). Each entry in the command list stores a Type reference, an object reference and the method name.
4
1657
by: julian.tklim | last post by:
Hi, I have built a DLL using VB 6.0 and trying to run create the object in ASP. Eg: <% set a = Server.Createobject("Office.clsOffice") %>
7
6202
by: thisis | last post by:
Hi All, i have this.asp page: <script type="text/vbscript"> Function Body_Onload() ' create the object Set obj = Server.CreateObject("UploadImage.cTest") ' use method of the object Body_Onload = obj.cTestDelete
6
16172
by: alessandro | last post by:
Hi all, This is my framework for create TCP server listening forever on a port and supporting threads: import SocketServer port = 2222 ip = "192.168.0.4"
6
2331
by: teddysnips | last post by:
In my application I need to allow users to cut 'n' paste stuff from various sources, some of which might include dodgy characters such as "<". Natch, IE interprets these as potentially dangerous and provides a mechanism to encode/decode them. However I can't seem to get it to work: .... <asp:textbox id=txtDescription style="Z-INDEX: 102; LEFT: 111px; POSITION: absolute; TOP: 124px" tabIndex=29 runat="server" onblur="return...
19
11236
by: Scott M. | last post by:
Why do we need runat="server" on our <headtags?
0
8427
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8851
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8525
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7356
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2750
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1975
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.