Get computer IP address - LAN & Internet using C#

WPF & WinForms
Posted on
There are two ways to get your IP address!
First is for LAN IP, which indicates your computer address in local network, while the second way is to get your INTERNET IP, which is stored in your router.

#1 - Get computer LAN address like
#2 - Get computer INTERNET address like

Check if Internet connection is available using C#

WPF & WinForms
Posted on
There can be situations when you need to check, whether your application has Internet access.
Maybe you have to download/upload some file or database, or just run some application check.

Many developers are solving that "problem" just by ping-ing Well...? :/ That will work in most (99%) cases, but how professional is to rely work of Your application on some external web service?

Instead of pinging, there is an very interesting Windows API function called InternetGetConnectedState(), that recognizes whether You have access to Internet or not.

Running a ClickOnce Application as Administrator

WPF & WinForms
Posted on
Using ClickOnce to deploy your Windows application is the easiest way you can imagine.
BUT, as it gets with all automatic process, there are situations when you ran into a problem: my ClickOnce deployed application wouldn't start on Windows 8 operating system.

Accessing Controls running in different Thread

WPF & WinForms
Posted on
If you worked with System.Threading.Thread in desktop applications, you probably ran into problem, where you wanned to access some control, and update her condition / property.

Controls in Windows Forms are bound to a specific thread and are not thread safe. Therefore, if you are calling a control's method from a different thread, you must use one of the control's invoke methods to marshal the call to the proper thread.