症状
针对 Microsoft.NET Framework 4.5.2 VB.NET 应用程序重新编译时,可能会在编译过程中收到以下错误消息︰
{Name}不是 Windows 的成员。
在此消息,"{名称}"占位符是子 System.Windows 命名空间,例如"窗体"或"标记"。
例如,错误消息可能如下所示︰
表单不是 Windows 的成员。
解决方案
该问题涉及的.NET Framework 4.5.2"Windows"命名空间冲突。它将出现在代码中使用 Windows。{名称} 请参阅 System.Windows。{名称}。
要解决此问题,请更改代码以完全限定命名空间,或者导入完整的命名空间和引用它们的简单名称及其类型。
例如,下面的代码将导致错误︰
Module Module1
Sub Main()
Windows.Forms.MessageBox.Show("Example")
End Sub
End Module
但是,将成功编译下面的代码︰
Imports System.Windows.Forms
Module Module1
Sub Main()
MessageBox.Show("Example")
End Sub
End Module
此外将成功编译下面的代码︰
Module Module1
Sub Main()
System.Windows.Forms.MessageBox.Show("Example")
End Sub
End Module