C# 在asp.net网页中托管Windows窗体用户控件

C# 在asp.net网页中托管Windows窗体用户控件,c#,asp.net,winforms,user-controls,C#,Asp.net,Winforms,User Controls,我已经创建了一个Windows窗体用户控件,我需要将它放在网页中。我看到了很多链接: 但它不起作用 将WIndows窗体用户控件放入网页。我已经在网页中编写了以下代码 <body> <form id="form1" runat="server"> <div> <object id="MyWinControl" classid="http:VideoShareUserControl.dll#VideoShar

我已经创建了一个Windows窗体用户控件,我需要将它放在网页中。我看到了很多链接:

但它不起作用

将WIndows窗体用户控件放入网页。我已经在网页中编写了以下代码

<body>
    <form id="form1" runat="server">
    <div>
      <object id="MyWinControl" 
         classid="http:VideoShareUserControl.dll#VideoShareUserControl.UserControl1"
         height="100%" 
         width="100%" VIEWASTEXT />
    </div>
    </form>
</body>
但它不起作用


因此,请为我提供任何解决方案。

我认为您忘记设置一些选项:

从项目属性页的“生成”菜单中设置com互操作的注册。 控件的代码应该是这样的:不要忘记Comvisible和Guid: 代码:

在html或asp.net页面中,使用以下代码:

将您的控件dll放在网站的根目录中

没有必要将其添加为引用。
不工作意味着什么?我想在asp.net页面中加载它。所以我用了标签。但是它并没有显示控件……如果您查看您的webage html源代码,是否有任何东西显示控件应该在哪里?还是只有一个空div?在Firefox中它只是一个空div。但在InternetExplorer中它的显示像一个框架。。。
using System.Runtime.InteropServices;
namespace WindowsFormsControlLibrary1
{
    [ComVisible(true)]
    [Guid("CD46781D-B691-4287-B802-C9E2540AF08A")]
    [ProgId("WpfComHostDemo.WinformHostUserControl")]
    [ClassInterface(ClassInterfaceType.AutoDispatch)]
    public partial class UserControl1 : UserControl
    {      
        public UserControl1()
        {
            InitializeComponent();
        }
        private void button1_Click(object sender, EventArgs e)
        {
            MessageBox.Show(Environment.UserName+" "+Environment.MachineName+" "+
                            Environment.OSVersion);
        }
    }
}