Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.

Fortran Routines Accessed by VB.Net

Groundsel
Beginner
237 Views
I had this working for VB6.0 and upgraded a project to VB.Net Now, I cannot seem to get the project upgraded to VB.Net to access the Fortran. My method had been to create a dll containing the Fortran routines suitably exported. Then, I expect to include the dll as a reference with VB.Net.
When I tried this, I get an immediate rejection with the message:
"A reference 'C:STANPIPES4R0TestVBSupport.dll' could not be added. This is not a valid assembly or COM component. Only assemblies with the extension 'dll' and COM components can be referenced. Please make sure that the file is accessible and that it is a valid assembly or COM component."
Well, the file is accessible, original (as compiled; not copied), has the dll extension but presumably is not a valid assembly. Perhaps my linker settings are in error? I know that others have apparently had no trouble with this so it must be old hat - but I can't find the answer. If it has come up before, please just point me to the reference. Presumably, the calls etc are as valid now as they were for VB6.0
Cheers!
Tom
0 Kudos
4 Replies
sabalan
New Contributor I
237 Views

I am not a .Net expert but I have come across this: Your Fortran DLL must be compiled with some Fortran for .Net (e.g. Salford FTN95 or Lahey) to be compatible to be included as a reference in your .Net application. If your DLL is compiled with CVF or IVF, then you have to declare it in VB as before (or use DLLIMPORT).

I thinkSteve provided some sample on this forum for mixed VB.Net - IVF. Just search the forum.

Sabalan.

0 Kudos
Groundsel
Beginner
237 Views

I was hoping to hear what Steve did to compile those examples to which you allude. The details discussed during all cases which I havefound on this forumdid not address compilation and dealt with matters already resolved in my instancewhen we were usingVB6.0

As regards the Fortran compiler. I figured that with IVF integrated with Visual Studio.Net 2003, that detail would be satisfied. However, I must be missing something regarding the Fortran project settings.

0 Kudos
Steven_L_Intel1
Employee
237 Views
The manner in which you combine VB.NET and IVF is the same as when you combine VB.NET and CVF. The major difference is that you need to ensure that your DLL routines have the STDCALL calling mechanism.

You cannot add an Intel (or Compaq) Fortran DLL as a "reference" to a .NET assembly, as stated above. You must instead call it using the mechanism for unmanaged code. I did post examples - I'm away on business this week so don't have my samples handy, but there's not much to change from CVF.
0 Kudos
Groundsel
Beginner
237 Views

Thanks, Steve,

It was the transition from VB6 to VB.Net which was giving pause; not the CVF to IVF. Indeed, the routine working with VB6 was compiled with IVF. However, you told me what I needed to know which was that you need to put the full pathname in the declare statement rather than making the dll a "reference". Once that was clear, I noted that this is what allrelated examples I found on this forum seem to have done.

So all that was wrong was that VB.Net was not finding the dll. The reason it worked in VB6 was presumably because the executable in VB6 was fully compiled rather than in debug mode viathe Visual Studio.Net interface. Thus the dll being in the same directory as the exe was found by the latterwithout incident.

I have tried copying the dll into the debug directory of VB.Net and simplifying the declare statement. That does not work. Even worse was placing the dll directory name along the "reference path" of the VB.Net project after which it could not even find system files! Presumably, that was the same bad idea in a different form from my making the dll a reference.

So, for the debug phase of the development, the full pathname of the dll will be included in the declare statement; to be simplified when the solution is finally released.

Cheers!

Tom

0 Kudos
Reply