Wednesday, November 02, 2005

ISV Community Days in November

The focus this time will be on Visual Studio Team System, tuning your .NET Framework 2.0 apps for maximum performance and Debugging.

More details, including information on how to register for these events can be had from here.

Friday, September 30, 2005

ISV Community Day Presentations

You can find the presentations that we used at the recenty concluded ISV Community Days here.

We are about to start planning the topics we'll cover the next time. If you'd like us to cover something specific do leave me a comment and I'll see if we can include it.

Friday, September 16, 2005

ISV Community Days are back!

Join us to find out how Microsoft can help you move to Visual Studio 2005 and SQL Server 2005. We also spend time exploring the changes made to databinding in Visual Studio 2005 (both WinForms and WebForms).

Find more details here.

Friday, August 19, 2005

Blogger's MS Word add-in

I am writing this in Word and using the blogger Word add-in to publish. The add-in (and more details about it) can be had from here.

Wednesday, August 17, 2005

TechEd Redux

If you are in Trivandrum, Kolkata, Ahmedabad or Chandigarh, you can attend TechEd in your city on 18th, 23rd, 24th or 26th August respectively. For more details visit the Tech.Ed on the road site.

The agenda can be seen here.

Tuesday, July 05, 2005

Compatibility between .NET Framework 1.1 and 2.0

With Framework 2.0 around the corner, you will probably consider moving to it. Even if you don't make a move in near future, you might be interested in knowing the various issues that you should keep in mind while developing your 1.1 applications today, so that the migration at a later date is as smooth as possible. I just came across this fantastic article at MSDN, that address some of these issues.

Monday, July 04, 2005

ISV Community Days

The presentations for this quarter's ISV Community Days are now available for downloads. The event after touching Chennai, Mumbai and Hyderabad will conclude in Bangalore on 7th July at Le Meridian (we'll start at 10:00 AM).

Tuesday, June 28, 2005

Tech Ed 2005, Mobility Session: Links to additional information

These are some of the links that you'll find useful if you do mobile development. I found material presented here very useful when preparing for my session:

Tuesday, May 24, 2005

The current version of ActiveSync is not supported

While developing a Pocket PC or Smartphone application using Visual Studio 2005 Beta 2, you might get the following error:

"The current version of ActiveSync is not supported"

You'll also get this error when you try to connect to your device via Tools -> Connect to Device...

This happens because (as the error message rightly informs us) you don't have the latest version of ActiveSync installed. The latest "public" version is 3.8, while Visual Studio 2005 requires version 4.0. Microsoft has recently made the developer preview of ActiveSync 4.0 available, which can be downloaded from here

Monday, May 09, 2005

Tuesday, March 29, 2005

Country from IP

In a web application, it’s often useful to be able to find out the geographic location of your visitors. For instance, you could use that data to either render the page in a language native to that geography or you could supply user with geographically relevant information. (Google for instance redirects you to if you are coming from an IP that belongs to an ISP in India). There are of course caveats – the user might be coming from behind a proxy server which is different from his actual geography. (Often happens to me at work!). Worse still the user could be traveling and checking your website from a cybercafé in Thailand. There are ways you can handle these exceptions gracefully but for now let’s focus on finding user’s country given his IP.

First of all you need to get hold of the IP to Country database. You can obtain it in CSV format from: (thanks Anil). The database is updated regularly and you should check for updates every month or so. The database contains a series of IP ranges and the country corresponding to each range. You can import it (DTS) into SQL Server. Your table could look something like:

CREATE TABLE [pubs].[dbo].[ip-to-country] (
[StartIP] bigint NULL,
[EndIP] bigint NULL,
[CountryCode] varchar (2) NULL,
[CountryCodeThreeLetter] varchar (3) NULL,
[CountryName] varchar (100) NULL

Note that we are using bigint data type for the IP data since the IP addresses in the csv file are not in the dotted decimal notation. Once you have the data in this table, you can simply use the stored procedure below to find the country corresponding to an IP (ok so this is not the most elegant piece of t-sql you’ll see but then t-sql has never been my strong point):

create function dbo.IPToCountry (@ip as varchar(15))
returns varchar(30)
declare @country varchar(30)

--declare @ip as varchar(15)
--set @ip = ''

declare @count1 as int
declare @count2 as int

set @count1 = 0
set @count2 = 0

declare @value as bigint
declare @tempvalue as bigint

set @count1 = charindex('.',@ip)

set @tempvalue = substring(@ip,1,@count1-1)
set @value = @tempvalue * power(2,24)

set @count2 = @count1 + 1
set @count1 = charindex('.',@ip,@count2)

set @tempvalue = substring(@ip,@count2,@count1-@count2)
set @value = @value + (@tempvalue * power(2,16))

set @count2 = @count1 + 1
set @count1 = charindex('.',@ip,@count2)

set @tempvalue = substring(@ip,@count2,@count1-@count2)
set @value = @value + (@tempvalue * power(2,8))

set @count2 = @count1 + 1

set @tempvalue = substring(@ip,@count2,1+len(@ip)-@count2 )
set @value = @value + (@tempvalue * power(2,0))

--select @value

@value >=StartIP and @value <=EndIP

return @country

Sometime later I’ll post a quick console application that allows you to lookup country from IP without using a database in the backend.

Monday, March 14, 2005

VSTO Workshop

You can find the code snippets used during the VSTO workshop in Bangalore on Saturday here. A few of you asked about the complete process by which an office document loads an assembly and executes it. This slide sheds light on it:

Wednesday, February 09, 2005

Globalization Workshop

I finished conducted the first software globalization and localization workshop yesterday. The presentations, lab walkthroughs and code samples used during the workshop can be found here.

One addendum to the above content is designing WinForms application for Middle-Eastern market (for use with BiDi scripts). To fully support RTL (Right To Left) locales such as Arabic, you need to set the RightToLeft property of your form to Yes. In addition you need to enable "mirroring". Unfortunately there is no System.Windows.Forms property that corresponds to mirroring. But you can easily achieve it by overriding the CreateParams property:

Protected Overrides ReadOnly Property CreateParams()As
        'Retrieve the CreateParams class to change the style
        Dim CP As System.Windows.Forms.CreateParams
        CP = MyBase.CreateParams
        'If the control needs RTL add these styles
        If _Mirrored Then
            CP.ExStyle = CP.ExStyle Or &H400000 Or &H100000
        End If
        Return CP
    End Get
End Property

In C# you do the same as:

protected override CreateParams CreateParams
  CreateParams cp = base.CreateParams;
    CreateParams cp = base.CreateParams;
    cp.ExStyle = cp.ExStyle | 0x400000 | 0x100000;
 return cp;

*minor modifications made to the code on 6 May 05, thanks Anonymous!

This is what your form would appear like once it is "mirroring" correctly:


Here some links that are must visit if software globalization/localization is your cup of tea:

Thursday, February 03, 2005

Search for a Notepad replacement

Without commenting on merits or demerits of Notepad, I'll simply state that I am badly looking for a free Notepad replacement. I've checked Notepad2 and NoteTab Light, but both of them balked when it came to full Unicode and complex script support. Even when these editors claim Unicode support, they don’t work with Indic/Far-Eastern IMEs (I get ???? when typing).

Right click in Notepad and pay attention to the last 3 menu items - Right to left reading order, Show Unicode control characters and Insert Unicode control characters. These options are important to me!

Sriram pointed me today to Syn. While it doesn't do Unicode and doesn't claim to be a Notepad replacement it does show some promise of being my long overdue XEmacs replacement ;-).

So folks, any ideas? What is that lean, mean, fast notepad replacement that you use (it must satisfy my somewhat esoteric requirements that the original notepad handles so well)?

Thursday, January 20, 2005

Welcome back Raj!

May I add in a low, menacing Agent Smith voice - "we missed you!". Those of you who know Raj would probably know that he has blogged for a brief interval before but just when things were getting nicely warmed up he pulled the plug :-(.. Well, he is back again - here. Hope you'll be around for a while this time Raj!

Saturday, January 15, 2005


While playing with different shades of blue I came up with two designs which look very "Austin Poweresesque". Do try setting them as your tiled wallpaper (which is if you are feeling retro too!)

Experimenting with different colors is turning out to be one of my latest hobbies.

Technical Notes: The latest version of Paint Shop Pro has an interesting feature whereby you can mix two colors on a palette like you would when painting in real life. You can always choose colors the normal "computer" way, i.e. by specifying their RGB or HSL values but the ability to blend colors in this way, adds an interesting dimension to the whole experience.

Thursday, January 13, 2005

Checking for presence of Indic support from .NET

The CultureInfo class under the System.Globalization namespace is indispensable when writing applications that require Globalization/Localization support. To create an instance of this class, you simply pass the name of the culture; e.g. to create an instance of hi-IN culture, I will do something like this:

CultureInfo ciHindi = new CultureInfo("hi-IN");

There are other CultureInfo constructors too for example there is one which takes the LCID of the culture you are interested in. So the above snippet could also be written as:

CultureInfo ciHindi = new CultureInfo(1081);

On English version of Windows - one most widespread in India - Indic and Far-Eastern language support needs to be installed separately from Control Panel:

If you do not have Indic support enabled, the user might get issues when displaying Indian language characters (e.g. trying to display CultureInfo.LocalName will simply show you a string of boxes). It might be a good idea to prompt the user to enable Indic support prior to running your application. Here is how you can check for its presence on a client machine:

using System;
using System.Globalization;

public class SamplesCultureInfo
    public static void Main()
        bool bIndicInstalled = false;
        // Displays several properties of the neutral cultures.
        foreach ( CultureInfo ci in CultureInfo.GetCultures( CultureTypes.InstalledWin32Cultures ) )
            if(ci.LCID == 1081) //hi-IN - since all Indic cultures are installed en-masse,
                     //presence of one indicates presence of others too
                bIndicInstalled = true;

            Console.WriteLine("Indic support is present on this machine");
            Console.WriteLine("Indic support absent from this machine");

Wednesday, January 12, 2005

Tooltips Redux

I had spoken a few days ago about tooltips in Web-UIs. They have one small shortcoming – you cannot control the visual appearance of the tooltip. The system default settings apply to your tooltip. There is (there usually always is!) a workaround. IE 5 had introduced a new technology called “behaviors”. In their simplest avatar, a behavior could be just a jscript file with the .htc extension. But there is more to behaviors, and I’d rather have you read about them here.

So why this digression from tooltips to behaviors? Well because there is a sample behavior that you can download from MSDN which gives you total control over appearance of your tooltips - they can contain HTML markup. This can come in especially handy when you are trying to show Indian scripts in a tooltip, which typically require slightly larger font for them to be legible. Here is an example (Thanks Vinod for supplying me with Tamizh translation!). More details about the tooltip behavior can be had from here.

Behaviors are close to 5 years old but can be used creatively with ASP.NET for creating some interesting UIs. (Hint: The IE Webcontrols use them internally). I’ll talk about an interesting use in one of my future posts shortly.

Monday, January 10, 2005

Converting ISCII to Unicode

The usage of computers proliferated into non-English speaking nations much before a unified global standard for representing data (Unicode) took shape. Different countries adopted different approaches to encoding data – most notable of them being the DBCS/MBCS we see for far-eastern languages (such as Simplified/Traditional Chinese, Japanese etc.). The idea was this – two characters of 1 byte each (between 128-255) when interpreted together designated one character – e.g. you combining Ê (0xCA) and ¯ (0xAF) gives you the ideogram for stone: 石 (Unicode 0x77F3) in Simplified Chinese. The system besides being prone to programming errors had some limitations – because the same lead-byte, trail-byte combination, depending on which “codepage” you are looking at ,can represent multiple languages, it is not possible to have documents with more than one far-eastern language (e.g. the same lead-byte (0xCA) trail-byte (0xAF) sequence gives you坒 (Unicode 0x5752) under Traditional Chinese codepage – two totally different characters!).

In India too, we had a similar indigenous encoding schemes, the most widespread of them being ISCII (Indian Script Code for Information Interchange) – the idea is very similar in that you use characters between 128-255 to denote Indian language characters. Depending on the ISCII encoding you chose, the same set of bytes could represent a different language.

The Encoding class in .NET allows you to convert between these encodings and Unicode. Recently while having a discussion with Dr. Pavanaja, it occurred to me that you can use the Encoding class to also do the conversion from ISCII to Unicode.

Let’s see an example (I chose to write it as a web-page and not a console app because the final Unicode result will not show up on console):

<%@Page Language="C#"%>
<%@Import Namespace="System.Text"%>
<%@Import Namespace="System.Globalization"%>

<script runat="server">
void Page_Load(Object o, EventArgs e)
    //Response.Write("Hello World");
    Encoding encFrom = Encoding.GetEncoding(1252);
    Encoding encTo = Encoding.GetEncoding(57008);
    String str = "ØÛÆèÄÜ";

    //Get it into a byte array...
    Byte[] b = encFrom.GetBytes(str);
    String strUnicode = encTo.GetString(b);


57002 denotes the ISCII Hindi Encoding. Other ISCII Encodings are:

Codepage NameLanguage
57002 x-iscii-de Devnagri
57003 x-iscii-be Bengali
57004 x-iscii-ta Tamizh
57005 x-iscii-te Telugu
57006 x-iscii-as Assamese
57007 x-iscii-or Oriya
57008 x-iscii-ka Kannada

'ØÛÆèÄÜ' is an Indic String – with the right software/font you should be able to view it. You can also create an HTML document (thanks agin to Dr. Pavanaja for the tip!) with the following Meta tag, to view the contents of the ISCII string without explicitly doing conversion to Unicode (though IE does it internally for you before rendering it using the sytem installed Indic Open-Type fonts):

<meta http-equiv="Content-Type" content="text/html; charset=x-iscii-de">

Friday, January 07, 2005


Tooltips can be a useful element even in Web UIs. For most tags you can specify the title attribute which gets rendered as a tooltip for that tag by IE. For the img tag, the alt attribute acts as its tooltip, but in case you also supply a title attribute, it overrides the value of the alt attribute.

Let’s look at yesterday’s example with tooltips enabled. I have also set the table-layout of our table’s style to fixed , so you no longer need another div inside the td (do a view source – that should clear things up a bit)

Have a great Weekend!

Thursday, January 06, 2005


It is common to have user interfaces that clip overflowing text and display ellipsis where the text crops. When you move your cursor over the clipped text, you will typically get a tooltip displaying the complete text. Since it is widely accepted that pictures are worth a thousand words, let me share a screenshot (of my Internet Explorer Bookmark pane – pressing Ctrl + I gets you there) to illustrate my point:

You can implement a similar UI in your web-based applications, by using the CSS text-overflow attribute. This is what you need to do:

  • Ensure that the text you want to clip is encapsulated in <nobr> </nobr> tags or set the white-space style attribute of the tag containing your text to nowrap

  • In the style attribute of your container tag – say div, set the width attribute to your desired width

  • In the style attribute of your container tag, set the text-overflow attribute to “ellipsis” and overflow attribute to hidden.

Let’s see a quick example of this in action.

Unfortunately, cropping text will not give you tooltips automatically. You can set the title attribute of the div to get the tooltips. Tooltips in web UIs is another interesting topic. I’ll take it up tomorrow!

Wednesday, January 05, 2005

When friendly is not friendly

Internet Explorer introduced “Friendly HTTP Error Messages” for certain HTTP errors (400, 403, 404, 405, 406, 408, 409, 410, 500, 501, 505). For instance if your ASP page does something bad that results in HTTP 500 error, IE will typically display a friendly message to the user, which looks something like this:

Additionally, the error message might contain other information that was generated by the offending page. If the error message produced by your page is more than 512 bytes (the thresholds are stored in the key HKEY_LOCAL_MACHINE\Software\Microsoft\Internet Explorer\Main\ErrorThreshold) then IE does not show the friendly error page but the entire output from the webserver as it is. Which is why you might not get these friendly messages when woking with ASP.NET; given the verbose nature of error messages generated by them.

Friendly or not, as a web developer, IE’s substituted messages might come in the way of debugging your page. They can be disabled from Tools -> Internet Options -> Advanced:

I use the cluster of 3 radio-buttons (Underline Links) as a landmark to quickly locate the right checkbox in this crowd of checkboxes.

Tuesday, January 04, 2005

Automating ftp.exe sessions

ftp.exe is a command line tool that you use to connect to ftp servers. What is not very widely known about this tool is that it allows you to automate an ftp session by supplying a script which has the relevant ftp commands.

Let’s say we need to logon to the host – and download all the files in the dump directory on the server, we would first create a simple text file – say commands.txt which look something like this:

user username
pass password
cd dump
mget *.*

Then when using ftp.exe from command prompt, we can supply this text file as an argument to it:

ftp –s:commands.txt

that should do it!

Also see: Using FTP Batch Scripts

Monday, January 03, 2005

The customary Hello World!

I started blogging some 18 months ago. There are things about technology in general and computers in particular that I’d love to write about, but given the general nature of posts in the other blog, I decided to keep material of technical nature away from it. There were attempts, half-attempts, failed attempts at starting a technical blog; none materialized into a blog URL I could attest my name to.

My friend Anand – who incidentally was the one who initiated me to Blogging, was kind to extend me an offer to blog with him jointly. I made all but two posts and got entrenched in quagmire of things at work that kept me off from it. My sincerest apologies Anand!

While spending 8 days of vacation where I tried diligently avoiding computers, it became clear to me that I still fundamentally love computers (distance makes hearts grow fonder ;-)) – and more importantly I love sharing all the exciting things that I discover or do (with them, on them, to them ;-)). So here it is - another entry to the technical blogsphere. I hope, especially if you’ve read so far, that you’ll find the stuff I post in future, worth your time!

Now to address a question, which I prognosticate will be certainly asked of me tomorrow – why Blogger. Don’t you work for MS – and so aren’t you supposed to show your allegiance by using Aren’t you being perfidious!? are great – especially in the light of the fact that they are in v. 1.0. But I find them limiting in the regard that they don’t allow me to edit their HTML templates. I am a DHTML geek at heart and it hurts me to not tweak the defaults. The boxes you see on this blog (on your right), are built using inline jscript generated by an ASP.NET page, residing on anther server, which is querying amzon web-services and is fetching meta-data of my books and CDs in real-time – that kind of stuff just wouldn’t have been possible. Then there is an even more fundamental issue of aesthetics – I just can’t get myself to like either msn’s default font or any of the bundled image-background templates. That should settle it. It is not a downright repudiation of, but a conscious choice based on a set of reasons.