locked
Calling a COBOL DLL file from VB.Net RRS feed

  • Question

  • Guys & Gals,

    Basically i have this old DLL built back in 93 that basically takes a bunch of values and automatically runs it through a bunch of algorythms and pushes back some output data to the same memory space as you passed it.

    I personally have no idea how it works, never seeing cobol before in my life :), however this is how it was explained to me by the guys that maintains it.

    They currently have it running perfectly fine in VB6, but using in .net seems to be rather painful.

    I get either:

    Attempted to read or write protected memory. This is often an indication that other memory is corrupt.

    A call to PInvoke function 'COBOLComm!COBOLComm.CobolInterface::Module' has unbalanced the stack. This is likely because the managed PInvoke signature does not match the unmanaged target signature. Check that the calling convention and parameters of the PInvoke signature match the target unmanaged signature.

    Or it does nothing at all to the memory space.  Ive tried using the GCHandle attributes to use 'shared' memory, used teh marshal to put hte structure being passed into 'shared' memory but still nothing at all.  The dll call declaration is:

    <DllImport("OldCobolAlg.DLL", BestFitMapping:=True, CallingConvention:=CallingConvention.Winapi, EntryPoint:="Module", PreserveSig:=False, SetLastError:=False, ThrowOnUnmappableChar:=True)> _
        Public Shared Sub Module(ByVal CommArea As CommArea)
    End Sub

    Anyone got any ideas? or even a point in the right direction?

    Wednesday, March 14, 2007 11:50 PM

All replies

  • What is the Declare statement that you use in VB6 to call this function?

    Toddap_MS

    Monday, March 19, 2007 6:58 PM
    Moderator