473,379 Members | 1,344 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,379 software developers and data experts.

How to determine if I am in a web or a windows application

Hello to all,

I use a lib class to handle all my exeption errors ocured in my objects.
Since my objects are used in windows applications as well as in web
applications, I would like to determine in my lib class if she is serving a
web or a windows application. Is there a neat way to detect this.

Greets

Jean.Paul
Sep 21 '06 #1
4 1226
"Jean Paul Mertens" <ON****@newsgroups.nospamschrieb:
I use a lib class to handle all my exeption errors ocured in my objects.
Since my objects are used in windows applications as well as in web
applications, I would like to determine in my lib class if she is serving
a web or a windows application. Is there a neat way to detect this.
Check out 'System.Reflection.Assembly.GetEntryAssembly'.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://dotnet.mvps.org/dotnet/faqs/>

Sep 21 '06 #2
Hello Jean Paul,

You could do it by figuring out the which program/assembly is calling the
exception handling library. Based on that you can differentiate whether
win/web app is calling .

If you don't have control over exception handling library, meaning if the
lib is blackbox to you, the only way to attack this scenario is to play with
generated exception message. Try adding more information to the exception
message of the exception object and call the exception handling library with
the exception.

Pls let me know whether this is useful to you and let me know whether you
need more information
--
Thanks & Regards,
Sundar Narasimman
"Jean Paul Mertens" wrote:
Hello to all,

I use a lib class to handle all my exeption errors ocured in my objects.
Since my objects are used in windows applications as well as in web
applications, I would like to determine in my lib class if she is serving a
web or a windows application. Is there a neat way to detect this.

Greets

Jean.Paul
Sep 21 '06 #3
In most scenarios this will do:

/// <value>Indicates that the application is running in ASP.NET</summary>

public static bool IsWeb

{

get {return System.Web.HttpContext.Current != null;}

}
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"Jean Paul Mertens" <ON****@newsgroups.nospamwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
Hello to all,

I use a lib class to handle all my exeption errors ocured in my objects.
Since my objects are used in windows applications as well as in web
applications, I would like to determine in my lib class if she is serving
a web or a windows application. Is there a neat way to detect this.

Greets

Jean.Paul


Sep 21 '06 #4
I agree with this one. (aka, Eliyahu's)

I use this one fairly often.

Keep in mind which namespace/assembly its in.
PS

You normally dont' need to post to 4 or more groups.


"Eliyahu Goldin" <RE**************************@mMvVpPsS.orgwrote in
message news:eG**************@TK2MSFTNGP03.phx.gbl...
In most scenarios this will do:

/// <value>Indicates that the application is running in ASP.NET</summary>

public static bool IsWeb

{

get {return System.Web.HttpContext.Current != null;}

}
--
Eliyahu Goldin,
Software Developer & Consultant
Microsoft MVP [ASP.NET]

"Jean Paul Mertens" <ON****@newsgroups.nospamwrote in message
news:%2******************@TK2MSFTNGP03.phx.gbl...
Hello to all,

I use a lib class to handle all my exeption errors ocured in my objects.
Since my objects are used in windows applications as well as in web
applications, I would like to determine in my lib class if she is
serving
a web or a windows application. Is there a neat way to detect this.

Greets

Jean.Paul


Sep 22 '06 #5

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

Similar topics

3
by: Web Webon | last post by:
Hi everybody! I wonder if this is possible? I need to determine if a client is using "windows classic folders" or anything else. If I instantiate a Shell ActiveX object is there a way of...
19
by: Lauren Quantrell | last post by:
In Windows XP display Properties/Appearance users can chose between: Windows XP Style or Windows Classic Style. Is there a way in VBA to determine the user's selection? The reason: Toolbars...
3
by: Sisyphus | last post by:
Hi, Is there anything in the ANSI C standard covering the means by which I can determine the operating system and compiler being used (at the preprocess stage) ? If so, then how might I...
3
by: dje | last post by:
How do I determine if the current process is a Web Application or Windows Application? I've tried: System.Diagnostics.Process process=System.Diagnostics.Process.GetCurrentProcess(); but it...
6
by: Arsen V. | last post by:
Hello, I have a localization class that I want to use from either Web or Windows Forms apps. Currently it stores some information in the HttpRuntime.Cache object. I want to be able to determine...
4
by: Dave | last post by:
Greetings, I have a web application that will be hosted on our intranet. I would like to determine, via code the user's windows login name and domain in the following format: DOMAIN\loginname...
3
by: Dean Slindee | last post by:
I have a exception handling class that could be called from either a windows project app or a console project app. Is there any way for this class to determine which type of app called it without...
7
by: Doru Roman | last post by:
Hi, What is the fastest way to evaluate manually the result in this case: int a, b, c; a = 255; b = 122; c = a & b; The only way I know is transforming each number into the binary value...
4
by: Jean Paul Mertens | last post by:
Hello to all, I use a lib class to handle all my exeption errors ocured in my objects. Since my objects are used in windows applications as well as in web applications, I would like to determine...
8
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
I want to determine the Windows color scheme that is being used by my app. This means that I need to determine the following: 1. Does the OS support themes? 2. Are themes currently enabled...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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...

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.