A Programmer's Dream

Class Libraries and "ApplicationDefinition"

Posted by Stephen Wrighton on 15 Jul 2009

Oh the joys of Visual Studio IDE.

99% of the time, I love this tool, but there's that other 1% of the time, when I could happily smack it six ways to Sunday.

Well today I was working in a Class Library of one of my projects, and all of a sudden, it stopped compiling.

Just refused.

Which of course broke things up and down the solution, as this particular library is my Data Layer.

So, I peruse the Error List, and come across this two errors:
Error 1 Library project file cannot specify ApplicationDefinition element.
Error 2 The project file contains a property value that is not valid.
With absolutely NO reference to where, how, what, or even which object in the project that is generating these two wonderful ambiguous errors.

So, I turn to my good friend Google.

And got a lot, and a lot of results. Most of them talking about removing APP.XAML from the project (which I didn't have one in this project) or just flat out not knowing what it was/is/or means.

It's at this point that I start rubbing the bridge of my nose. I need to test my changes, and deploy for a customer display by this afternoon.

Starting to worry a bit, I removed the new dialog I had created (even though it was a WinForms dialog as opposed to a WPF window) and attempted to recompile.

Still with the error.

So, I change my search parameters slightly, and delve deeper into the mysterious workings of Google Search Results.

And found this link (translated into English here).

The basics talks of dragging objects from a WPF Application or a WPF Library project into a standard project. Apparently, the BUILD for these items will be changed from whatever they are in the WPF-based project to an "Application Definition" build command.

Which of course breaks a library, as only executable projects can build with Application Definition--and it's usually the App.XAML file which recieves this build type.

Pondering this, as I had not dragged nor dropped anything into the project, I remembered that I had added an object to this library; but instead of creating it new, or dragging & dropping, I had cut-and-pasted it into my resources folder.

So, I look at the build information for this image, and lo-and-behold, it had been changed to ApplicationDefinition.

I quickly modified it back to Resource like it should have been, and then compiled.

Eureka! And not the tv show, or the anime character, but rather the original intent.

Compilation proceeded, things started working, and life was good.

At least until I ran across my next bug....

Tweet me @kidananubix if you like this post.