Daily .Net Tips

.NET Tip a Day, Keeps painkillers away!

The String Intern Pool

String forms a large part of a program. Irrespective of what the program is used for, almost 70% of the actual program code (approx) is generally formed by strings. As we all know .NET strings are immutable. Producing large number of string constants inside a program or assigning same string to more than one objects can eat up  the object heap. .NET provides String Intern Pool to help in optimizing the usage of strings.

String Intern Pool is a special table allocated on Large Object Heap which maintains references of all strings that are created on a program. CLR keeps track of those strings that are created in memory and uses it when it needs to create the same string again. This ensures that new memory is not used whenever the content of the string is not different.
[Read the rest of this entry...]

Configuring Pinging in IIS 7.0 / 7.5 to avoid terminating processes while debugging from Visual Studio

IIS monitors the worker processes health by sending a periodic request the worker processes. This pinging is to ensure that if the worker processes responding the incoming requests in timely manner. If the worker process does not respond in a timely manner, IIS terminates the process after a specific number of ping.  Now, consider you are debugging your web application by attaching w3wp.exe from Visual Studio.  During debugging, it might take a long to find out result of debugging and as an out come, execution is on hold as you are pausing around with some breakpoints or playing around the code.

[Read the rest of this entry...]

How to detach a particular process instead “Detach All” in Visual Studio ?

Visual Studio processes windows  shows the list of attached process and  it also helps to detach a particular process from the list of attached process.  Let’s assume you have 4 process attached with visual studio for current application. If you use “Detach All”,  Visual Studio will detach all the process apart from the process which can cause the termination of application ( like ASP.NET Local Development server for an ASP.NET Web Application )

[Read the rest of this entry...]

How to get list of attached processes in Visual Studio while debugging ?

While debugging in Visual Studio, we used “Attach To Process” window to attach a particular process. We can use the same window to attach multiple processes as well.  “Attach to Process” windows grayed out the processes which are already attached and “Attach” process comes as disabled if you try to attach an grayed out process as it’s already attached.

[Read the rest of this entry...]

Surround-with Code Snippets in Visual Studio

Surround with” is a very nice features in Visual Studio IDE. The overall objective of this features is to surround the code snippets with a set of statement or controls very easily. Let’s assume that, you have set of code block which you want to put inside a if statement, so instead of writing the statement complete, first select the code block, right click and select “Surround with” from context menu.

[Read the rest of this entry...]

Refactoring Code Rename Members using Visual Studio

As I have been discussing about Refactor menu yesterday, Visual Studio comes up with really nice features on Refactoring code using the refactor menu options. In this post I will cover how to Rename your code using Refactor “Rename” menu option.

Let us suppose we have a member in our code called FetchMember, and we need to rename the member name, its all overloads and even everywhere it is used, all at a time, one thing you can do is to use Find option in visual studio, but if FetchMember is somewhat generalized and need to be changed only to this Type, and usage restricted to this type only, then manual task of rename would be lot of pressure.
[Read the rest of this entry...]

Refactoring Code using Visual Studio Extract Method

Visual Studio being an intelligent IDE does gives us a number of features that enhance the development of application as well as enhancing the way of coding continuously. One of such feature that has been added to VisualStudio IDE is refactoring. In this post we will see how easily we can use Refactoring feature of Visual Studio to get things done easily.
[Read the rest of this entry...]

Comment and Uncomment for CSS Editor in Visual Studio 2011 Developer Preview

CSS editor in Visual Studio 2011 introduced many new features for web developers and it helps developers to work with CSS more efficiently and organize way. I talked about such two features over here http://abhijan.me/yCL4LH and http://abhijan.me/zvnmqu . CSS editor has another enhancement, which is “supporting direct code comment and uncomment”.

[Read the rest of this entry...]