Featured Posts

Tools I use Visual Studio Addins 1. GhostDoc This is a free addin that automatically generates the XML comments for your code. Click on the method/field name and press Control + Shift + D and it generates the XML...

Readmore

New UI for my website! Hello, I have modified the UI of my website and have moved all my blogs from my old blog site. There were few comments from my site visitors and friends that site was not rendering properly in Google Chrome...

Readmore

Setting custom toolwindow icon for Visual Studio add-in I recently completed a minor update to my Favorites Menu for Visual Studio add-in. The new installer is already put under ‘My Development’ section on my site. The update includes a minor bug fix...

Readmore

Set devenv to run your Visual Studio version Recently I found out that my wife has VS 2003, VS 2005 and VS 2008 all installed in her laptop. It is our usual practice that we hit devenv in Windows run menu to open our Visual Studio IDE. So whenever...

Readmore

  • Prev
  • Next

Tools I use

Posted on : 16-12-2009 | By : Utkarsh Shigihalli | In : .net, development, personal

0

Visual Studio Addins

1. GhostDoc

This is a free addin that automatically generates the XML comments for your code. Click on the method/field name and press Control + Shift + D and it generates the XML comments for you.

GhostDoc provides two commands.

a. Build Documentation

b. Re-build Documentation

I usually set default keyboard shortcut Control + Shift + D to Re-build Documentation as it helps me in re-writing the documentation whenever I change signature of the method, or rename the parameters.

2. PowerCommands for Visual Studio

This is available from Microsoft itself and it is open source!. I am listing down few of its features below.

  • Collapse projects
  • Unload/Reload projects
  • Remove and sort usings
  • Open containing folder
  • Open command prompt
  • Extract constant
  • Clear recent lists
  • and more…

powercommands

3. DPack

This has awesome set of features but I feel it has not got the popularity it deserves. This is the first thing which I install after installing Visual Studio.

From the developer site:

DPack includes various browser tools that allow the developer to quickly find solution files, types, particular type members, methods or properties for instance, or quickly find and reference standard .NET framework types.

I use its “File Browser” window a lot to quickly open the files in the solution. Similarly you can browse through the members/ types in the whole solution using “Solution Browser”. And “Framework Browser” window allows you to locate a type, its corresponding namespace and assembly.

dpack

6. Favoroites Menu for Visual Studio

This is the tool I developed long back. This tool provides you the same functionality of any browser favorites menu. To be more clear, this tool allows you to mark any files in Visual Studio as your favorite file. The tool allows you to tag the file for easy searching. You can read more details about this tool in my website under “My Development” section.

7. Source Code Outliner PowerToy

From the author:

The Source Outliner PowerToy is a Visual Studio 2008 extension that provides a tree view of your source code’s types and members and lets you quickly navigate to them with filtering inside the editor.

Developer Tools

1. Console2

A multi-tab based console window. I regularly use this and add VS 2005, VS 2008 and sometimes PowerShell console windows. Some of the special features include multiple tabs, text editor-like text selection, different background types, alpha and color-key transparency, configurable font, different window styles.

2. BareTail

A tiny free real-time log viewer and log message highlighter.

3. Process Monitor

Popular sysinternals tool. While developing the Visual Studio add-ins, I need to watch Visual Studio activity to identify whether my add-in dll is being loaded etc. For this, I usually filter the processes for devenv.exe.

From the author:

Process Monitor is an advanced monitoring tool for Windows that shows real-time file system, Registry and process/thread activity

4. Reflector

Needs no explanation!

System Tools

1. XNeat Windows Manager Lite edition

Tool to hide, roll up windows, change order of task bar buttons etc.

2. Everything

A tiny, super fast indexed search engine for searching files and folders.

3. Launchy

One of the popular launchers.

4. Dexpot

A free virtual desktop creation and management tool.

5. TeraCopy

A super fast copier with features to pause, resume file transfers. I have replaced the default copy handler after I found this.

6. CCleaner

A popular system junk cleaner, registry cleaner, startup manager tool. Freeware.

8. CutePDF writer

A free PDF printer.

Text Editors

1. PSPad

A syntax highlighting text editor. This one is my favorite. I regularly use it for formatting the HTML. Also has downloadable scripts to beautify JS etc.

2. Notepad++

Another open source free text editor.

Messengers

1. Digsby

A multi protocol messenger. Support all major messengers like GTalk, MSN, Yahoo, AIM etc. It can also alert you if you have any new messages in facebook, linked in etc. There is real competition between Pidgin and Digsby. I use Digsby mainly for its social networking capabilities.

Utilities

1. PrintScreen

A free screenshot taking tool.

2. ColorPix

A small free color picker. Once you found the color of your choice, press Space key will lock the color so that you can use it.

Zip Utilities

1. 7-Zip

A file archiver supporting all major compression algorithms.

Set devenv to run your Visual Studio version

Posted on : 09-09-2009 | By : Utkarsh Shigihalli | In : .net, development

0

Recently I found out that my wife has VS 2003, VS 2005 and VS 2008 all installed in her laptop. It is our usual practice that we hit devenv in Windows run menu to open our Visual Studio IDE. So whenever my wife hit devenv in run window, it always opened VS 2003 editor, where as she wanted it to open VS 2005.

I just now found out how to change this behavior. Windows run menu works by identifying the commands in the particular registry entry.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths

The devenv.exe, and its path is defined in that registry key.

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\App Paths\devenv.exe

So when you install VS 2005/2008 and then install VS 2003, this registry key is overwritten.

So you can rewrite this path of devenv.exe to set the proper behavior.

Default path to Visual Studio 2005:

C:\Program Files\Microsoft Visual Studio 8.0\Common7\IDE\devenv.exe

Default path to Visual Studio 2008:

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\devenv.exe

Disclaimer: Modifying the registry can cause serious problems that may require you to reinstall your operating system. Use the information provided at your own risk.

Setting custom toolwindow icon for Visual Studio add-in

Posted on : 12-08-2009 | By : Utkarsh Shigihalli | In : .net, programming, vsx

0

I recently completed a minor update to my Favorites Menu for Visual Studio add-in. The new installer is already put under ‘My Development’ section on my site.

The update includes a minor bug fix i.e, toolwindow icon is not set properly inside Visual Studio 2008. I do not remember from where I got the following code, but this worked for me.

Paste the below code in to a Utililty.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
public class MyIcon
{
	private static Color GuessTransparentColor(Bitmap bitmap)
	{
		Color pixel = bitmap.GetPixel(0, 0);
		Color color2 = bitmap.GetPixel(bitmap.Width - 1, 0);
		Color color3 = bitmap.GetPixel(0, bitmap.Height - 1);
		Color color4 = bitmap.GetPixel(bitmap.Width - 1, bitmap.Height - 1);
		if (pixel == color2)
		{
			return pixel;
		}
		if (color2 == color3)
		{
			return color2;
		}
		if (color3 == color4)
		{
			return color3;
		}
		return color4;
	}
	public static Bitmap PrepareImage(Image image, Color transparentColor)
	{
		Bitmap bitmap = new Bitmap(image);
		Bitmap bitmap2 = new Bitmap(0x10, 0x10, PixelFormat.Format24bppRgb);
		Color color = guessTransparentColor(bitmap);
		for (int i = 0; i < bitmap2.Width; i++)
		{
			for (int j = 0; j < bitmap2.Height; j++)
			{
				Color baseColor = color;
				if ((i < bitmap.Width) && (j < bitmap.Height))
				{
					baseColor = bitmap.GetPixel(i, j);
				}
				baseColor = Color.FromArgb(0xff, baseColor);
				if (baseColor != color)
				{
					bitmap2.SetPixel(i, j, baseColor);
				}
				else if ((transparentColor != color) && (baseColor == transparentColor))
				{
					if (baseColor.R > 0)
					{
						bitmap2.SetPixel(i, j, Color.FromArgb(baseColor.R - 1, baseColor.G, baseColor.B));
					}
					else
					{
						bitmap2.SetPixel(i, j, Color.FromArgb(baseColor.R + 1, baseColor.G, baseColor.B));
					}
				}
				else
				{
					bitmap2.SetPixel(i, j, transparentColor);
				}
			}
		}
		return bitmap2;
	}
	public static Bitmap PrepareImage(Bitmap image, Color transparentColor)
	{
		Bitmap bitmap = new Bitmap(image);
		Bitmap bitmap2 = new Bitmap(0x10, 0x10, PixelFormat.Format24bppRgb);
		Color color = guessTransparentColor(bitmap);
		for (int i = 0; i < bitmap2.Width; i++)
		{
			for (int j = 0; j < bitmap2.Height; j++)
			{
				Color baseColor = color;
				if ((i < bitmap.Width) && (j < bitmap.Height))
				{
					baseColor = bitmap.GetPixel(i, j);
				}
				baseColor = Color.FromArgb(0xff, baseColor);
				if (baseColor != color)
				{
					bitmap2.SetPixel(i, j, baseColor);
				}
				else if ((transparentColor != color) && (baseColor == transparentColor))
				{
					if (baseColor.R > 0)
					{
						bitmap2.SetPixel(i, j, Color.FromArgb(baseColor.R - 1, baseColor.G, baseColor.B));
					}
					else
					{
						bitmap2.SetPixel(i, j, Color.FromArgb(baseColor.R + 1, baseColor.G, baseColor.B));
					}
				}
				else
				{
					bitmap2.SetPixel(i, j, transparentColor);
				}
			}
		}
		return bitmap2;
	}
	public static Bitmap PrepareMask(Image image)
	{
		Bitmap bitmap = new Bitmap(image);
		Bitmap bitmap2 = new Bitmap(0x10, 0x10, PixelFormat.Format24bppRgb);
		Color color = guessTransparentColor(bitmap);
		for (int i = 0; i < image.Width; i++)
		{
			for (int j = 0; j < image.Height; j++)
			{
				Color pixel = bitmap.GetPixel(i, j);
				Color color3 = ((pixel == color) || (pixel.A < 0xff)) ? Color.White : Color.Black;
				bitmap2.SetPixel(i, j, color3);
			}
		}
		return bitmap2;
	}
	[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Auto)]
	private struct SHFILEINFO
	{
		public IntPtr hIcon;
		public int iIcon;
		public int dwAttributes;
		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 0x100)]
		public char[] szDisplayName;
		[MarshalAs(UnmanagedType.ByValArray, SizeConst = 80)]
		public char[] szTypeName;
	}
	public static Icon GetIconFromFile(string path)
	{
		SHFILEINFO psfi = new SHFILEINFO();
		SHGetFileInfo(path, 0x80, ref psfi, Marshal.SizeOf(psfi), 0x111);
		return Icon.FromHandle(psfi.hIcon);
	}
	[DllImport("shell32.dll", CharSet = CharSet.Auto)]
	private static extern IntPtr SHGetFileInfo(string pszPath, int dwFileAttributes, ref SHFILEINFO psfi, int cbFileInfo, int uFlags);
	[DllImport("oleaut32.dll", CharSet = CharSet.Auto, SetLastError = true)]
	internal static extern int OleLoadPictureFile(object fileName, [MarshalAs(UnmanagedType.IDispatch)] ref object iPictureDisp);
	public static Color VS_MENUCOLOR = Color.FromArgb(0xec, 0xe9, 0xd8);
	public static Color VS2005_COLOR = Color.FromArgb(0, 254, 0);
	public static Image GetImageFromAnyFormat(string path)
	{
		string str = path.ToLower();
		if (str.EndsWith(".exe") || str.EndsWith(".ico"))
		{
			return GetIconFromFile(path).ToBitmap();
		}
		return Image.FromFile(path, true);
	}
	protected static object OleLoadPictureFile(string fileName)
	{
		object iPictureDisp = null;
		OleLoadPictureFile(fileName, ref iPictureDisp);
		return iPictureDisp;
	}
	public static StdPicture CreatePictureDisp(Image image)
	{
		return (StdPicture)ImageConverter.GetIPictureDispFromImage(image);
	}
}
class ImageConverter : AxHost
{
	internal ImageConverter()
	: base("52D64AAC-29C1-CAC8-BB3A-115F0D3D77CB")
	{
	}
	public static IPictureDisp GetIPictureDispFromImage(Image image)
	{
		return (IPictureDisp)AxHost.GetIPictureDispFromPicture(image);
	}
}

Usage:

1
2
3
4
5
6
7
8
9
10
if (string.Equals(@"Software\Microsoft\VisualStudio\8.0", _applicationObject.RegistryRoot))
{
	//If VS 2005
	_myFavoritesWindow.SetTabPicture(Resources.favicon.GetHbitmap());
}
else
{
	//If VS 2008
       _myFavoritesWindow.SetTabPicture(MyIcon.CreatePictureDisp(MyIcon.PrepareImage(Resources.favicon, MyIcon.VS_MENUCOLOR)));
}

Note:
1. The code above is not tested extensively on different machines.

2. Before using the above code you can check a nice article by Carlos Quintero. He has also written how the icon can be set for Visual Studio 2010 toolwindow.

Singleton Pattern vs. Static Class

Posted on : 13-11-2008 | By : Utkarsh Shigihalli | In : .net, c#, programming

0

The singleton pattern ensures a class has only one instance, and provide a global point of access to it.

There is a nice article about choosing between Singleton pattern and the static class here with examples.

DebuggerStepThrough attribute

Posted on : 06-11-2008 | By : Utkarsh Shigihalli | In : .net, c#, programming

0

Pedram Rezaei has written how we can let .NET debugger know, not to step in to certain elements of your program with the help of DebuggerStepThroughAttribute.

Read it here

TypeCode enum in C#

Posted on : 09-06-2008 | By : Utkarsh Shigihalli | In : .net, c#, development

0

Recently, one of my friend digged in to metadata of TypeCode enum type and found out that, it does not have value 17 in it.

typecode

Even I was surprised to see this, and wanted to know the reason behind value 17 missing from the enumeration.

I googled and found a link to blog which explains, why the value 17 has been missed from the enum.

From the author:

We’ve had this “hole” in the TypeCode enum since October of 2000, and I can’t find an older set of bits. But, I’m sure that comment in IConvertible is right – this used to be TimeSpan. For TimeSpan, it’s possible we thought it would be interesting for a while, then we realized that frankly not that many people need to convert a Decimal to a TimeSpan, then removed it.

You might ask why we didn’t “fix” the enum when we removed whichever of these values we had originally added. It turns out that whenever we have a breaking change internally, we need to recompile all the code that might possibly depend on the removed or changed public surface area. For us, that would mean rebuilding everything that might have referred to TypeCode.String, whose value would have changed from 18 to 17. While we do go through that process internally in DevDiv, it is costly & painful for us.

Accessing Master page properties

Posted on : 14-05-2008 | By : Utkarsh Shigihalli | In : .net, asp.net

0

Other day I needed to access the property defined in Master page and was facing an issue. The issue was what if the master page is renamed? The namespace would change and it will break the code.

I googled for a better option and found exactly what I wanted. Below is the link where the author has neatly explained how this can be done.

http://dotnetbyexample.blogspot.com/2007/10/right-way-of-accessing-master-page.html

ASP.NET State Server error!

Posted on : 20-02-2008 | By : Utkarsh Shigihalli | In : .net, development, programming

0

After a full day work, I deployed my project which is an mobile web application, on to a testing server yesterday. The application is built using .net framework 1.1.

After deployment, I hit the URL in the web browser, and to my shock got the below error.

error1

Thankfully, the error stated how to resolve error “Please ensure that the ASP.NET State service is started…”. I hit services.msc from run menu and yes, ASP.NET State Service was not running!. I started it, and refreshed the URL, the page appeared!

Good that I fixed the problem immediately, thanks to asp.net for conveying error neatly this time!