The virtual path ‘/App_Resources/dev/mycontrol.ascx’ maps to another application which is not allowed

Getting to the root of the problem
 

I had been trying to set up a development environment for Visual Studio so that instead of using the in-built Development Server (Cassini) I could use IIS. Since I had to develop on a Windows XP machine my first problem is that I could not create more that one Web Site under IIS 5.1 so I had to resort to using Virtual Directories for the applications (A Web app and a WCF app). This differed from the live setup where each was configured under its own web site and this is where my problems started. When I fired up the web application I was greeted with this error – The virtual path ‘/App_Resources/dev/mycontrol.ascx’ maps to another application which is not allowed.

The web application used the concept of loading controls from embedded resources using the LoadControl() method and this was causing the error. In the live environment the application is always at the root for the website because of the deployment configuration, however in my scenario the web app was located in a virtual directory off the root web site. The issue occurs because the virtual path ‘/App_Resources/’ assumes that it is at the web site root rather than the application root. To solve the problem I just need to add a tilde (~) to the front of the virtual path in the managed code so it became ‘~/App_Resources/dev/mycontrol.ascx’. I also found instance in the JavaScript code where this situation occurred but this time we just need to use the dot notation to indicate the root folder. The virtual path in the script became ‘./App_Resources/dev/mycontrol.ascx’

For information on loading webforms and usercontrols from embedded resources take a look at http://www.codeproject.com/KB/aspnet/ASP2UserControlLibrary.aspx

Skype interfering with IIS

I have been working at a client who is using Windows XP on their development boxes and came across this issue the other day when I tried to start IIS – Unexpected error 0x8ffe2740 occurred. I had a look in the System Event log and found an Error for the W3SVC service – The service could not bind instance 1. I like to have a quick look at http://www.eventid.net in these situations as the Event ID (115) will usually have an explanation for what caused the error along with some helpful responses from people who have had the same issue.

My first clue pointed me to this article about the problem which suggested that another service/application was already using port 80. Doing a bit more searching I came across another blog which provided me with a better solution… Skype was getting in the way! Since Skype will use port 80, if its free, it was stopping IIS from using the port. Fortunately this is an option in Skype you can turn off. Just deselect the check box (highlighted below) and then restart IIS.

UPDATE : I have also encountered this issue on a Windows 7 machine I was using for development which was highlighted by this article. The fix to the problem was the same as detailed above.