{"id":6003,"date":"2007-06-04T19:46:00","date_gmt":"2007-06-04T19:46:00","guid":{"rendered":"https:\/\/blogs.msdn.microsoft.com\/vbteam\/2007\/06\/04\/deploying-applications-with-the-interopforms-2-0-toolkit\/"},"modified":"2024-07-05T14:45:41","modified_gmt":"2024-07-05T21:45:41","slug":"deploying-applications-with-the-interopforms-2-0-toolkit","status":"publish","type":"post","link":"https:\/\/devblogs.microsoft.com\/vbteam\/deploying-applications-with-the-interopforms-2-0-toolkit\/","title":{"rendered":"Deploying Applications with the InteropForms 2.0 toolkit"},"content":{"rendered":"<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">(Recently, we released the InteropForms 2.0 toolkit which allows you to add the richness of .net windows forms to your vb6 application.&nbsp; We&#8217;ve gotten a fair number of questions from customers asking for more details on deployment, so this will hopefully answer most of your questions)<\/p>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">As I&#8217;m sure you&#8217;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.&nbsp;&nbsp; The Interop Forms Toolkit 2.0&nbsp;allows you to&nbsp;easily extend your VB6 applications with .NET functionality, which is great,&nbsp;but it creates some interesting&nbsp;deployment issues.&nbsp;&nbsp; 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.<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">To save you some time, here&#8217;s what we recommend in general with building mixed apps.<\/div>\n<blockquote class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">\n<div>a)&nbsp; Use the Interop Forms Toolkit to build Interop Usercontrols instead of Interop Forms.<\/div>\n<div>b)&nbsp; Remove the reference&nbsp;to Microsoft.InteropForms.dll library unless you plan on taking advantage of some of it&#8217;s functionality such as the Globals&nbsp;class (for sharing state) or the EventMessenger class (for raising application-level&nbsp;events).<\/div>\n<div>c)&nbsp; Configure your usercontrol manifest appropriately and create an application manifest for your VB6 app so you can take advantage of Reg-free COM <\/div>\n<div>d)&nbsp; Modify your legacy setup to copy over your new usercontrol binary and the application manifest into your application folder.<\/div>\n<\/blockquote>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">If you can do this, you can easily augment an existing application in a painless way.&nbsp; Deploying an application created this way is as simple as copying the new files down into the target directory.&nbsp; Of course, this doesn&#8217;t work for all situations and I&#8217;ve glossed over a few other details that should be mentioned.&nbsp;&nbsp; To decide on the best way to deploy your application, you have to deal with three issues.&nbsp;&nbsp; <\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\"><font size=\"2\"><strong>1) Prerequisites:<\/strong><\/font><\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">If you use an Interop usercontrol\/form in your project, your clients need to have the .NET framework 2.0 installed on their system.&nbsp;&nbsp; This framework is on machines by default in Vista and may be on your client machines anyway, but if not, here&#8217;s some options.&nbsp;&nbsp; (This assumes you have permissions to install\/rollout .msi setups that globally effect the machine.)<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<blockquote class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">\n<div>1)&nbsp;The recommended approach is to use the bootstrapper technology in VS 2005 to deploy any prereqs you need.&nbsp;&nbsp; You can create a custom bootstrapper which installs prereqs like the .net framework only if necessary and in&nbsp;a secure way.&nbsp;&nbsp; These prereqs that the bootstrapper supports are typically called &#8220;bootstrapper packages&#8221; and you can see what&#8217;s available on your machine by going to the Publish tab in the project designer and clicking on &#8220;Prerequisites&#8221; button.<\/div>\n<div>&nbsp;<\/div>\n<div>A &#8220;custom bootstrapper&#8221; is basically a special &#8220;setup.exe&#8221; that is built by VS that understands what prereqs are needed for your application.&nbsp;&nbsp; Once the prereqs are installed, it will launch whatever you want &#8211; typically the application setup.&nbsp;&nbsp; If you ever build a Setup and Deployment project in VS or publish a Clickonce app, the &#8220;setup.exe&#8221; that is created is a custom bootstrapper.<\/div>\n<div>&nbsp;<\/div>\n<div>2)&nbsp;Alternatively, you can roll your own approach (use batch file, etc&#8230;) which I won&#8217;t go into detail here.<\/div>\n<\/blockquote>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\" dir=\"ltr\">For most .Net created apps, the .Net 2.0 framework is the only dependency you have.&nbsp;&nbsp; However&nbsp;if you use InteropForms (rather than Interop Usercontrols) you take an a dependency on a binary called the &#8220;Microsoft.InteropFormTools.dll&#8221;.&nbsp;&nbsp; You also have&nbsp;this dependency by default if you&nbsp;create an Interop UserControl project, although you can&nbsp;safely remove it unless you explicity&nbsp;want to use some of the objects in this assembly.&nbsp;&nbsp;&nbsp;&nbsp;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.<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\" dir=\"ltr\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\" dir=\"ltr\">Lastly, if your Interop project has any extra 3rd party dependencies, you&#8217;ll need to ensure those are appropriately installed.&nbsp;&nbsp; If you want, you can create your own bootstrapper package for them and have the VS bootstrapper take care of installing them for you.<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\"><em>Resources:<\/em><\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">Creating a custom bootstrapper:&nbsp; Check out the &#8220;How To: Deploy a Hybrid Application&#8221; topic in the Interop Forms Toolkit documentation.&nbsp;&nbsp;&nbsp; <\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">Creating a bootstrapper package:&nbsp;&nbsp; Check out these links:<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\"><a href=\"http:\/\/msdn2.microsoft.com\/en-us\/library\/aa730839(VS.80).aspx\">http:\/\/msdn2.microsoft.com\/en-us\/library\/aa730839(VS.80).aspx<\/a><\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\"><a href=\"http:\/\/blogs.msdn.com\/chrsmith\/articles\/Using_the_Bootstrapper_to_wrap_a_Windows_Installer_package.aspx\">http:\/\/blogs.msdn.com\/chrsmith\/articles\/Using_the_Bootstrapper_to_wrap_a_Windows_Installer_package.aspx<\/a><\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">Actually, there&#8217;s a great tool that David Guyer created to allow you to visually create both a custom bootstrapper or a bootstrapper package.&nbsp;&nbsp; I highly recommend it.&nbsp;&nbsp; You can download it (via ClickOnce!) here:<\/div>\n<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\"><a href=\"http:\/\/www.codeplex.com\/bmg\">http:\/\/www.codeplex.com\/bmg<\/a><\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\"><font size=\"2\"><strong>2) Registering the Controls with Reg-Free COM:<\/strong><\/font><\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">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.&nbsp; 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.&nbsp;&nbsp; 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&#8217;re done.<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">If you use InteropForms projects&nbsp;(or say you have to support older platforms like Windows 98 or Windows 2000), this approach won&#8217;t work and you&#8217;ll need to use regasm (or a windows .msi) to deploy your assemblies which is more difficult, but still quite doable.&nbsp;&nbsp; If you use InteropForms projects, probably the easiest way to deploy them is in this manner:<\/div>\n<blockquote>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">1) Create a VS Setup and Deployment project and add your InteropForms assembly to it.&nbsp;&nbsp; Also, make sure you set the register property to vsdraCOM so that will get globally registered on the machine and build your .msi<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">2) Create a bootstrapper package for this .msi and then add this package to your custom bootstrapper.<\/div>\n<\/blockquote>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">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&nbsp;directly if you want to deploy them and cannot use reg-free COM.<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">Note:&nbsp; 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.&nbsp;&nbsp; The good news is that we&#8217;ve shipped the code to do this and you can just borrow what we have.&nbsp;&nbsp; Look in the source.zip file in the installation folder and check out the &#8220;bootstrapperpackageinstaller&#8221; project for details.&nbsp;&nbsp; In the &#8220;How to: Deploy a Hybrid Application&#8221; 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).<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\"><em>Resources:<\/em><\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">Search MSDN for &#8220;vsdraCOM&#8221; and you&#8217;ll get a bunch of information around this.&nbsp;&nbsp; Also, check out the links mentioned above for more information on bootstrapper information.<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\"><font size=\"2\"><strong>3) Your existing setup:<\/strong><\/font><\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\"><font size=\"2\"><\/font>&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">Part of the choosing of the best way to deploy your application comes from what you can do with your existing setup.&nbsp; Here&#8217;s the common scenarios and what we recommend.<\/div>\n<blockquote>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">a) Your&nbsp;setup is frozen (or you cannot modify it).<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">In this case, you can create a custom bootstrapper to install all prereqs that your application needs (whatever component you created in (2) above).&nbsp;&nbsp; You will end up with a single setup.exe which will launch and setup everything the application needs.<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">b) Your&nbsp;setup is a windows .msi file created in VS.&nbsp;&nbsp; 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.&nbsp;&nbsp; VS will create a custom bootstrapper (the setup.exe) that installs all needed prerequisites.<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">c) Your setup is created with the VB6 package and deployment wizard or some other technology and you can modify it.&nbsp;&nbsp; Depending on (1) above &#8211; namely, if you need to install prerequisites, you&nbsp;might want to create a&nbsp;custom bootstrapper to &#8220;wrap&#8221; your legacy setup.&nbsp;&nbsp; Depending on (2), you can either just add your files to your setup (if you use RegFree&nbsp;COM and Interop Usercontrols), or can do something custom for your setup.<\/div>\n<\/blockquote>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">Resources:<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\"><a href=\"http:\/\/blogs.msdn.com\/chrsmith\/articles\/Using_the_Bootstrapper_to_wrap_a_Windows_Installer_package.aspx\">http:\/\/blogs.msdn.com\/chrsmith\/articles\/Using_the_Bootstrapper_to_wrap_a_Windows_Installer_package.aspx<\/a><\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">Anyway, I hope that helps clear up any confusion around deploying hybrid applications.&nbsp;&nbsp; If you run into questions\/issues feel free to ask questions <a href=\"http:\/\/forums.microsoft.com\/MSDN\/ShowForum.aspx?ForumID=879&amp;SiteID=1\">here<\/a> and we&#8217;ll do our best to help you out.<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">Also we&#8217;ll be doing a webcast with demos and some Q&amp;A on June 6th, you can register for it here: <a href=\"http:\/\/msevents.microsoft.com\/CUI\/WebCastEventDetails.aspx?EventID=1032337474&amp;EventCategory=4&amp;culture=en-US&amp;CountryCode=US\">http:\/\/msevents.microsoft.com\/CUI\/WebCastEventDetails.aspx?EventID=1032337474&amp;EventCategory=4&amp;culture=en-US&amp;CountryCode=US<\/a><\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">Good luck!<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">Toddap_MS<\/div>\n<div class=\"ExternalClassA5FE57680D7B44F58E5A062B55282A50\">&nbsp;<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>(Recently, we released the InteropForms 2.0 toolkit which allows you to add the richness of .net windows forms to your vb6 application.&nbsp; We&#8217;ve gotten a fair number of questions from customers asking for more details on deployment, so this will hopefully answer most of your questions) &nbsp; As I&#8217;m sure you&#8217;re aware, deploying VB6 COM [&hellip;]<\/p>\n","protected":false},"author":260,"featured_media":8818,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[21,195],"tags":[155,170],"class_list":["post-6003","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-im-a-vb","category-visual-basic","tag-todd-apley","tag-vb6_migrationinterop"],"acf":[],"blog_post_summary":"<p>(Recently, we released the InteropForms 2.0 toolkit which allows you to add the richness of .net windows forms to your vb6 application.&nbsp; We&#8217;ve gotten a fair number of questions from customers asking for more details on deployment, so this will hopefully answer most of your questions) &nbsp; As I&#8217;m sure you&#8217;re aware, deploying VB6 COM [&hellip;]<\/p>\n","_links":{"self":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/6003","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/users\/260"}],"replies":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/comments?post=6003"}],"version-history":[{"count":0,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/posts\/6003\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media\/8818"}],"wp:attachment":[{"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/media?parent=6003"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/categories?post=6003"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/devblogs.microsoft.com\/vbteam\/wp-json\/wp\/v2\/tags?post=6003"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}