|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
How to determine if I am in a web or a windows applicationHello 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 "Jean Paul Mertens" <ON7AMI@newsgroups.nospam> schrieb: Check out 'System.Reflection.Assembly.GetEntryAssembly'.> 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. -- M S Herfried K. Wagner M V P <URL:http://dotnet.mvps.org/> V B <URL:http://dotnet.mvps.org/dotnet/faqs/> 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 -- Show quoteThanks & 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 > > > 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;} } -- Show quoteEliyahu Goldin, Software Developer & Consultant Microsoft MVP [ASP.NET] "Jean Paul Mertens" <ON7AMI@newsgroups.nospam> wrote in message news:%23%23gctPV3GHA.2228@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 > > 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. Show quote "Eliyahu Goldin" <REMOVEALLCAPITALSeEgGoldD***@mMvVpPsS.org> wrote in message news:eGcLg7V3GHA.4024@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" <ON7AMI@newsgroups.nospam> wrote in message > news:%23%23gctPV3GHA.2228@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 > > > > > > |
|||||||||||||||||||||||