Deploying Applications with the InteropForms 2.0 toolkit

Deploying Applications with the InteropForms 2.0 toolkit

  • Comments 12
(Recently, we released the InteropForms 2.0 toolkit which allows you to add the richness of .net windows forms to your vb6 application.  We've gotten a fair number of questions from customers asking for more details on deployment, so this will hopefully answer most of your questions)
 
As I'm sure you're aware, deploying VB6 COM based applications can get complicated at times, which is one of the great advantages that moving your applications to .NET gives you.   The Interop Forms Toolkit 2.0 allows you to easily extend your VB6 applications with .NET functionality, which is great, but it creates some interesting deployment issues.   The good news is that there are some things we did in the latest 2.0 release to make this much easier than before and we tried to document the different strategies, but given that there are plenty of ways to do things, we wanted to blog about this in more detail.
 
To save you some time, here's what we recommend in general with building mixed apps.
a)  Use the Interop Forms Toolkit to build Interop Usercontrols instead of Interop Forms.
b)  Remove the reference to Microsoft.InteropForms.dll library unless you plan on taking advantage of some of it's functionality such as the Globals class (for sharing state) or the EventMessenger class (for raising application-level events).
c)  Configure your usercontrol manifest appropriately and create an application manifest for your VB6 app so you can take advantage of Reg-free COM
d)  Modify your legacy setup to copy over your new usercontrol binary and the application manifest into your application folder.
If you can do this, you can easily augment an existing application in a painless way.  Deploying an application created this way is as simple as copying the new files down into the target directory.  Of course, this doesn't work for all situations and I've glossed over a few other details that should be mentioned.   To decide on the best way to deploy your application, you have to deal with three issues.  
 
1) Prerequisites:
 
If you use an Interop usercontrol/form in your project, your clients need to have the .NET framework 2.0 installed on their system.   This framework is on machines by default in Vista and may be on your client machines anyway, but if not, here's some options.   (This assumes you have permissions to install/rollout .msi setups that globally effect the machine.)
 
1) The recommended approach is to use the bootstrapper technology in VS 2005 to deploy any prereqs you need.   You can create a custom bootstrapper which installs prereqs like the .net framework only if necessary and in a secure way.   These prereqs that the bootstrapper supports are typically called "bootstrapper packages" and you can see what's available on your machine by going to the Publish tab in the project designer and clicking on "Prerequisites" button.
 
A "custom bootstrapper" is basically a special "setup.exe" that is built by VS that understands what prereqs are needed for your application.   Once the prereqs are installed, it will launch whatever you want - typically the application setup.   If you ever build a Setup and Deployment project in VS or publish a Clickonce app, the "setup.exe" that is created is a custom bootstrapper.
 
2) Alternatively, you can roll your own approach (use batch file, etc...) which I won't go into detail here.
For most .Net created apps, the .Net 2.0 framework is the only dependency you have.   However if you use InteropForms (rather than Interop Usercontrols) you take an a dependency on a binary called the "Microsoft.InteropFormTools.dll".   You also have this dependency by default if you create an Interop UserControl project, although you can safely remove it unless you explicity want to use some of the objects in this assembly.    We have bundled this file in a redist package and created a bootstrapper package so you can safely and securely deploy this binary just like you would with the .Net framework.
 
Lastly, if your Interop project has any extra 3rd party dependencies, you'll need to ensure those are appropriately installed.   If you want, you can create your own bootstrapper package for them and have the VS bootstrapper take care of installing them for you.
 
Resources:
 
Creating a custom bootstrapper:  Check out the "How To: Deploy a Hybrid Application" topic in the Interop Forms Toolkit documentation.   
 
Creating a bootstrapper package:   Check out these links:
 
Actually, there's a great tool that David Guyer created to allow you to visually create both a custom bootstrapper or a bootstrapper package.   I highly recommend it.   You can download it (via ClickOnce!) here:
 
 
2) Registering the Controls with Reg-Free COM:
 
Registration free COM is a cool technology that works in Windows XP and later operating systems that allows you to deploy COM-based binaries without having to register them.  If you can be sure that your clients will be on this platform or later, then it can make your deployment story much easier if you use Interop UserControls.   As I mentioned above, the only thing you need to add to legacy application is add your new usercontrol assembly and an application manifest file to your application and copy those files to the application directory and you're done.
 
If you use InteropForms projects (or say you have to support older platforms like Windows 98 or Windows 2000), this approach won't work and you'll need to use regasm (or a windows .msi) to deploy your assemblies which is more difficult, but still quite doable.   If you use InteropForms projects, probably the easiest way to deploy them is in this manner:
1) Create a VS Setup and Deployment project and add your InteropForms assembly to it.   Also, make sure you set the register property to vsdraCOM so that will get globally registered on the machine and build your .msi
 
2) Create a bootstrapper package for this .msi and then add this package to your custom bootstrapper.
Interop UserControls projects cannot be deployed this way b/c they rely on some additional code to get run to register them properly (check out the code in the method with the DllRegisterFunction() attribute), so you need to use regasm.exe directly if you want to deploy them and cannot use reg-free COM.
 
Note:  If you do need to use regasm.exe, what I find to be the best approach is to create an .msi like above, but use a custom action to register/unregister the assembles.   The good news is that we've shipped the code to do this and you can just borrow what we have.   Look in the source.zip file in the installation folder and check out the "bootstrapperpackageinstaller" project for details.   In the "How to: Deploy a Hybrid Application" in the Interop Forms documentation, we also mention that you can ship regasm.exe in your installer, although I would recommend using the code that we ship (which searches for and finds the right copy of regasm.exe installed locally).
 
Resources:
 
Search MSDN for "vsdraCOM" and you'll get a bunch of information around this.   Also, check out the links mentioned above for more information on bootstrapper information.
 
3) Your existing setup:
 
Part of the choosing of the best way to deploy your application comes from what you can do with your existing setup.  Here's the common scenarios and what we recommend.
a) Your setup is frozen (or you cannot modify it).
In this case, you can create a custom bootstrapper to install all prereqs that your application needs (whatever component you created in (2) above).   You will end up with a single setup.exe which will launch and setup everything the application needs.
 
b) Your setup is a windows .msi file created in VS.   In this case, you can just add the appropriate logic for installing your assembly (see (2) above) and you can just goto the Prerequisites dialog for the setup project and rebuild your .msi.   VS will create a custom bootstrapper (the setup.exe) that installs all needed prerequisites.
 
c) Your setup is created with the VB6 package and deployment wizard or some other technology and you can modify it.   Depending on (1) above - namely, if you need to install prerequisites, you might want to create a custom bootstrapper to "wrap" your legacy setup.   Depending on (2), you can either just add your files to your setup (if you use RegFree COM and Interop Usercontrols), or can do something custom for your setup.
Resources:
 
Anyway, I hope that helps clear up any confusion around deploying hybrid applications.   If you run into questions/issues feel free to ask questions here and we'll do our best to help you out.
 
Also we'll be doing a webcast with demos and some Q&A on June 6th, you can register for it here: http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032337474&EventCategory=4&culture=en-US&CountryCode=US
 
Good luck!
 
Toddap_MS
 
Leave a Comment
  • Please add 5 and 5 and type the answer here:
  • Post
  • Is there any easy way to configure and create manifests for our VB6 exe and our .NET dlls so that regasm doesn't have to be used at all on the target PC?  By easy I mean no resource compiling or multi-step .net compiles.

  • Interested users should check out this post as well which contains a more detailed description of deploying using Reg-Free COM plus explains how to deploy VB6 apps using ClickOnce.

    http://blogs.msdn.com/bethmassi/archive/2007/06/27/deploying-interop-usercontrols.aspx

  • ChrisW:  On your comment above, i'm not entirely clear what you mean.   Assuming you use regfree COM, regasm.exe doesn't need to be on the target PC.   If you want, mail me at my name (minus the _MS) @microsoft.com and we can discuss.

  • I apologize right away that it's been a while since I've blogged about the interop forms toolkit although

  • I have been working on several Visual Basic projects recently, so thought it would be useful to signpost

  • 前に Interop Forms Toolkit についてブログを書いて以来、時間が経ってしまったことを お詫び します。この件については、常に最新の情報を得るように努めてきましたし、 相互運用のフォーラム

  • Paul Maher, Microsoft UK Developer & Platform group, has pulled together some useful material for

  • Ok. I have an interop toolkit 2.0 Usercontrol that was built by another developer. I have NO source code for it at all just the compiled DLL how do i get it to appear in my VB6 toolbox so I can use it, anybody out there know?

  • Hey Mel, all you have to is run regasm.exe <name of usercontrol>.dll and after that you'll be able to see it in VB6.

    It won't appear in the toolbox by default, you'll have to click Project->Components and select it from the list.  For more information I'd recommend reading the walkthroughs that are included in the Interop Toolkit help docs.

    Hope that helps,

    Jonathan

  • If I want to use the Interop usercontrol in other development computer with VB6/Office programming, I need to register the type library of this control.

  • Hi,

    I'm using vb.net InteropControl devloped using visual studio 2008 with vb.net. I'm using same control as ole in PowerBuilder. This interop control works fine on developer machine where both visual studio and powerbuilder 10.5 is installed. But client's machine is window 7. On that machine Visual Studion 2008 is not installed, but It has PowerBuilder 10.5. Problem is, that InterOP control is not working. Client machine has dot net frame work 2 and above. I have tried to register interop control dll with regsam. That dll gets register but I'm not able to access it's functions or methods.

    Am i missing any thing ?

    Any help in this regards will be highly appreciated.

    Thanks

    VGP

  • I have the same issue as VGP. Any help would be appreciated!

Page 1 of 1 (12 items)