473,414 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

How Can I locate a namespace reference in asp.net?

What is the best way to locate the namespace I need to put in a using
statement?

For example suppose I wanted to discover which namespace "Server" was
in the context of:

Exception ex = Server.GetLastError();

- code that is normally placed in Global Application_Error() but which
I want to put in a separate class.

How do I go about finding which particular namespace has a Server
class which includes a GetLastError method?

Apr 27 '07 #1
4 3563
Keep in mind, when you're not coding in a web page or a user or web control
you need to use the full object path to get to things like the Server object
as such: HttpContext.Current.Server
--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"mark4asp" <ma******@gmail.comwrote in message
news:11**********************@r3g2000prh.googlegro ups.com...
What is the best way to locate the namespace I need to put in a using
statement?

For example suppose I wanted to discover which namespace "Server" was
in the context of:

Exception ex = Server.GetLastError();

- code that is normally placed in Global Application_Error() but which
I want to put in a separate class.

How do I go about finding which particular namespace has a Server
class which includes a GetLastError method?

Apr 27 '07 #2
re:
!What is the best way to locate the namespace I need to put in a using statement?

Look it up in the .Net Framework Class Browser :

http://quickstarts.asp.net/QuickStar...ssbrowser.aspx

Juan T. Llibre, asp.net MVP
asp.net faq : http://asp.net.do/faq/
foros de asp.net, en español : http://asp.net.do/foros/
===================================
"mark4asp" <ma******@gmail.comwrote in message
news:11**********************@r3g2000prh.googlegro ups.com...
What is the best way to locate the namespace I need to put in a using
statement?

For example suppose I wanted to discover which namespace "Server" was
in the context of:

Exception ex = Server.GetLastError();

- code that is normally placed in Global Application_Error() but which
I want to put in a separate class.

How do I go about finding which particular namespace has a Server
class which includes a GetLastError method?

Apr 27 '07 #3
On 27 Apr, 13:01, "Mark Fitzpatrick" <markf...@fitzme.comwrote:
Keep in mind, when you're not coding in a web page or a user or web control
you need to use the full object path to get to things like the Server object
as such: HttpContext.Current.Server

--
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"mark4asp" <mark4...@gmail.comwrote in message

news:11**********************@r3g2000prh.googlegro ups.com...
What is the best way to locate the namespace I need to put in a using
statement?
For example suppose I wanted to discover which namespace "Server" was
in the context of:
Exception ex = Server.GetLastError();
- code that is normally placed in Global Application_Error() but which
I want to put in a separate class.
How do I go about finding which particular namespace has a Server
class which includes a GetLastError method?- Hide quoted text -

- Show quoted text -
Thanks Mark, I had problems finding the "HttpContext.Current.Server"
bit.

I figured it out - all incredibly simple once you realise that Google
is not your friend but your enemy. Visual Studio is your friend.

1) In Visual Studio I put the line:
Exception ex = Server.GetLastError();
some place where it works (i.e. where a specific reference to the
namespace is not required) and where a breakpoint can reasonably be
set [Global Application_Error() won't do but
FormsAuthentication_OnAuthenticate() is fine as that's in Global too]
2) add a breakpoint there.
3) start debugging
4) add a watch for the desired object (Server) which tells me:

+ Server {System.Web.HttpServerUtility} System.Web.HttpServerUtility

Voila - the required namespace is "System.Web.HttpServerUtility"

So in I can now call my custom class in Global Application_Error():

string sError = CustomError.getError(Context, Request, Server, ref
sMessage);

and the header for my class method in CustomError is:

public static string getError(HttpContext Context, HttpRequest
Request, HttpServerUtility Server, ref string eMessage)

with no particular new using statements being needed in CustomError.

I feel the need to tell myself this even if everyone else already
knows it because it helps me remember things when I write them down.

Apr 27 '07 #4

"Juan T. Llibre" <no***********@nowhere.comwrote in message
news:uo**************@TK2MSFTNGP02.phx.gbl...
re:
!What is the best way to locate the namespace I need to put in a using
statement?

Look it up in the .Net Framework Class Browser :

http://quickstarts.asp.net/QuickStar...ssbrowser.aspx
You may also want to use the F1 button in Visual Web Developer or Visual
Studio.
Put the cursor on the word "Server" in your code, and press F1.

Usually, it will bring you straight to the right page with all the
information.

Riki
Apr 27 '07 #5

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

Similar topics

0
by: shawnk | last post by:
I want to use the Hosts file to locate schema for validation. The Hosts file (C:\Windows\System32\etc) will locate xsd schema files on a LAN server for development purposes. This gives me a...
3
by: SC | last post by:
i have 2 separate projects: 1) Project A: Class library, written in VB.NET; It's namespace is explicitly defined in the code like: Namespace MyCompany.Project.ClassesA .... End Namespace ...
4
by: Peter Speybrouck | last post by:
I have a little problem with a webservice. I reproduced the problem in the following simplified example. I just create a new C# ASP.NET webservice and a c# console application. I added a new...
4
by: dhnriverside | last post by:
HI guys I've just written my first independent namespace for my library (yay me!). However, on trying to add it to my website project, it causes an error when I look at the website. It compiles...
6
by: ryan.d.rembaum | last post by:
Hello, I have code that I wish to use in many web applications. Basically sort of stand utility stuff. So from Visual Studio Project I select add a component and chose Component Class. Lets...
1
by: Phill. W | last post by:
Having changed a VB.Net(2003) DLL project, I'm getting Type Loading problems in other code that uses my DLL. In my source code, I have a Namespace Statement something like this: Namespace...
9
by: Buz Waitz | last post by:
I'm a newbie. I've created a datalayer class which I creatively called sqlAccess and placed in a namespace I just as creatively called MyDomain.DataAccessLayer. (Well now, I didn't actually use...
29
by: Tiraman | last post by:
Hi, I Build my own dll with my own namespace name and i would like to put it in one place but for the project bin folder so all of the projects will be able to use it . i tried to put the dll...
0
by: CtrlAltDel2008 | last post by:
Hello everyone, i hope you can help me with this query. The code below all works fine, referring to the SUBSTRING part, at the moment it just displays all the text from the "http" part until the end...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
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...

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.