views:

163

answers:

5

I have another program (which I do not have the source for, already compiled) that is calling a DLL. I want to swap the DLL out and put my own in its place, to run my own model (inside the DLLs) rather than this other one that comes with the software.

I have made DLLs in fortran using the G95 compiler that work declaring them dynamically similarly to below. I have also looked into creating DLLs with VB NET, but it seems the only options are Class Libaries, which don't get called and declared the same way as below. I do have the code for the function declaration from the developer, but that is all (see below)

Is there a way to create working DLLs using VB NET that don't involve the class library, that I could name the dll file "318dll.dll", and have a function inside called CalcLoss and thats it, not class, one function only. The only way I know how to create DLLs using VB NET involves the class library and then you have to include existing item, and it magically appears available in your project.

Here is the template calling code for the fortran DLLs that have been working. how do I make this kind of DLL with VB NET?

Thanks.

Declare Sub CalcLoss Lib "318dll.dll" (TanTHT As Single, RanTHT As Single, EXTNSN As Boolean, ByVal Mode As String, Loss As Single, FSPLSS As Single)
+2  A: 

I think you are wanting to create a Win32 DLL library, not a .NET library. That's why you're not seeing the option you want. I'm not sure if there is a way to do this in VB.NET. You will probably need to switch to regular Visual Basic (not .NET) to do this.

jdmichal
VB6 won't do it either. It will create COM class libraries. It'll have to be native C/C++ to create a DLL with a native API.
Toby
@Toby: VB6 can actually coerced to produce Win32 DLLs, but there’s a certain bit of hackery involved.
Konrad Rudolph
A: 

Option 1: Use C++/ME to create an unmanaged wrapper around your VB.NET DLL.

Option 2: Upgrade to a .NET version of FORTRAN.

Jonathan Allen
A: 

If you want to write code in .Net (VB.Net/C#) and expose it to unmanaged applications you could try this tool I wrote. It allows you to tag methods with Attributes and then reassembly the assembly to allow the exports.

There is no support on this code, but it's free to play with. USE AT YOUR OWN RISK

... Extended ...

After you compile you assembly with my ExportAttribute on the method to export, you can run the recompiler to disassemble and reassemble your application. This was only written as a proof of concept. But it worked between VB6/Winbatch to .Net assemblies. It was also tested with the .Net DllImport/PInvoke functions.

Matthew Whited
A: 

Johnathan allen's option #1 is best. You can use .NET libs from c++, VB6.0, etc, MS has docs on it. Just use your library like that.

HOWEVER if for some reason that won't work do this (warning, HACK) if you only call it 1x/sec or less:

C++ Win32 dll: writes the parm values to a temp file. Starts your VB.NET code compiled into an EXE that reads the tempfile and writes another w/ the results. Win32 dll waits for the VB EXE, then reads the file (really wait for it with process lib, don't just look for the output file, that's a world of pain waiting to happen)

FastAl
A: 

So the solution turned out to be just to write the DLL in fortran, because i could just copy and paste a bunch of code already infortran, rather than have a VB dll call a fortran dll. now its all one dll, and it works. Thanks for everyone's input.

Sam Goodness