从WPF应用程序复制XAML控件类库后问题控件、应用程序、类库、问题

2023-09-04 22:47:23 作者:超喜欢我家狗子

在重构了一些code我遇到像这样的一些构建过程中的错误:

In the process of refactoring some code I encountered several build errors like these:

库项目文件不能指定ApplicationDefinition元素。

Library project file cannot specify ApplicationDefinition element.

项目文件中包含的属性值是无效的。

The project file contains a property value that is not valid.

如何这些错误得到解决?

How can these errors be resolved?

推荐答案

在复制和粘贴文件,无论是在一个项目或其他项目时,Visual Studio有没有保持相同的的BuildAction 财产。它经常变化生成操作一个看似随机值,例如: ApplicationDefinition ,这会导致生成错误。

When you copy and paste files either within a project or to another project, Visual Studio has a nasty habit of not keeping the same BuildAction property. It often changes the build action to a seemingly random value, e.g. ApplicationDefinition, which causes that build error.

检查(在Visual Studio的属性窗口,在Solution Explorer中选中的文件),您的每一个的.xaml文件中有一个的BuildAction 的网页和你的$财产C $ C文件有的BuildAction 属性编译

Check (in the Visual Studio properties window with the file selected in the Solution Explorer) that each of your .xaml files have a BuildAction property of Page and your code files have a BuildAction property of Compile.