当前位置: 代码迷 >> C# >> WPF引述WINFORM和原有的声明重复了
  详细解决方案

WPF引述WINFORM和原有的声明重复了

热度:20   发布时间:2016-05-05 04:10:57.0
WPF引用WINFORM和原有的声明重复了
楼主要引用winform,但报错了,看样子是WPF里的控件和winform控件重定义了。。。怎么解决?
-----------------------------
错误 5 “Label”是“System.Windows.Controls.Label”和“System.Windows.Forms.Label”之间的不明确的引用 C:\Users\Frank\Documents\Visual Studio 2012\Projects\WPFforjiekouchengxu\WpfApplication2\Main.xaml.cs 65 37 WpfApplication2
-----------------------------
如上的问题还有多处。。。
-------------------------------

------解决思路----------------------
重名的时候就要在类名前加上命名空间了。
------解决思路----------------------
这两个命名空间在引用的时候给个别名,控件前加入对应的别名(命名空间)
------解决思路----------------------
使用的时候,使用全称

System.Windows.Controls.Label label1; 
System.Windows.Forms.Label label2;

或者使用namespace Alias
using winform = System.Windows.Controls;
using WPF = System.Windows.Forms;

winform.Label label1;
WPF.Label label2;
------解决思路----------------------
using winform = System.Windows.Controls;
using WPF = System.Windows.Forms;
  相关解决方案