Console Application - Visual Studio gotcha on x64 OS

1 minute read

I was playing around a bit with Enterprise Library 5.0 and it's Logging block. I figured it would be a very simple scenario: Enterprise Library is there to assist us with the most common practices isn't it?

I created a solution with a Database project, a Class Library project and a very simple Console Application project, while following the Enterprise Library documentation to log to a database.

So far so good:

  • The database was deployed properly with all required tables, keys and stored procedurs.
  • The console application had it's proper entlib-configuration.

However, when running the console app, I noticed that nothing was written to the database. No exceptions were thrown either. I checked, double checked and triple checked the configuration: all seemed fine. Spooky!

Hours of my time went into debugging the 5 lines counting program until I noticed the Build output: *"1 project skipped". *It was the class library that contained my LoggingProvider.

Damn! Everything compiled, no exceptions, no config errors... Only that Visual Studio decided to not compile my class library!

I was developing on a Windows 7 x64 operating system. I first created the class library project and then added a new C# Console Application project to the solution.

It turns out: new C# Console application projects target the x86 platform by default!

"When creating a new Visual C# Console Application in VS2010 for .NET 4.0, the default target settings for the project is to target the x86 platform instead of Any CPU (MSIL) like Visual Studio 2008 does"

I fixed the issue by targetting the x86 platform in my class library: all of the sudden, my console app was logging to the database using EntLib 5.0...

Unexpected gotcha!

Leave a Comment