VB .NET DLL Structure problems

VB .NET DLL Structure problems

vader1000's picture

I am upgrading my interface that was originally done in VB 6.0 using CVF 6.6 as the number cruncher via a .DLL compile. Everything worked fine. Now I am upgrading to VB .NET and I am having many problems with structures being passed to the fortran .DLL. I have a simple structure like this:


I can get the first element (MYLONG) to align properly, but everything else falls apart. I have tried everything I can think of in VB to make this work, but it seems impossible. I have been able to force an offset position for the first 2 elemens (MYLONG and MYDOUBLE), and they will come over into the .DLL properly. However, the array is always screwed up. VB is forcing the header information in the structure (length, pointer info, etc). I don't know what to do about this situation. I need a solution to this and fast.

If I pass the structure or class byref in VB, I really get a mess in fortran. There isn't a single value that will align properly. Apparently VB passes loads of header information. If I pass the first element of the object/array from VB byref, I can get a few fields to align, but there are still serious problems.

Can CVF support VB objects? Ie, an instance of a class? I like the compaq compiler, but I need this to work as I wish with .NET. Please let me know what to do about this problem.


3 posts / 0 new
Last post
Jugoslav Dujic's picture

I'm not a VB user, but I happened to have VBTransition2.doc at hand, and I found the following there:

User-defined type storage

Visual Basic 6.0
User-defined data types can contain one or more elements of a data type, an array, or a previously defined user-defined type. In Visual Basic 6.0, they are stored in contiguous blocks of memory.
Visual Basic.NET
In the CLR, user-defined types are stored in whatever format is most efficient. This may or may not be a contiguous block of memory. Structures can be marked with marshalling attributes to ensure they are passed to COM components as a contiguous block of memory.
APIs are marked with a TODO comment wherever you many need to add marshalling attributes (attributes are not added automatically; they are not needed unless you pass the structures to APIs).

This is Greek for me, but looks related. I think entire document describing differences 6.0 vs. NET can be found here.


Jugoslav www.xeffort.com
johngeorge35's picture

check the vb.net specs they have all changed! Where to pass an integer from vb to forttran in vb6 you needed a long that has changed to an integer in vb7
The arrays must now go from 0 to n in vb.nat if you set them up that way they
In vb
Dim a(n,n) as Real
can be passed as FUNC(a(1,1),n
If you define the array in vb properly. I got some things running but it took a lot of finagling
as vb.net has nothing in common with vb6

Login to leave a comment.