- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi
I have created Dll using fortran and I could able to call some subroutines from this Dll file using VB.net and passing the arrays I would like to pass between Fortran Dll and VB.net.But I'm facing a problem to call the subroutine more that one time, in other wards when I run the VB.net(interface) and Run amodel (Which will call the subroutine from Dll file), the simulation will be done without any problems. But if I opened a new model and try to run again I could not call this subroutine again from the Dll (it seems the Dll is busy in some thing, although the simulation is done), so I have to close all the interface to be able to run that model. I hope I could be able to describe my problem, What iam asking for if there is any setting I have to take in consideration while i'm creating the Dll file to over come this problem.
this is the fortran subroutine I'm using
Subroutine FortranDLL(A,IA)
!MS$ATTRIBUTES DLLEXPORT, ALIAS: 'FORTRANDLL' :: FortranDLL
IMPLICIT REAL*8 (A-H,O-Z)
DIMENSION A(5000001),IA(5000001)
OPEN(unit=1000,file=
+'C:\Sams2000\Applications\ATTIF2000\Engine\AttifSavedResults.txt')
CALL ATIFLO00(A,IA)
CLOSE (1000)
Return
End Subroutine FortranDLL
Many thanks
Ahmed
Link Copied
- « Previous
-
- 1
- 2
- Next »
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ok, I will do that, let me thank you one more time for your great help
Many thanks
Ahmed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
You can use something like this (I am writing it from memory) and it is C code.
char *DllName="Fortran.dll";
HMODULE FortranLib=LoadLibrary(DllName);
typedef LPVOID(__cdecl *T_FortranFunction)(double *Array,int *ia);
T_FortranFunction FortranFunction=(T_FortranFunction) GetProcAddress(FortranLib,"FORTRANFUNCTION"); // function name is exported uppercase
FortranFunction(Array,ia); //call to function
BOOL retval=FreeLibrary(FortranLib); //remove library from memory
If You want to use this approach You cannot link against Fortran.lib because linker creates initialisation of library instead You.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sure - if you can figure out how to do something like this from VB it will work, but that's quite complex in VB, if possible at all, and loses a lot of VB's friendliness in syntax.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve
I have thought in some ways in VS to be able to load and unload the DLL file, and I think The only way to do that is using AppDomain in VS so I should be able to load and unload this AppDomain , I have done that but I'm facing a security problem while calling the subroutines from the Dll file , could you please help me to know if there problem I can manage from the dll or VS , I have attached the error I got while calling the Dll subroutine
Many thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Ahmed, sorry, I have never seen that before and would not be able to diagnose based on a screenshot. My guess, though, is that you can't do this. I would encourage you to solve the problem another way. For example, you could have VB call a Fortran DLL that itself used LoadLibrary and GetProcAddress to load the "real" DLL and then call FreeLibrary before returning.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve
Thank you so much for your reply, and I will be do appreciated if you just sent me an example to clarify the other way you suggested , I'm facing a lot of problems with the way I'm using right now.
Many thanks
Ahmed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
I can't write you a complete example, but if you look at the provided sample DLL\LoadLibrary you'll have 90% of it. Perhaps you could even write this part of the application in VB - I have no experience calling Windows API routines from VB. The idea is to give you control over loading and unloading the DLL where you need variables reset.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
No problem at all
I will look at the provided examples and if there is any question I will let you know.
Many thanks
Ahmed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi Steve
I can not find such samples in my computer, Could you please help me to know where it is exist.
Many thanks
Ahmed
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content

- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
- « Previous
-
- 1
- 2
- Next »