Loading...

How to check windows application is running in IDE or as EXE

This is one the most useful post I have ever written, and I am sure you will find it useful.
In Windows Application some times we may need to check whether our application is running in IDE or is running as EXE.

A typical example would be, developer may need to provide user name and password every time he runs the windows application from IDE. As a developer I always use developer/administrator account while developing any windows application.

We might use Development Server while working in development/debug mode. Once the application is deployed we will be using Live Server. It is very hard if you keep on changing the server names each time like while dev change the server to development and while live change it back to live. We might make mistakes while switching these servers. To avoid these difficulties we can use the following function to see whether our application is running in IDE or running as standalone EXE.

Module modMain
    Sub Main()
        If IsApplicationRunningInIDE() Then
            Console.WriteLine("I am working on IDE")
             txtUserName.text = “admin”    
             txtUserName.password = “admin123”
        Else
            Console.WriteLine("I am working on standalone EXE")
             txtUserName.text = “”    
             txtUserName.password = “”
        End If
    End Sub
    Public Function IsApplicationRunningInIDE() As Boolean
        Return System.Diagnostics.Debugger.IsAttached()
    End Function
End Module


I welcome your comments
Newer Posts Older Posts

Contact Me

© Copyright Source Code World | Designed By Code Nirvana
Back To Top