473,320 Members | 1,949 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,320 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 1339
> 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: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.