Problems after copying XAML controls from WPF Application to a class library

后端 未结 5 1441
南笙
南笙 2021-02-04 23:50

In the process of refactoring some code, I encountered several build errors such as these:

Library project file cannot specify ApplicationDefinition element.

5条回答
  •  野趣味
    野趣味 (楼主)
    2021-02-05 00:06

    2 years later and I came searching with the same question, but was only able to use the above comments to rule out other options and eventually find my answer when I noticed the two projects each had the same identically-named .xaml file within a single solution.


    Abstract example

    1 solution which has 2 projects: PRINTNOTESPROJ and MAKENOTESPROJ.

    During development, I used a XAML window in MAKENOTESPROJ which should actually be part of PRINTNOTESPROJ in the Release executables.

    Upon switching to Build->Release, I simply clicked-down on "PrintWindow.XAML" (in MAKENOTESPROJ & with child PrintWindow.xaml.cs) and DRAGGED it onto my PRINTNOTESPROJ.

    *This is the key. I forgot that doing this only COPIES the related files to the new project [at least in VS 2010]. From this point onward I received your error until I DELETED "PrintWindow.xaml" from my original project MAKENOTESPROJ.

    I hope this makes sense... Please comment with questions!

提交回复
热议问题