none
Will .Net user control(.dll) in HTML page execute without IIS RRS feed

  • Question

  • Hi All,

    I have created a project type of "Windows forms control Library" using VS2008 in C#. Solution name is TestBrowserApplication.

    I added a button,label and menu strip

    Code as below

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;

    namespace TestBrowserApplication
    {
        [ComVisible(true)]
        public partial class UserControl1 : UserControl
        {
            public UserControl1()
            {
                InitializeComponent();
            }

            private void button1_Click(object sender, EventArgs e)
            {
                label1.Text = "";
                MessageBox.Show("Testing winform control");
                label1.Text = "Testing winform control";
            }

            private void menu1ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                MessageBox.Show("Menu 1 clicked");
            }

            private void mennu2ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                MessageBox.Show("Menu 2 clicked");
            }
        }
    }

     

    In AssemblyInfo.cs i made com visible as true

    in Project properties -> Build -> selected the Register for COM Interop

    I build the solution and got the dll - TestBrowserApplication.dll.

    Then I tried to call this dll from HTML

    HTML file code as below

    <html>
    <head>
    <title>WinForms Control example</title>
    </head>
    <body>
    <p>WinForms Control example</p>
    </body>
    <object id="UserControl1" classid=" http:TestBrowserApplication.dll#TestBrowserApplication.UserControl1" height="500" width="500" VIEWASTEXT> </object>
    </html>

    When I placed the html and dll file in to new virtual directory of IIS, i'm able to see the control in webpage(http://localhost/WinFormsControl/ControlHost.html)

    when I copied the HTML and dll to other webserver(like tomcat etc, not supporting IIS), and access the html from another client machine, the control is not appearing in the web page. The control is shown as small blank image with 'X' in red color and no errors or exception

    The client machine has .Net framework and IE version is 8.0. My understanding is dll will download to client machine and it will get executed like Activex.

    Can anyone explain the concept behind executing the control in HTML, is it possible to execute the control in HTML without IIS.

    If it's not possible, how to execute code in client machine like Activex

     

    Thanks,

    Mani


    • Changed type Daniel Rieck Friday, March 26, 2010 12:47 PM it's a question
    • Moved by Figo Fei Tuesday, March 30, 2010 1:27 AM (From:Common Language Runtime)
    Friday, March 26, 2010 9:44 AM

Answers

  • Hi Mani

    You may find forums.asp.net and forums.iis.net more helpful.

    Thanks.



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Tuesday, March 30, 2010 1:25 AM
  • This was moved out of the CLR forum.

    You can ask this question at another forum.

    Or I can move it into a specific forum if you'd like.

    This is regarding your code:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    
    namespace TestBrowserApplication
    {
        [ComVisible(true)]
        public partial class UserControl1 : UserControl
        {
            public UserControl1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                label1.Text = "";
                MessageBox.Show("Testing winform control");
                label1.Text = "Testing winform control";
            }
    
            private void menu1ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                MessageBox.Show("Menu 1 clicked");
            }
    
            private void mennu2ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                MessageBox.Show("Menu 2 clicked");
            }
        }
    }
    
    

     


    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Tuesday, December 27, 2011 2:01 AM
    Owner

All replies

  • You might need to configure the server to return the correct mime type.


    Mark the best replies as answers!
    Friday, March 26, 2010 12:49 PM
  • How to configure the server to return the correct mime type

     

    Thanks,

    Mani

    Saturday, March 27, 2010 10:25 AM
  • Hi Mani

    You may find forums.asp.net and forums.iis.net more helpful.

    Thanks.



    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Tuesday, March 30, 2010 1:25 AM
  • This was moved out of the CLR forum.

    You can ask this question at another forum.

    Or I can move it into a specific forum if you'd like.

    This is regarding your code:

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Drawing;
    using System.Data;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    
    namespace TestBrowserApplication
    {
        [ComVisible(true)]
        public partial class UserControl1 : UserControl
        {
            public UserControl1()
            {
                InitializeComponent();
            }
    
            private void button1_Click(object sender, EventArgs e)
            {
                label1.Text = "";
                MessageBox.Show("Testing winform control");
                label1.Text = "Testing winform control";
            }
    
            private void menu1ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                MessageBox.Show("Menu 1 clicked");
            }
    
            private void mennu2ToolStripMenuItem_Click(object sender, EventArgs e)
            {
                MessageBox.Show("Menu 2 clicked");
            }
        }
    }
    
    

     


    Ed Price a.k.a User Ed, Microsoft Experience Program Manager (Blog, Twitter, Wiki)
    Tuesday, December 27, 2011 2:01 AM
    Owner