≡ Menu

When building a console app with the csc task in NAnt, set the correct target

Today, I crafted some XML to build a console application using a csc task in NAnt. The app built fine (hooray), but then I spent the best part of the afternoon trying to work out why I kept getting the following error when trying to run the application:

EventType clr2or3 error text

That’s right, the dreaded “EventType clr20r3” error. I’m sure everyone has heard of it… (yes, I’m joking.)

After some sanity checks I then googled the error description, which lead me down the path of checking my dependencies. They were all accounted for in the XML. I opened the app in Reflector and all looked fine: the dependencies were all there, and all the assembly versions being referenced were correct. I repeated this process until my mind started contemplating chaos theory.

So what was the solution? Besides jumping in front of the nearest double decker bus? Well, after much banging of head on table, it came down to a simple cut and paste bug. I had inadvertently set the target of the csc task to be “winexe” instead of “exe” (winexe is also a valid option, but simply not the correct target option for a console app). I changed this, rebuilt and all was fine.

From the sample code in the NAnt documentation:

NAnt CSC Task sample code


{ 2 comments… add one }
  • Simon August 12, 2009, 3:47 pm

    Well done for finding it! Sounds like a real nightmare.

  • Andy M June 3, 2010, 3:31 pm


    Was getting a similar problem with trace messages disappearing when going to consoletracelistener. When you build using a winexe these traces get silently swallowed as there is no console.

Leave a Comment