Friday, June 27, 2008

Working with event logs

The .Net Framework provides the EventLog class in the System.Configuration namespace that allows us to create and manage log entries. In this article, I will describe how this can be achieved in just a few lines of codes.

a) Creating an Event Log

The EventLog class allows us to create an event log. Here are a couple of overloaded constructors available, but here, I am going to use the simplest one by providing a name for the log only. Also, to use the event log, the Source property needs to be specified and a message needs to be written as well.

Next, to write an entry, I will use the WriteEntry method, by giving the message and the entry type.

If the code is executed, the new event log will be visible in the Windows Event Viewer.

b) Deleting an Event Log

c) Getting existing event logs

Event Viewer and event logs in Windows XP

The Event Log Service in Windows XP records application, security and system events in its Event Viewer. Here an event is any significant occurence in an application and/or system that requires notification to the users. The event logs allow us to obtain information about hardware, software or any system components, identify and diagnose current system problems or even assist in prediction of potential system problems.

Event Logs in Windows XP

1. Application log
2. Security log
3. System log

Viewing the Event Logs in XP

Start --> Control Panel --> Performance and Maintenance --> Administrative Tools --> Event Viewer

For more information about Event Viewer and event logs, read the nice article How to view and manage event logs in Event Viewer in Windows XP here.

Coming next: Event Logs in .Net 2.0

Saturday, June 21, 2008

YouTube for Mobile

YouTube for Mobile is a mobile application that will allow you to browse and watch YouTube videos from your handset. I have tried it on my Nokia N95, and it works great.

the main features ...
- browse by popular videos (most viewed, top rated, featured), related videos or keyword search;
- sign into your YouTube account and access your own videos, subscriptions and favourites;
- upload videos from the mobile phone to YouTube directly;
- Similar look and feel of the YouTube website version;
- supported phones are Nokia's N73, N95, E65, 6110, 6120 and Sony Ericsson's K800 and W880

some other facts ...
- applicant has been written in java;
- works best with 3G coverage (and my home MyT connection as well);
- video is in .3gp format and of lower quality than the video on the YouTube website;
- supported phones are Nokia's N73, N95, E65, 6110, 6120 and Sony Ericsson's K800 and W880;

YouTube installation ...
To install the YouTube application, use your mobile phone and go to

and follow the instructions to download and install YouTube on the phone. Upon successful completion, the YouTube icon will appear on the applications menu.

the sound issue on Nokia phones ...
For Nokia devices, you must have the Warning Tones enabled in your phone's settings to hear audio in YouTube. This setting can be found in "Profiles" > "Current Profile" > "Personalize" > "Warning Tones."


Launch YouTube Mobile Client from Menu ...

YouTube Mobile Client is launched, and enters the Home menu ...

Search a video on YouTube ...

Video presented with small thumbnail and related descriptive information ...

Video starts with same look and feel as ...

Additional options available ...

Logon YouTube using my account ...

View my videos ...

Closing the application ...

further information...
here and here.

Wednesday, June 11, 2008

Declaring variables as nullable in C#

Nullable variables can be declared if you want to determine whether a value has been assigned or not.

Two ways:

1. Use Nullable type
Nullable b = null;

2. Use C# shorthand notation
bool? b = null;

Launch a program on a device remotely from the desktop using RAPI Start

1. Windows Mobile Developer Power Toys is installed on your pc. This can be downloaded here.

2. Microsoft ActiveSync is installed on your pc. This can be downloaded here.

3. Device is connected to the pc via ActiveSync.

4. The program to be launched has already been deployed on the device.

To launch a program on a device remotely via command-line,

1. Open Command Prompt Window

2. Go to *installation path of Windows Mobile Developer Power Toys*\RAPI_Start

cd C:\Program Files\Windows Mobile Developer Power Toys\RAPI_Start

3. Type rapistart *path of program on device to be launched enclosed between double quotes (see example below)*

rapistart "\Program Files\HelloWorldApplication\HelloWorldApplication.exe"

Monday, June 9, 2008

.Net Compact Framework and OpenNetCF

The slides of a small presentation I made on .Net Compact Framework and OpenNetCF...