• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 909
  • Last Modified:

Create Web Reference dll in VB.NET, to be used in VB6

I've little experience with .NET but have seen its cool feature of being able to add a Web Reference to a project and it builds the classes for you.

I am coding in VB6 and would like to use the .NET generated code via a DLL but can't get it to work. Can someone show me how to do the following:

1) Create a VB2005 project, adding the Web Reference https://api.betfair.com/global/v3/BFGlobalService.wsdl

2) Turn this into a DLL that can be referenced in VB6, which exposes the methods and attributes with Intellisense.

3) Show me the basic construction for calling one of the web services from the VB6 environment.

So far, I have managed to do the following:

1) Can create the VB2005 project and add the web reference.
 
2) http://vb-helper.com/howto_vb6_use_net_dll.html says I need to "Register for COM Interop," which I've done, and add "<ClassInterface(ClassInterfaceType.AutoDual)> _" to my class statement. The web reference shown above creates 23 methods from this service, so do I need to add this to every class created? If so, where, because I can't seem to put it anywhere that works.

Without completing the steps in 2, Intellisense will not show the methods and attributes for this DLL, which is what I need. Can someone help me through the steps needed to get this DLL working in VB6?

Regards
James
0
electrum2003
Asked:
electrum2003
1 Solution
 
doobdaveCommented:
Hi,

The attribute: "<ClassInterface(ClassInterfaceType.AutoDual)> _" is a class-level attribute, therefore your can only apply it at the class level, eg:

<ClassInterface(ClassInterfaceType.AutoDual)> _
Public Class MyClass

...

End Class

In order to have intellisense, you will need to add your own comments by typing ''' before each method, this will create the stub for you in VB2005, you will then need to manually add the comments for each method/property that you wish to expose to your VB6 app.

Hope this sets you on the right path, post back if you need further help.

Best Regards,

David
0
 
DEEPESHCommented:
In the above scenario i woukld like to add one thing
For using .Net Dll in VB6 you require it to register this dll on client machine using Regasm.exe, this will list this assembly in Project Refrence Dialog box of Vb6, actually it going to make an entry in registry, which make it interopertable with vb6.
0
 
electrum2003Author Commented:
Hi doobdave

>The attribute: "<ClassInterface(ClassInterfaceType.AutoDual)> _" is a class-level attribute, therefore your can only
> apply it at the class level, eg:
>
> <ClassInterface(ClassInterfaceType.AutoDual)> _
> Public Class MyClass
>
> ...
>
> End Class

Do you mean I have to write my own classes? I'm hoping to just use .NET to auto-generate classes from the web reference.

>In order to have intellisense, you will need to add your own comments by typing ''' before each method, this will
> create the stub for you in VB2005, you will then need to manually add the comments for each method/property
> that you wish to expose to your VB6 app.

I've added some comments to the auto-generated classes but none of this shows up in intellisense in VB6. However, I have referenced the .tlb file in VB6 and intellisense now shows all the web service methods as classes, but does not show the tool-tip with the parameters required to use the class.

eg I can write

"Dim bf1 As" and intellisense shows the complete list of methods, and I select GetEventsReq
"Set bf1 = New GetEventsReq"
"bf1."

At this stage, intellisense should show me all the events and attributes associated with class GetEventsReq, but it doesn't bring up anything. All the methods are there in Object Browser too, but all of them are empty.

>Hope this sets you on the right path, post back if you need further help.

I need to crack this so any help would be very much appreciated.
0
Take Control of Web Hosting For Your Clients

As a web developer or IT admin, successfully managing multiple client accounts can be challenging. In this webinar we will look at the tools provided by Media Temple and Plesk to make managing your clients’ hosting easier.

 
electrum2003Author Commented:
Hi DEEPESH

I can't find regasm.exe! I have tried using regsvr32 but it says it can not find an entry point.

I can still use the .tlb created by VB2005 from the References section in VB6 by browsing to the location of the .tlb file. Trying to do this with the .dll causes "can't add a reference to the specified file"

0
 
DEEPESHCommented:
You will find Regasm on .Net Framework installed path, default is
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Regasm.exe
0
 
electrum2003Author Commented:
Hi DEEPESH

Thanks, I've registered it successfully so it now appears in the References list in VB6.

However, the classes still show no members in object browser.
0
 
DEEPESHCommented:
Strange??? Try using Late binding
0
 
electrum2003Author Commented:
Not sure what you mean by late binding in this context. Can you provide an example?
0
 
DEEPESHCommented:
By lateBinding I mean try using CreateObject,

Just to revice, have you done this two things
1.) Generated Strong Name for your assembly
2.) used tlb option in Regasm

I suggest you to go through these links
http://www.vbdotnetheaven.com/Code/May2004/AccessNetCompsFromVBIA.asp
http://msdn2.microsoft.com/en-us/library/tzat5yw6.aspx
0
 
DEEPESHCommented:
While browsing net i found another usefull artical
http://www.ondotnet.com/pub/a/oreilly/dotnet/news/complus_0801.html
0
 
DEEPESHCommented:
Any Commnet on it
0
 
electrum2003Author Commented:
The solution to achieve the classes being visible to VB6 is to put

ClassInterface(ClassInterfaceType.AutoDual), _

in the class headers for every class created by the web reference and, crucially, to put

Imports System.Runtime.InteropServices

in the first lines of the .vb file created by the web reference.

As none of the respondents was able to tell me this I am unable to award them points, although I thank them for their contribution.

Regards
James
0
 
Computer101Commented:
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now