how to write my own Winforms control and use it in IE

I want to write a Winforms control and use it inside IE.
I'm searching  for a tutorial/documentation

The Newsgroup is about "Discuss the ClickOnce deployment technology as well as using Windows Forms controls from inside Internet Explorer" so i hope you can help me.

Regards
Stefan



Answer this question

how to write my own Winforms control and use it in IE

  • Muzaffer Caglayan

    hi Again!

    You can achive your functionality in one the following way! In a Visual Studio.NET open the project properties go to the Build action tab and check the checkbox Register Control for COM interoperability.

    Now Open the Registry and find the Name of your Root NameSpace of your Project in the Registry. To manually find where there COM ids are stored in your Pc's Open the following Registry Keys

    MyComputer\HKEY_CLASSES_ROOT\CLSID\   and click the check box in the front of CLSID

    a new tree-view hierarchy loads. Now find your clsid in that list. YOu can use Registry Find Feature.

    Now do one thing Export all these registry keys to some folder as .reg file. Open this fileFor- example see here Sample

    ------------------------------------------------------------------------------------------------------

    Windows Registry Editor Version 5.00

    [HKEY_CLASSES_ROOT\CLSID\{00000010-0000-0000-0010-0000001A2B3C}]
    @="Sehmi.Web.Files.Uploader"

    [HKEY_CLASSES_ROOT\CLSID\{00000010-0000-0000-0010-0000001A2B3C}\Implemented Categories]
    @=""

    [HKEY_CLASSES_ROOT\CLSID\{00000010-0000-0000-0010-0000001A2B3C}\Implemented Categories\{00000020-0000-0000-0020-0000001A2B3C}]
    @=""

    [HKEY_CLASSES_ROOT\CLSID\{00000010-0000-0000-0010-0000001A2B3C}\InprocServer32]
    @="mscoree.dll"
    "Assembly"="FileUploader, Version=1.0.1961.20031, Culture=neutral, PublicKeyToken=null"
    "Class"="Sehmi.Web.Files.Uploader"
    "CodeBase"="file:///C:/WINDOWS/Downloaded Program Files/FileUploader.dll"
    "RuntimeVersion"="1.1.4322"
    "ThreadingModel"="Both"

    [HKEY_CLASSES_ROOT\CLSID\{00000010-0000-0000-0010-0000001A2B3C}\InprocServer32\1.0.1961.20031]
    @=""
    "Assembly"="FileUploader, Version=1.0.1961.20031, Culture=neutral, PublicKeyToken=null"
    "Class"="Sehmi.Web.Files.Uploader"
    "CodeBase"="file:///C:/WINDOWS/Downloaded Program Files/FileUploader.dll"
    "RuntimeVersion"="1.1.4322"

    [HKEY_CLASSES_ROOT\CLSID\{00000010-0000-0000-0010-0000001A2B3C}\ProgId]
    @="Sehmi.Web.Files.Uploader"

    ----------------------------------------------------------------------------------------------------

    E.g   if {00000010-0000-0000-0010-0000001A2B3C}     is your project's CLSID  note it and keep it in a safe place

    and now use the following piece Of Code to load your Control in as ASP.NET or html Page

    <html>

    <object  id="MyObject"    classid="clsid:{00000010-0000-0000-0010-0000001A2B3C}" >

    </object>

    </object>

    </html>

    and open that page from your server in a an internet explorer

    --------------------------------------------------------------------------------------------------------------------------

     

    Thanks!
    Er.Sehmi
    Infotrust.com.sg
    Singapore



  • Abbas Zaheer

    Click Once and Hosting Winform contorls inside of IE are 2 different things.

    For a tutorial on Hosting .NET windows form contorls inside of IE please see here

  • Adam P

    hi again!!!

    First of all i shall be very thankful to you becuase you havereaed my article!!! if your Windows Form Control has some dependent assemblies then go this way : -

    1. Open gacUtil.exe and Register all assemblies will Gac ( Global Assembly Cache ) , then try to Run you hosted application in IE6

    I am assuming that you should know what the GacUtil.exe Is Its an custom assembly registration Utility provided by Microsoft

    2. Load all the dynamically loaded assemblies using System.Reflection. You can also do this way !!! Use Reflection i mean

                Dim      [Assembly]   As     System.Reflection.Assembly

                Assembly.Load("MyAssembly")

                Or

               Assembly.LoadFrom("C:\.............\myApplication\myAssembly.dll")

                Or

                Assembly.LoadFile("C:\.............\myApplication\myAssembly.dll")

    Then see whether your Control loads the assembly form that location Or not

    3. If you have programmed that assemblies i mean may be many people doesn't like this method. Try to Code them in your Component. This is the last and the worst solution i think called Going to hell !!!

    But i strongly suggest you to plz make one simple control and try to host it in as IE. If that works then go for other complex control(s).

    Free Free to Contact Me.

    Er.Sehmi
    -----------------------------------------------------------
    The Enemy Of my Enemy Is my Friend !!!
    Infotrust.com.sg
    Microsoft.NET
    Singapore

     

     

     



  • Dickie Howarth

    hello again!

    The procedure i am telling you is to host the .net 1.1 control in an IE6, do the same for the .net beta 2.0

    Create a windows user controls prrojet and compile the .dll of it!!!

    After that create a virtual directory on the IIS and set its permissions... And make sure that its Application Permissions are set to Scripts only. if you set it to scripts and executables then your controls is not hosted and will not displayed in an IE6.

    Then create an .ASPX page in that virtual directory then in .ASPX write

    <OBJECT ID="MyControl"
      classid="http://MyServer/virtualDirectory/MyControl.dll#NameSpace"
      height= 200 width= 400 >
    </OBJECT>

    Now see this:   MyControl.dll  is the name of your Windows Forums UserControl.

    if you are creating your control in vb.net then from the properties tab of your project see your root NameSpace ! And assign that NameSpace name in the place where i had written

    classid="http://MyServer/virtualDirectory/MyControl.dll#NameSpace"

    you can also write this line as:

    classid="MyControl.dll#NameSpace"

    but i think the above full url method is better

    Now open that .ASPX Page in an IE6 or IE7, and see your control hosted in an IE


    For any Problems Regarding Control Hosting in an IE Contact: ErSehmi@hotmail.com freely without any hesitations, i will show full co-operation with you!!!


    Thanks!
    Er.Sehmi
    Infotrust.com.sg
    Singapore






  • ProxyProdigy

    Hi,

     

    I found this thread's topic is exact what I'm looking for. I've tried and searched for a week and haven't found a way.

    Basically, I tried to use Visual Studio 2005 to create a C# Window control library (or maybe it should be Web control library ), as an assembly right In the library (the .dll), there is myControl class extened from UserControl. And I want to be able to embed this control in my web page, using object tag, classid and codebase attributes, I guess.

    Three questions:

    (1) Will a C# control have to be used in a .net runtime If so, can we assume most of w2k and xp users have the runtime

    (2) I tried to turn on "Register for COM Interop" in project property and rebuilt the dll. But I didn't find the control registered in the Regitry.

    (3) Will this control have to be used in IIS server, with or without using classid=assembly#namespave.class Is this kind of specification of classid only recognized and supported by IIS in a web page

    Here is how the html looks like: (the commented control is a sample from MSDN and it didn't work for me either). I was prompted to install it when opening the page in my tomcat server. Yes, I should to state that I do need to host the control in tomcat (or any other non-IIS server).

    <html>
     <body color="white">
      <hr> 
         <form name="frm" id="frm">
           <input type="text" name="txt" value="enter URL here"/><input type=button value="Click me" onClick="doScript();"/>
          </form>
          <font face=arial size=1>
    <!--     
           <OBJECT id="myControl" name="myControl" classid="ActiveXDotNet.dll#ActiveXDotNet.myControl" width=288 height=72>
    -->      
           <OBJECT ID="NavControl1" NAME="NavControl1" CLASSID="OPWinNavigator.dll#OPWinNavigator.NavControl" TYPE="application/x-oleobject" CODEBASE="http://localhost:4040/OPWinNavigator.dll" STANDBY="Please wait while the system installs the Navigator Control..." width="600" height="400">
           </OBJECT>
         </font> 
      </hr>
     </body> 
    <script language="javascript">
          function doScript()
           {
            alert("Address entered: " + frm.txt.value);
            NavControl1.Text = frm.txt.value;
           }
    </script>
    </html>

    Thanks for at least reading my entry,

    Jason

     



  • how to write my own Winforms control and use it in IE