Mixed language programming in Visual Basic.NET

R

Robert Liles

I have recently migrated from Microsoft Professional Development System
Version 7.1 (I know I am in the stone age >G<) to Microsoft Visual
Basic.NET. I am used to writing time critical or very repetitive routines
in Assembly language and linking them into my Basic PDS programs to greatly
enhance execution speed. I can find no information on doing this in VB.NET.
Can someone point me to a resource that will tell me how to pass arguments
to an assembly routine? I know how to create system .DLL files from
assembly so I assume I can call them from VB, but I don't know how to pass
the data, especially strings.

TIA, Bobbo
 
S

Sylvain Lafontaine

You cannot write assembler directly into a VB.NET program, as the underlying
language for all managed languages is the CLI, not the assembler. The CLI
is an intermediate language and will get compiled by the JIT (Just In Time)
compiler just before its execution; however, in the managed world, you
cannot have a direct access to this compiled code. (I believe that you can
write CLI code if you want to; however, it's a so high level language above
assembler that you will hardly see any difference from standard C# of VB.NET
code.)

The easiest way would be to use VC++ managed to provide an interface between
your assembly code and the NET Framework; while another possibility would be
to encapsulate your assembly into a COM object and use Interoperability to
communicate with it. However, the burden of transfering informations
between the managed and the unmanaged worlds will greatly reduce any
performance benefits for most of the cases.

My suggestion would be that you either write your code in C++ with the VC++
NET or that you forget about it and use VB.NET or C# exclusively. (The VC++
Net will give you an easy interface between the managed and the unmanaged
worlds.) Excerpt if you want to interface directly with a physical device,
writing in assembler instead of C++ is probably overkill in your case.

S. L.
 
A

Al

I have recently migrated from Microsoft Professional Development
System Version 7.1 (I know I am in the stone age >G<) to Microsoft
Visual Basic.NET. I am used to writing time critical or very
repetitive routines in Assembly language and linking them into my
Basic PDS programs to greatly enhance execution speed. I can find no
information on doing this in VB.NET. Can someone point me to a
resource that will tell me how to pass arguments to an assembly
routine? I know how to create system .DLL files from assembly so I
assume I can call them from VB, but I don't know how to pass the data,
especially strings.

TIA, Bobbo

You wrote in another post that you can create a DLL

so all you have to do is declare each function Example
<DllImport("avifil32.dll", PreserveSig:=True)> Public Shared Function
AVIFileOpen(ByRef ppfile As Integer, ByVal szFile As [String], ByVal
uMode As Integer, ByVal pclsidHandler As Integer) As Integer End
Function
 

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

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,019
Latest member
RoxannaSta

Latest Threads

Top