August 2006 - Posts

Per Kevin's request, I am writing about what the App_Code folder is and what it is meant for. The origin of the App_Code folder is the fact that namespaces were effectively removed from the .NET 2.0 style of web projects. Namespaces can still be used but they were trying not to make them necessary any more. Basically, the way the App_Code folder functions is that any class that you drop in there can be accessed anywhere in the project.

In large enterprise web sites, you would probably hardly ever use the App_Code folder, because most likely you have all of your classes in another class library. For small simple sites, the App_Code folder makes a lot of sense to have a common place to put your extra classes.

If you migrate a 1.1 project, most likely you will end up with some classes in the App_Code folder (whether they are supposed to be there or not). The migration wizard basically will move any .cs or .vb (i.e.: class files), into this folder if it is not associated with a control or web page. The global.asax.cs (or .vb in the case of Marcus) will also be placed in here after a migration (in new projects when you create a global.asax it puts all the code inline in the asax file itself without a code behind).

Other files that will usually be placed there in new projects are the code behind for web services.

Lastly (as mentioned by Bobby), depending upon your compilation option, typically everthing in the App_Code folder will be compiled into a single DLL. So there you have it, the mysteries behind the App_Code folder revealed.

By now, you have probably used the App_Code folder. Today, I encountered a fairly common error that can occur when working with a project that has multiple programming languages (i.e.: C# and Marcus's favorite Visual Basic .NET). When you add a C# file to an App_Code folder containing VB files and compile you will get an error similar to the following.

'App_Code/file.cs' and 'App_Code/file2.vb' use a different language, which is not allowed since they need to be compiled together.

The reason you receive this error is that by default everything in the App_Code folder gets compiled down to a single DLL which means the langauges can not be different. This is easy enough to fix, simply create a new subfolder in the App_Code folder (i.e.: CS or VB), and then add the following elements to the compilation node of the web.config.

        <add directoryName="CSCode" />

Making this simple change will allow you to have seperate subdirectories for different programming languages.

Ok for those ultra dorks out there, this is really cool. Microsoft has announced that they are releasing a version of XNA Studio (called Express) for free. This allows novice developers to actually develop Xbox 360 games. XNA studio provides a managed environment using a custom implmenetation of the .NET compact framework. What is cool is that it can compile to both the PC and Xbox 360 platform as simple as changing from debug to release.

I believe Microsoft is the first console developer to ever open up their system to hobbyist developers. This is way cool.

XNA Studio Express Press Release

If you created an app that is running MSDE for some reason or you have someone else's crappy app that is using MSDE, you should be happy to know that it will not run in Windows Vista. Time to upgrade to SQL Server Express.

More Info Here