Results 1 to 4 of 4

Thread: .dll question

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    26

    .dll question

    I have a very big problem!
    ( i'm importing that dll!)
    I have a c++(i think 6.0) .dll and .NET makes nothing!
    In VB 6.0 it works great, but in VB .NET not!
    So I import it with DLLImport but it do everything well,
    but at finish the arraylength is only 1 and the result is a integer, that is nowhere in the dll!
    So i think .Net can't really find the Entrypoint or can't interprete it!

    I import it as following:

    VB Code:
    1. <DllImport("C:\VB_SchockKurve.dll", EntryPoint:="CalculateSchockDaten", CallingConvention:=CallingConvention.ThisCall, CharSet:=CharSet.None, SetLastError:=True, ExactSpelling:=True)> _
    2.     Public Shared Function CalculateSchockDaten(ByRef arr1() As Long, ByRef arr2() As Single, ByRef arr3() As Single) As Long

    and the result:
    VB Code:
    1. result = CalculateSchockDaten(array1, array2, array3)

    the code is right and options of the function are the right too.
    But where the problem? Can't .Net import c++ 6.0 dlls???
    Can't it find the entrypoint(but there is no error, but probably it can jump to nothing!)?

    I have anybody here an idea?


    mfg trevex
    PS sorry for bad english, i'm just a german pupil

  2. #2
    Junior Member
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    30

    Exclamation Re: .dll question

    The calling convention is incorrect (Thiscall is used for class methods, try StdCall!).

    Can you give us the signature of your API function (CalculateSchockDaten) in C(++) ?

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jan 2005
    Posts
    26

    Re: .dll question

    StdCall makes Nothing, too. All variables that will be give to the function have after the work only a length of 1! and the var result is an very big integer!
    I can look for the source.
    The function is in the class CalculateSchock is that important?

  4. #4
    Junior Member
    Join Date
    Jan 2005
    Location
    Belgium
    Posts
    30

    Re: .dll question

    We need to make sure that the your DllImport definition of CalculateSchockDaten matches the C/C++ declarationexactly .

    For example, in the C/C++ declaration, the return type has to be __int64, since you used 'Long' as return type.
    If there is only one datatype that doesn't match, you can have the strange behaviour that you described, and cause stack corruption.

    How did you get the DllImport definition ?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width