Programming
Article
By aspatton

Case-sensitive code

By aspatton

One situation I’ve witnessed numerous times is the fact that C# and the .NET platform is case-sensitive. This seems to cause problems for older Windows develoeprs that migrated from Visual Basic. One particular problem I encountered recently with an ASP.NET application was located in the Web.config file. The following line caused a problem with the application and the developer couldn’t figure out why:



Now, this is not invalid XML but it does conform to the design of the ASP.NET appSettings element. The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. Notice, the first letter of settings is capitalized, and the fact that it was not capitalized caused a problem. The server return the following error when the application was started:

Unrecognized configuration section ‘appsettings’

Now, it took me a few seconds to realize the problem but it illustrates the point that the .NET platform is largely case-sensitive unless you utlize VB.NET as your language (but the Web.config remains case-sensitive regardless of the language). The correct Web.config entry would be:



These issues exist in the C# and J# languages as well, but those can be caught during compilation.

Recommended
Sponsors
The most important and interesting stories in tech. Straight to your inbox, daily. Get Versioning.
Login or Create Account to Comment
Login Create Account