Using WCF in VB6?
One of the demos a peer of mine gave (Johnathan) included creating a .NET form with a Web reference that, using the interop toolkit (just released), could be called from a VB6 app. This is a great scenario because it enables those with a VB6 legacy code base to use some of the cool features in .NET without having to rewrite their VB6 applciations.
While I thought that was cool, I wanted to see if the same was possible with WCF in .NET 3.0. As you probably know, the benefit of WCF services is that it highly configurable unlike ASMX in .NET 2.0. The biggest issue in VB 6, however, is to figure out where to add that configuration.
The solution is to name the configuration myapp.exe.config and place it right next to the executable, which is simple enough if you publish the VB6 app.
What about if you want to debug it from the VB6 IDE?
In this case, name the configuration vb6.exe.config and place it right next to the vb6.exe in the VB98 directory.
- Install the Interop Toolkit
- Use the InteropForm project template to create a new project (you don't need to do this, but this really is the simplest way)
- Use svcutil to generate a WCF proxy to consume the service (alternatively use Orcas CTP and new Service Reference dialog - http://www.microsoft.com/downloads/details.aspx?FamilyId=D1336F3E-E677-426B-925C-C84A54654414&displaylang=en)
- Use the Service reference in your form.
- Select Tools->Generate Interop Wrapper Classes from the Menu Items
- Build the project.
- Open VB6
- Add a Project -> Reference to the .NET project's dll
- Call the new InteropForm like you would call any other VB6 form.
What's really cool is that you get great intellisense on the InteropForm from VB6!
Let me know if you have any issues.