?
Solved

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

Posted on 2006-11-02
15
Medium Priority
?
896 Views
Last Modified: 2008-02-01
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
Comment
Question by:electrum2003
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
15 Comments
 
LVL 8

Expert Comment

by:doobdave
ID: 17856846
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
 
LVL 5

Expert Comment

by:DEEPESH
ID: 17857020
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
 

Author Comment

by:electrum2003
ID: 17857246
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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:electrum2003
ID: 17857262
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
 
LVL 5

Expert Comment

by:DEEPESH
ID: 17857324
You will find Regasm on .Net Framework installed path, default is
C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\Regasm.exe
0
 

Author Comment

by:electrum2003
ID: 17857361
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
 
LVL 5

Expert Comment

by:DEEPESH
ID: 17857387
Strange??? Try using Late binding
0
 

Author Comment

by:electrum2003
ID: 17857745
Not sure what you mean by late binding in this context. Can you provide an example?
0
 
LVL 5

Expert Comment

by:DEEPESH
ID: 17864771
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
 
LVL 5

Expert Comment

by:DEEPESH
ID: 17865393
While browsing net i found another usefull artical
http://www.ondotnet.com/pub/a/oreilly/dotnet/news/complus_0801.html
0
 
LVL 5

Expert Comment

by:DEEPESH
ID: 17987447
Any Commnet on it
0
 

Author Comment

by:electrum2003
ID: 18146146
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
 
LVL 1

Accepted Solution

by:
Computer101 earned 0 total points
ID: 18225515
PAQed with points refunded (500)

Computer101
EE Admin
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question