473,395 Members | 2,423 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,395 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 1182
"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...
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...
8
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
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.