The attached project is a distillation of an error that I am having when calling a Fortran DLL from a VB.Net executable.
We are trying to use a callback from the Fortran to display output in a VB rich text box. The included project is from Visual Studio 2012 and Intel Visual Fortran Composer XE 2013 SP1 Update 1.
This is the routine causing the error:
SUBROUTINE WRWIN(OUTSTR) C* USE IFCOM ! defines CONVERTTOBSTR and FREESYSSTRING routines USE VB_WRWIN_MOD ! defines VB_WRITEWINDOW VB routine INTEGER IRC ! <i> - screen unit to write to CHARACTER*(*) OUTSTR ! <i> - string to print POINTER ( P2, MY_STR_OUT ) INTEGER*2 MY_STR_OUT(128) P2 = CONVERTSTRINGTOBSTR( TRIM(OUTSTR) ) CALL VBWRITEWINDOW1( P2, IRC ) RETURN END
After the call to VBWRITEWINDOW1, execution stops in Visual Studio with "Windows has triggered a breakpoint in HelloWorld_Basic.exe. This may be due to a corruption of the heap, which indicates a bug in HelloWorld_Basic.exe or any of the DLLs it has loaded.
If I choose the Target Framework for the VB project as ".NET Framework 2.0", the program compiles and runs fine. This error only occurs when I change the framework to .NET Framework 4.5.
SLN file is in the HelloWorld_Basic folder. Both VB and Fortran projects are included in the same solution.
Any help would be greatly appreciated.