vb.net “表单”不是“Windows”的成员
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/23573659/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
'Forms' is not a member of 'Windows'
提问by andre_ss6
I tried to change the Target Framework on my app recently from .NET Framework 4.5 to 4.5.2, but if I do I get the following error when trying to build: "'Forms' is not a member of 'Windows'" (that is, System.Windows.Forms
). Changing to 4.5.1 works normally. I'm using Visual Studio 2013 Ultimate.
我最近尝试将我的应用程序上的目标框架从 .NET Framework 4.5 更改为 4.5.2,但是如果我这样做,我在尝试构建时会收到以下错误:“'Forms' 不是 'Windows' 的成员”(即是,System.Windows.Forms
)。更改为 4.5.1 正常工作。我正在使用 Visual Studio 2013 Ultimate。
回答by user3967313
I had this error when changing to 4.5.2.
更改为 4.5.2 时出现此错误。
In my case the error was related to a MessageBox ... I replaced: "Windows.Forms.DialogResult.Yes" (which caused the same error message) with "System.Windows.Forms.DialogResult.Yes" which did the trick.
在我的情况下,错误与 MessageBox 相关......我用“System.Windows.Forms.DialogResult.Yes”替换了:“Windows.Forms.DialogResult.Yes”(导致相同的错误消息),它起到了作用。
回答by Stefano Leoni
I had the same problem, me too with Windows.Forms.DialogResult
enumeration values.
我有同样的问题,我也有Windows.Forms.DialogResult
枚举值。
The project automatically imports System
and System.Windows.Forms
namespaces and worked fine up to 4.5.1
.
该项目会自动导入System
和System.Windows.Forms
命名空间,并且可以正常工作到4.5.1
.
In 4.5.2
I had to remove Windows.Forms.
and just leave DialogResult.Ok
(or whatever else) in my code, it seems to be a problem with namespaces resolution.
在4.5.2
我不得不在我的代码中删除Windows.Forms.
并保留DialogResult.Ok
(或其他任何东西)时,命名空间解析似乎是一个问题。
回答by krishna chaithanya
Make sure that you add System
in front of the Windows.Form
.
确保System
在Windows.Form
.
回答by gregmac
I ran into this with an application still targeted to .NET 4.0, where it failed on one (new) build server, but ran on my older ones.
我遇到了一个仍然针对 .NET 4.0 的应用程序,它在一个(新)构建服务器上失败了,但在我的旧服务器上运行。
I narrowed it down to the .NET 4.0 Targeting Pack only being installed on the old build servers. Targeting pack is included in Visual Studio, or the Windows 7.1 SDK. It is for some reason not distributed separately, and with support ending for .NET 4, 4.5 and 4.5.1, I don't suspect this is likely to change. Because my older servers have been around a couple years, they've gone through in-place upgrades and so had the targeting pack already.
我将范围缩小到仅安装在旧构建服务器上的 .NET 4.0 Targeting Pack。目标包包含在 Visual Studio 或 Windows 7.1 SDK 中。由于某种原因,它没有单独分发,并且随着对 .NET 4、4.5 和 4.5.1 的支持结束,我不怀疑这可能会改变。因为我的旧服务器已经使用了几年,它们已经进行了就地升级,因此已经有了目标包。
When you install Windows 7.1 SDK on Server 2012R2, it complains something to the effect of "A pre-release version of .NET 4 is installed, please install the RTM version". As far as I can tell, it's simply because a newer version) is installed -- Server 2012R2 comes with 4.5.1. I tried to uninstall all newer versions, but was unable to get the SDK to install the targeting pack.
当您在 Server 2012R2 上安装 Windows 7.1 SDK 时,它会抱怨“安装了 .NET 4 的预发布版本,请安装 RTM 版本”。据我所知,这仅仅是因为安装了较新的版本——Server 2012R2 带有 4.5.1。我尝试卸载所有较新版本,但无法让 SDK 安装目标包。
So to install:
所以要安装:
- Download the Windows 7.1 SDK ISO image
- Unzip it
- Run
Setup\MTPack\netfx_dtp.msi EXTUI=1
- 下载Windows 7.1 SDK ISO 映像
- 解压
- 跑
Setup\MTPack\netfx_dtp.msi EXTUI=1
You should now have a %programfiles(x86)%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\
folder with the 4.0 stuff.
您现在应该有一个%programfiles(x86)%\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\
包含 4.0 内容的文件夹。
(EXTUI=1 bypasses the restriction that it can't be installed separately).
(EXTUI=1 绕过了不能单独安装的限制)。
This allowed me to compile projects still targeting 4.0 (or re-build old revisions/branches that were targeting it at the time).
这使我能够编译仍然针对 4.0 的项目(或重新构建当时针对它的旧修订版/分支)。