473,395 Members | 1,452 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.

Am I running from a development environment?

I'm developing a Windows Forms application, where I would like to handle
errors differently depending on whether I'm running from a development
environment or directly from a .EXE file.
Any ideas how I can determine this?

- Turtle
Oct 20 '05 #1
6 1345
> I'm developing a Windows Forms application, where I would like to handle
errors differently depending on whether I'm running from a development
environment or directly from a .EXE file.
Any ideas how I can determine this?


Diagnostics.Debugger.IsAttached()
Oct 20 '05 #2
Any ideas how I can determine this?


You can't really. But you can check if there's a debugger attached to
the process with System.Diagnostics.Debugger.IsAttached.
Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Oct 20 '05 #3
Yeah you can! This was converted years ago, from some even older VB6 code..
but it still works!

Public Function AreWeInTheIDE() As Boolean
' Determine if we're in the IDE or not
Dim vInDevelopment As Boolean
System.Diagnostics.Debug.Assert(CheckIDE(vInDevelo pment), String.Empty)
Return vInDevelopment
End Function

Private Function CheckIDE(ByRef pStatus As Boolean) As Boolean
' This function is only called in the IDE - so return true to confirm
this is development
pStatus = True
Return True
End Function

____________________________________________
The Grim Reaper
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:OH**************@TK2MSFTNGP14.phx.gbl...
Any ideas how I can determine this?


You can't really. But you can check if there's a debugger attached to
the process with System.Diagnostics.Debugger.IsAttached.
Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Oct 20 '05 #4
Yeah you can! This was converted years ago, from some even older VB6 code..
but it still works!


Debug.Assert has the Conditional("DEBUG") attribute on it. So
AreWeInTheIDE will return True whenever the DEBUG conditional
compilation symbol is defined, and False otherwise. That has nothing
to do with whether or not you're running the application from the IDE
or not.
Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Oct 20 '05 #5
<insert rude words here>

I assumed that cos I converted it so long ago, that I'd tested it too...
oopps.

Thanks for pointing that out. Have now tested it and feel suitable
sheepish.

_____________________________
The Grim Reaper
"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:e4**************@TK2MSFTNGP10.phx.gbl...
Yeah you can! This was converted years ago, from some even older VB6
code..
but it still works!


Debug.Assert has the Conditional("DEBUG") attribute on it. So
AreWeInTheIDE will return True whenever the DEBUG conditional
compilation symbol is defined, and False otherwise. That has nothing
to do with whether or not you're running the application from the IDE
or not.
Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Oct 20 '05 #6
Many thanks to all of you!

"Mattias Sjögren" <ma********************@mvps.org> wrote in message
news:OH**************@TK2MSFTNGP14.phx.gbl...
Any ideas how I can determine this?


You can't really. But you can check if there's a debugger attached to
the process with System.Diagnostics.Debugger.IsAttached.
Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.

Oct 21 '05 #7

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

Similar topics

4
by: Damien Renwick | last post by:
I have a php script which simply stops midway through a while loop that processes records returned by a MySQL query. The HTML page continues trying to load the page but the php has stopped running...
4
by: Mee Yamo | last post by:
Fellas!! This is a very complicated one and it took me a few days to figure out exactly what's going on, but here's the final story: I have a production environment running on .NET with a SQL...
4
by: Jared Thirsk | last post by:
== Introduction to DAF == I am interested in the next generation of approaches to software development. Over the last decades, there has been an obvious shift in how our most complex software...
3
by: David | last post by:
I want to develop a single web app that will be run in three environments: development, test, and production. The test and prodc. will be on the same machine under different directories. I wish...
6
by: Turtle | last post by:
I'm developing a Windows Forms application, where I would like to handle errors differently depending on whether I'm running from a development environment or directly from a .EXE file. Any ideas...
4
by: marklawford | last post by:
Not having earned my DBA badge from the scouts just yet I'm a little lost with an error I'm getting. We've just upgraded our development database from 7.2 to 8.2 as the first step in upgrading...
3
by: Erik ETS | last post by:
I need some symmetry between my development environment and my running web site. The root of my web site is http://www.mysite.com/ while the root of the project in my local development environment...
17
by: vj | last post by:
Hi All, I am using C++Builder V5.0 to run my C programs. I am not an expert in C. Normally, I run the C program with these steps: 'Compile', 'Make Project', 'Build Project' and then 'Run'. Many...
11
by: John Sheppard | last post by:
Hello there, I am running a webservice on IIS6, sometimes it runs at a reasonable speed, sometimes it runs painfully slow and sometimes inbetween. The application that consumes the service is...
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...
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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.