Wednesday, July 15, 2009

Class Libraries and "ApplicationDefinition"

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....

32 comments:

Trevor said...

Thank you.

Stephen Wrighton said...

A pleasure

Anonymous said...

Thank you!

ddawg said...

thx!

Sciana said...

Thank you! It was really easy to repair my project after reading your post. Thank you one more time for your post:)

Pete said...

Thanks mate, this one had me buggered.

Stephen Wrighton said...

@Sciana and @Pete - you are both quite welcome. I know I had hassles with it, so I'm glad I saved others time.

Nicros said...

I also thank you, would have taken a long time to find this one after dragging and dropping a resource folder between projects!

Phil said...

Thanks, was starting to pull my hair out on this!

Anonymous said...

Thanks! I found I had copied a UserControl from another class library. This UserControl was copied into the new project definition as an "ApplicationDefinition".

Alex said...

You can easily fix this error in Visual Studio 2010 by changing the "Build Action" for the problem file from "ApplicationDefinition" to whatever you need it to be--just check out the properties window. In my case, being a copied UserControl, I switched the "Build Action" setting to "Page".

EricBowman said...

thank you so much!

Anonymous said...

Thank you man!

Tim said...

hullo, you saved my hide as well. I was wondering what happened!

P8TRO said...

Thank you!

Rod Howarth said...

Thanks! Solved my error.

Anonymous said...

THANKS!

Anonymous said...

Thank you!!!

Anonymous said...

Thank you!

Anonymous said...

Yet another sincere thank you. So,
Use Drag-n-Drop in an IDE vs just operating on files in an editor: save 10sec
Figure out why the compilation suddenly breaks with a cryptic error (trying to bisect the actions that broke it, narrowing down to having sertain xaml files present, etc.): wasted ~1h
Conclusion: the IDE has quite a bunch of lost time to regain.

Anonymous said...

Thank you!

Anonymous said...

Thorn1101: Thanks a lot!

Anonymous said...

Thank you very much

Paw said...

And thank you from me as well. Changed a Window I moved back to Page and it worked.

Anonymous said...

Thank you!!! saved my day :-)

Anonymous said...

Thanks! appreciate the answer

David Allgayer said...

Thank you for this, I was about to cry...

Anonymous said...

thanks

Anonymous said...

Thanks ; )

Anonymous said...

THANK YOU! SAVED MY DAY!

Anonymous said...

Thank you. It was exactly my problem (drag'n drop of a WPF Window from one project to another).

The bad side: the same problem always exists on VS2012 Update 1.

Francesco Cadili said...

Thank you!

Blog Widget by LinkWithin