码迷,mamicode.com
首页 > 移动开发 > 详细

WPF学习- 新建项目后自定义Main()[Type 'App' already defines a member called 'Main' with the same parameter types]

时间:2016-06-12 00:23:57      阅读:463      评论:0      收藏:0      [点我收藏+]

标签:

问题点:

在App.xaml.cs中自己添加Main方法,编译会出现如下报错:

错误 CS0111 类型“App”已定义了一个名为“Main”的具有相同参数类型的成员 

错误 Type ‘App‘ already defines a member called ‘Main‘ with the same parameter types 

错误 CS0017 程序定义了多个入口点。使用 /main (指定包含入口点的类型)进行编译。 

技术分享

 

原因:

默认方式新建WPF项目时,编译时会自动生成Main方法(在App.g.i.cs中)。

技术分享

解决方式:

在App.xaml的属性中,把生成操作 ApplicationDefinition 修改为Page。再编译就OK了。

【WPF项目在编译时,微软MSBuild:Compile 生成工具根据配置(ApplicationDefinition or Page) 做了不同的处理。】

技术分享

 

MSBuild 相关参考:https://msdn.microsoft.com/zh-cn/library/dd393574.aspx

MSBuid 扩展:https://github.com/mikefourie/MSBuildExtensionPack

WPF学习- 新建项目后自定义Main()[Type 'App' already defines a member called 'Main' with the same parameter types]

标签:

原文地址:http://www.cnblogs.com/kuangxiangnice/p/5576228.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!