Need Help It is urgent

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • avy31

    Need Help It is urgent


    Hy,
    I have a problem at which I can not find the solution:
    I have this:
    Declare Sub VRB_IO_StdInste l Lib "TWVRB408.D LL" Alias
    "_VRB_IO_StdIns tel@12" (ByVal Mode As Integer, ByVal szIniFile As
    String, ByRef pStdInstel As STR_STANDAARD_I NSTELLINGEN)
    Structure STR_STANDAARD_I NSTELLINGEN
    Dim VerbType As Integer ' Verbindingstype : 1..6
    Dim DoorgaandProfie l As Integer ' Doorgaand profiel: 1=kol,
    2=lig
    Dim Fyd As Integer ' Rekenwaarde vloeispanning
    Dim KlassKonstr As Integer ' Klassifikatie konstruktie:
    1=ongeschoord, 2=geschoord
    <MarshalAs(Unma nagedType.ByVal Array, SizeConst:=2)> _
    Dim padding_1() As Byte ' Boutkwaliteit
    Dim BoutKwaliteit As Integer ' Boutkwaliteit
    Dim MilieuKorrosief As Integer ' Milieu korrosief: 0=nee, 1=ja

    <MarshalAs(Unma nagedType.ByVal Array, SizeConst:=2)> _
    Dim padding_2() As Byte ' Ankerkwaliteit
    Dim AnkerKwaliteit As Integer ' Ankerkwaliteit
    Dim BetonKwaliteit As Integer ' Betonkwaliteit
    Dim VoegKwaliteit As Integer ' Voegkwaliteit
    Dim EBeton As Integer ' E-modulus beton
    Dim EVoeg As Integer ' E-modulus voeg
    Dim Norm As Integer ' Default normkeuze: NT_TGB etc.
    <MarshalAs(Unma nagedType.ByVal Array, SizeConst:=260) > _
    Dim ProfLijst() As Byte ' Naam van actueel gekozen profiellijst

    <MarshalAs(Unma nagedType.ByVal Array, SizeConst:=240) > _
    Dim Profiel(,) As Byte ' Laatst gebruikte profielnamen in
    wizard
    <MarshalAs(Unma nagedType.ByVal Array, SizeConst:=2)> _
    Dim padding_3() As Byte ' Default eindmaat e1 (... * d)
    Dim EindmaatE1 As Integer ' Default eindmaat e1 (... * d)
    Dim SteekmaatS1 As Integer ' Default steekmaat s1 (... * d)
    ' !!! Bufferlengte is: 552


    Public Sub Initialize()
    ReDim padding_1(2)
    ReDim padding_2(2)
    ReDim ProfLijst(260)
    ReDim Profiel(48, 5)
    ReDim padding_3(2)
    End Sub
    End Structure
    And when I try to call the function VRB_IO_StdInste l in the procedure:
    Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
    System.EventArg s) Handles Button1.Click
    Dim f As New STR_STANDAARD_I NSTELLINGEN
    f.Initialize()
    VRB_IO_StdInste l(0, "C:\Windows\TsW in.ini", f)
    End Sub
    it give an error like this:
    "An unhandled exception of type 'System.TypeLoa dException' occurred in
    WindowsApplicat ion1.exe

    Additional information: Can not marshal field Profiel of type
    STR_STANDAARD_I NSTELLINGEN: This type can not be marshaled as a
    structure field."

    Could anyone give me a solution for this error?
    Please it is urgent to solve this.
    Thanks
    Avy


    --
    avy31
    ------------------------------------------------------------------------
    avy31's Profile: http://www.hightechtalks.com/m188
    View this thread: http://www.hightechtalks.com/t2276430

  • Bart Mermuys

    #2
    Re: Need Help It is urgent

    Hi,

    "avy31" <avy31.1xxbxz@n o-mx.forums.yourd omain.com.au> wrote in message
    news:avy31.1xxb xz@no-mx.forums.yourd omain.com.au...[color=blue]
    >
    > Hy,
    > I have a problem at which I can not find the solution:
    > I have this:
    > Declare Sub VRB_IO_StdInste l Lib "TWVRB408.D LL" Alias
    > "_VRB_IO_StdIns tel@12" (ByVal Mode As Integer, ByVal szIniFile As
    > String, ByRef pStdInstel As STR_STANDAARD_I NSTELLINGEN)
    > Structure STR_STANDAARD_I NSTELLINGEN
    > Dim VerbType As Integer ' Verbindingstype : 1..6
    > Dim DoorgaandProfie l As Integer ' Doorgaand profiel: 1=kol,
    > 2=lig
    > Dim Fyd As Integer ' Rekenwaarde vloeispanning
    > Dim KlassKonstr As Integer ' Klassifikatie konstruktie:
    > 1=ongeschoord, 2=geschoord
    > <MarshalAs(Unma nagedType.ByVal Array, SizeConst:=2)> _
    > Dim padding_1() As Byte ' Boutkwaliteit
    > Dim BoutKwaliteit As Integer ' Boutkwaliteit
    > Dim MilieuKorrosief As Integer ' Milieu korrosief: 0=nee, 1=ja
    >
    > <MarshalAs(Unma nagedType.ByVal Array, SizeConst:=2)> _
    > Dim padding_2() As Byte ' Ankerkwaliteit
    > Dim AnkerKwaliteit As Integer ' Ankerkwaliteit
    > Dim BetonKwaliteit As Integer ' Betonkwaliteit
    > Dim VoegKwaliteit As Integer ' Voegkwaliteit
    > Dim EBeton As Integer ' E-modulus beton
    > Dim EVoeg As Integer ' E-modulus voeg
    > Dim Norm As Integer ' Default normkeuze: NT_TGB etc.
    > <MarshalAs(Unma nagedType.ByVal Array, SizeConst:=260) > _
    > Dim ProfLijst() As Byte ' Naam van actueel gekozen profiellijst
    >
    > <MarshalAs(Unma nagedType.ByVal Array, SizeConst:=240) > _
    > Dim Profiel(,) As Byte ' Laatst gebruikte profielnamen in
    > wizard
    > <MarshalAs(Unma nagedType.ByVal Array, SizeConst:=2)> _
    > Dim padding_3() As Byte ' Default eindmaat e1 (... * d)
    > Dim EindmaatE1 As Integer ' Default eindmaat e1 (... * d)
    > Dim SteekmaatS1 As Integer ' Default steekmaat s1 (... * d)
    > ' !!! Bufferlengte is: 552
    >
    >
    > Public Sub Initialize()
    > ReDim padding_1(2)
    > ReDim padding_2(2)
    > ReDim ProfLijst(260)
    > ReDim Profiel(48, 5)
    > ReDim padding_3(2)
    > End Sub
    > End Structure
    > And when I try to call the function VRB_IO_StdInste l in the procedure:
    > Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
    > System.EventArg s) Handles Button1.Click
    > Dim f As New STR_STANDAARD_I NSTELLINGEN
    > f.Initialize()
    > VRB_IO_StdInste l(0, "C:\Windows\TsW in.ini", f)
    > End Sub
    > it give an error like this:
    > "An unhandled exception of type 'System.TypeLoa dException' occurred in
    > WindowsApplicat ion1.exe
    >
    > Additional information: Can not marshal field Profiel of type
    > STR_STANDAARD_I NSTELLINGEN: This type can not be marshaled as a
    > structure field."
    >
    > Could anyone give me a solution for this error?[/color]

    Dim Profiel(,) As Byte ' Laatst gebruikte profielnamen in wizard

    Pinvoke doesn't support multi-dimension arrays inside structures, you can
    declare a single-dimension array whose length is the multiplication of the
    two dimensions.

    HTH
    Greetings


    [color=blue]
    > Please it is urgent to solve this.
    > Thanks
    > Avy
    >
    >
    > --
    > avy31
    > ------------------------------------------------------------------------
    > avy31's Profile: http://www.hightechtalks.com/m188
    > View this thread: http://www.hightechtalks.com/t2276430
    >[/color]


    Comment

    • avy31

      #3
      Re: Need Help It is urgent


      Hy
      Thanks for your help.Seems to be the only solution.
      But it is hard to apply because the 2 dimension array is used in other
      parts of the application as 2 dimension array.
      Do you have another solution?How can I call the parameter as structure
      in DLL function to solve this problem without change the 2 dimension
      array?

      Greetings
      Avy


      --
      avy31
      ------------------------------------------------------------------------
      avy31's Profile: http://www.hightechtalks.com/m188
      View this thread: http://www.hightechtalks.com/t2276430

      Comment

      • Bart Mermuys

        #4
        Re: Need Help It is urgent

        Hi,

        "avy31" <avy31.1xypxy@n o-mx.forums.yourd omain.com.au> wrote in message
        news:avy31.1xyp xy@no-mx.forums.yourd omain.com.au...[color=blue]
        >
        > Hy
        > Thanks for your help.Seems to be the only solution.
        > But it is hard to apply because the 2 dimension array is used in other
        > parts of the application as 2 dimension array.[/color]

        Instead of accessing it like data[i,j], you can access it like data[(i*jd) +
        j] (where jd is the second dimension).

        You could also use Buffer.BlockCop y to copy the single dimension array to a
        mutli dimension array (and back).

        HTH,
        Greetings
        [color=blue]
        > Do you have another solution?How can I call the parameter as structure
        > in DLL function to solve this problem without change the 2 dimension
        > array?
        >
        > Greetings
        > Avy
        >
        >
        > --
        > avy31
        > ------------------------------------------------------------------------
        > avy31's Profile: http://www.hightechtalks.com/m188
        > View this thread: http://www.hightechtalks.com/t2276430
        >[/color]


        Comment

        Working...