A Way to use .Net dll in VB6

E

Eric Levy

I am having problems with MS getting rid of MS J++... I have a large
application that uses MS J++ code as a back-end data retrieval mechanism
into a VB application. I am not ready to port my VB app to .Net, but
appearently I have to port my MS J++ code to J#.Net because of the
discontinued support of Java. Is there a way to create a DLL from J#.Net
that my VB 6.0 App can use? Does anyone else have any other suggestions. I
would prefer to keep the code in Java, but it doesn't look like that is
possible unless there is a way to create a DLL that VB can use like VJ++
could create.
Thanks,
Eric
Please e-mail back at:
(e-mail address removed)
Please remove the "_NoSpam" from the e-mail.
 
D

David Browne

Eric Levy said:
I am having problems with MS getting rid of MS J++... I have a large
application that uses MS J++ code as a back-end data retrieval mechanism
into a VB application. I am not ready to port my VB app to .Net, but
appearently I have to port my MS J++ code to J#.Net because of the
discontinued support of Java. Is there a way to create a DLL from J#.Net
that my VB 6.0 App can use? Does anyone else have any other suggestions. I
would prefer to keep the code in Java, but it doesn't look like that is
possible unless there is a way to create a DLL that VB can use like VJ++
could create.
Thanks,


Sure you can. Just port your J++ project to J#. The result will be an
assembly which can be configured for COM interop. From there it can be run
from VB6.

Look up COM interop in the documentation to learn how to use .NET assemblies
which can be used from COM.

David
 
E

Eric Levy

I did this and I had to add _dispatch to my classes that I was calling in
VB6.0 (I'm not sure why I need to add _dispatch, but that is the way it was
listed in the Object Browser.)
I'm now running into the problem:
"Function or interface marked as restricted, or the function uses an
Automation type not supported in Visual Basic"
on the following line of code, which worked fine with my VB compiled code.


rainfall = dataProcessor.getRainfallDouble(ru)

Previous in the code this was called:
ru = dataProcessor.hexAddrToRegionUnit(adoElementsRS!WxStation)

The declaration for getRainfallDouble looks like:
public double getRainfallDouble(int[] rgnunit)

The declaration for the hexAddrToRegionUnits looks like:
public int[] hexAddrToRegionUnit(String HexAddr)

I tried passing ru as a variant and an integer array and neither way will
the code compile. It worked fine in VJ++, what's the difference between the
using the Com Interop and VJ++?
Thanks,
Eric
 
D

David Browne

Eric Levy said:
I did this and I had to add _dispatch to my classes that I was calling in
VB6.0 (I'm not sure why I need to add _dispatch, but that is the way it was
listed in the Object Browser.)
I'm now running into the problem:
"Function or interface marked as restricted, or the function uses an
Automation type not supported in Visual Basic"
on the following line of code, which worked fine with my VB compiled code.


rainfall = dataProcessor.getRainfallDouble(ru)

Previous in the code this was called:
ru = dataProcessor.hexAddrToRegionUnit(adoElementsRS!WxStation)

The declaration for getRainfallDouble looks like:
public double getRainfallDouble(int[] rgnunit)

The declaration for the hexAddrToRegionUnits looks like:
public int[] hexAddrToRegionUnit(String HexAddr)

I tried passing ru as a variant and an integer array and neither way will
the code compile. It worked fine in VJ++, what's the difference between the
using the Com Interop and VJ++?
Thanks,
Eric
VJ++ was as COM language J# has a completely different type system. COM
interop is a large and tricky subject, plus you are working across 2
different languages. So here's a suggestion to bypass a lot of the
marshalling and signature headache you're facing.

Write a wrapper DLL in VB6 which supplies your interface. Just stub out the
implementations. Then run that VB6 project throught the DOT.NET upgrade
wizard. The wizard should handle all of your marshaling troubles. Then in
your VB.NET library you can access your J# library.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top