Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/335.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#:名称空间';表格';命名空间中不存在';System.Windows';_C#_Forms_Namespaces - Fatal编程技术网

C#:名称空间';表格';命名空间中不存在';System.Windows';

C#:名称空间';表格';命名空间中不存在';System.Windows';,c#,forms,namespaces,C#,Forms,Namespaces,我有一个web应用程序,我想向用户显示一条消息,因此我搜索了web,找到了System.Windows.Forms,但当我尝试使用它时,我发现以下错误: CS0234:命名空间“System.Windows”中不存在类型或命名空间名称“Forms”(是否缺少程序集引用?) 我刚刚添加了“使用System.Windows.Forms”语句,还右键单击了解决方案,转到“添加引用”并选中了“System.Windows.Forms”项。 对于VisualStudio,没有错误,所以我编译了解决方案,但

我有一个web应用程序,我想向用户显示一条消息,因此我搜索了web,找到了System.Windows.Forms,但当我尝试使用它时,我发现以下错误:

CS0234:命名空间“System.Windows”中不存在类型或命名空间名称“Forms”(是否缺少程序集引用?)

我刚刚添加了“使用System.Windows.Forms”语句,还右键单击了解决方案,转到“添加引用”并选中了“System.Windows.Forms”项。 对于VisualStudio,没有错误,所以我编译了解决方案,但是当我尝试打开该表单时,我得到了错误

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using AcademiaSparta;
using System.Windows.Forms;

namespace AcademiaSpartaWeb
{
    public partial class Registrarse : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            MessageBox.Show("Hola");
        }
    }
}
我已经搜索了3个小时了,我找不到答案

PS:对不起,如果我的问题有语法错误,我的英语不是很好


非常感谢。

或者在您的解决方案中创建类似的方法:

public static class MessageBox {
    public static void Show(this Page Page, String Message) {
       Page.ClientScript.RegisterStartupScript(
          Page.GetType(),
          "MessageBox",
          "<script language='javascript'>alert('" + Message + "');</script>"
       );
    }
}

您是否试图在客户端的浏览器中显示消息框?嗯,
System.Windows.Forms
是一种完全错误的方式……请查看此链接以使用警报。不幸的是,它不如windows窗体好。
System.windows.forms
用于桌面应用程序,在创建web应用程序时对您没有任何好处。如果你想在浏览器上显示消息框,你需要使用Javascript的提醒。谢谢Vikram Bose的回答。我理解System.Windows.Forms的错误。
MessageBox.Show("Hola");