Tuesday 20 July 2010

The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)

 IIS Manager Error: The process cannot access the file because it is being used by another process. (Exception from HRESULT: 0x80070020)

The above is the exception comes most of the times when you are using the default web site in windows 7. Automatically it will stop the site and when we try to start then the above exception is coming. Because of it, no web sites, applications are running and unable to proceed to any further step. I know that the default web site uses the port number 80 by default. For testing purposes I have changed the port number to 9999 and tried to start the default web site and surprisingly it started and everything running fine. So, I fixed to the problem that the issue is only because of the port 80. I came to conclusion that someone else other than IIS web site is using the port 80.

Now, we found the problem. We need to look for solution. But, how to know who are using the port 80 other than IIS?

 Here is the post on it. "How to find what process is using which port?". The helped me a lot to find out the problem in minutes.

So, by following the steps in above post, found that the Skype is the culprit. Don't know why Skype needed the port 80. Actually there is no need to use port 80 by Skype. But, it's weird. Only Skype team can know about this.

So, finally to resolve this problem:
  1. Open the task manager and kill skype process.
  2. Go to IIS, and then start the default web site on port 80.
  3. Do once IISRESET.
That's it. Everything should start working. Now, you can start Skype and use both. Enjoy.
Note: Make sure in this case it is Skype, tomorrow some other third party software. So, you should carefully read the post "How to find what process is using which port?" to resolve these kind of problems.
Hope you enjoyed it.

How to know what process is using which port in windows

I believe this is going to be a very helpful post to most of the readers. So many times I need to know about this. This is a great tip to resolve so many problems. So, it is one of my hot tips for identifying the problems.

We usually install third party software like Skype, TeamViewer etc. in the windows OS, then they will default take some port numbers available. Then there are chances they will create some problem as explained below. [This is why we need to take care of installing software on the servers or production machines. We should install if and only if we really need them. :)] Below is the complete scenario.
  1. I have service 1 which is not running right now and I have assigned port number 80 for the service. 
  2. I have installed the third party software and assigned port number 80 or by default it has taken port number 80 without knowing me. 
  3. Now, there is a need to start service 1 in my system and use it.
  4. But, it never starts. Because the same port number is already allocated to something else process... So, in this situation we can't find the problem very easily. 
We need to do some investigation here. Below is the process we need to follow. First we need to find out what all processes using which port. And then find out the result process list and take further action.

Finding which process is using which port number:
  1. Open command prompt by going to Windows --> Run or [Start + R]. 
  2. Type cmd in there and hit enter.
  3. Now, you came up with command prompt window.
  4. Type the syntax exactly as shown. netstat -aon | findstr 0.0:80
In the above syntax a means active, o means include process ID's and n means the port numbers in the result. findstr is the attribute in the command to find out only the strings which has the string given. It only finds which has the given string matched to shorten the result.

Below is the sample output I got when I used the command.

The result order is, TCP protocol,  port, listening status, process id. The last column is the process id.

Find out what is the process from process id:
Now, it is the time to find out what is the process  which has the ID 4?
To know the process and their ids we have two options. Either go to the windows task manager  --> services tab and you can see all the processes with their process ids or from command prompt.
Use the command tasklist | findstr 4. It will list all the processes which has 4 in it as shown below. See all and check everything and find out what you need.

Hope this post helps to solve the problems. Enjoy the nice series of posts.

Friday 16 July 2010

More SharePoint 2010 templates in Visual Studio 2010

I am working on SharePoint 2010 these days and all the development is on Visual Studio 2010. The IDE is very cool and great features. Really very helpful for developers and administrators as everything is builtin like deploy, configure and easy development. I really love it. There are plenty of SharePoint 2010 templates are available by default in Visual Studio. Here are some from Microsoft with extra templates. Install them and use them for time saving and learn more...
http://code.msdn.microsoft.com/vsixforsp

Detect request is from iPad in ASP.NET

iPad. People slowly liking it. Few days ago, I have written a post on how to detect the request is from the iPhone. So, as iPad applications are also growing day to day, I want to give you a small tip on how to detect requests are from iPad. So that you will write logic which is specific to the iPad like html, CSS, scripts etc.

Detect request from iPad in ASP.NET [C#]:
if(HttpContext.Current.Request.UserAgent.ToLower().Contains("ipad"))
{
     //iPad is the requested client. Write logic here which is specific to iPad.
}
else
{
     //Normal browsers [from computers] requested.
}

Detect the iPad request in Java script:
if (navigator.userAgent.match(/iPad/i)

Very simple, isn't it. Hope this helps.