Friday, September 12, 2008

App_Code in VS 2005 and web-related projects

I must be doing something terrible wrong since my VS2005 web application does not "see" the public enums/classes inside App_Code.

I tried adding a ASP.NET Web Application Project (VB) to an existing solution. I then manually created App_Code folder and placed a file which defines (without a namespace) a class and an enum. No brainer. Then I added a web service called HR.asmx and placed:

<%@ WebService Language="VB" CodeBehind="~/App_Code/HR.vb" Class="HR" %>

I've added HR.vb into the App_Code.

Trying to build the web app project fails complaining it does not see these classes within the App_Code folder. I have another web site project in that solution and it builds with the exact same setup in App_Code. The obvious differences that I can see are:

  • The new one contains a Project file pointing to .vbproj file (no file path)
  • The old one has a "Full Path" and the project solution explorer name actually contains a path on the disk (something like E:\...\blah)
  • The old one contains a section Developer Web Server for project properties.
  • The old one has an option for Property Pages
  • The new one has a Properties (which opens up, among other things, a Web section where deployment via IIS/personal web server are possible)
  • The new one keeps offering a "Convert to web application" option through a right mouse click
  • The old has Build Web Site... and Publish Web Site... right-click menu options (vs a normal Build/Rebuild and a Publish... on the new Web app project)
This is what my solution explorer shows. Notice that the iconss are slightly different + the name of the first one starts with E:\...

It looks like that I've created something other then the "web application" project since my old project simply does not have these options that I see on the new one.

All this effort was due to a deployment problem I had. My customer happily uses VS2005 for project deployments. I've been trying to get my NAnt/CruiseControl to build and deploy (it works on my end of course), however, after talking to the customer I wanted to get the VS2005 to do its "Publish Website" option, thinking that it really ought to work just fine. It didn't and now I see that there's something that I did not do properly.

Any ideas/comments?

1 comment:

sjusic said...

I've managed to figure out a few things about my troubles.

Since I have created the solution some time ago, I had a VS2005 Team Suite (no service pack, etc). This means that I was adding a "New Web Site" project to the solution.

Later on, I've installed VS2005 SP1 which introduced support for the "old style VS2003" web projects. This also meant that when you choose Solution ... Add New Project there was a template for a ASP.NET Web Application which was normally not there.

My problems happened when I did a copy-paste from the new Web Site project to the Web App Project. Not sure what the deal is there, but after some testing around I noticed that doing things manually actually picks-up the App_Code/ folder classes even for the Web App project.