locked
.Net User Controls in VB6 RRS feed

  • Question

  •  
    As a company we would like to move all of our code to C#, but we share development with a third party who wants to stay at VB6. We currently supply them with a number of VB6 OCX controls which they embed in their applications. We would like to build C# controls but wrap them in a way such that they can continue to use them as OCXs.

    I have experimented with the toolkit and been able to popup C# forms from within VB6 but this model and UI experience would be an unacceptable change to the users. I have searched around and come up with the following but none are great.

    1. Create Web control inside an ASP.NET page and display it using the internet browser control in VB6.

    2. Popup a frameless C# form and attempt to position and move it inline with the parent, yak!!

    3. Create UI for the OCX in VB6 but delegate all functionality to a .NET library wrapped so the OCX can call it.

    Any other ideas ?



    Tanglesoft
    Friday, January 5, 2007 1:40 PM

Answers

  • I think the best solution to your problem is to use .NET Interop UserControls - there's a CTP available on our blog site at http://blogs.msdn.com/vbteam/archive/2006/11/02/interop-roadmap-usercontrols-mdi-and-data.aspx

    What this template allows you to do is create .NET UserControls (using a special template) and then host them in VB6 within the same form.  When you build the control it automatically gets registered for COM Interop.

    The template we've posted is pre-release software at this point, but the final version should be available in the very near future.

    Please try it out and let me know if you have any questions.

    Thanks,

    Jonathan

    Friday, January 5, 2007 7:31 PM
    Moderator

All replies

  • I think the best solution to your problem is to use .NET Interop UserControls - there's a CTP available on our blog site at http://blogs.msdn.com/vbteam/archive/2006/11/02/interop-roadmap-usercontrols-mdi-and-data.aspx

    What this template allows you to do is create .NET UserControls (using a special template) and then host them in VB6 within the same form.  When you build the control it automatically gets registered for COM Interop.

    The template we've posted is pre-release software at this point, but the final version should be available in the very near future.

    Please try it out and let me know if you have any questions.

    Thanks,

    Jonathan

    Friday, January 5, 2007 7:31 PM
    Moderator
  • Another consideration is that whether they want to modify their setup to require the installation of the .NET framework. If this is not viable then I would design the control so that all code that is sharable between a VB6 version and a .NET version is placed a single location of the project. Then that file can use used in either version and compiled.

    This solution by require abstracting some of the difference between the two platforms through the use of interfaces.

    Rob Conley

    Friday, January 5, 2007 8:30 PM