By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,602 Members | 1,507 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,602 IT Pros & Developers. It's quick & easy.

Need Help It is urgent

P: n/a

Hy,
I have a problem at which I can not find the solution:
I have this:
Declare Sub VRB_IO_StdInstel Lib "TWVRB408.DLL" Alias
"_VRB_IO_StdInstel@12" (ByVal Mode As Integer, ByVal szIniFile As
String, ByRef pStdInstel As STR_STANDAARD_INSTELLINGEN)
Structure STR_STANDAARD_INSTELLINGEN
Dim VerbType As Integer ' Verbindingstype: 1..6
Dim DoorgaandProfiel 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(UnmanagedType.ByValArray, SizeConst:=2)> _
Dim padding_1() As Byte ' Boutkwaliteit
Dim BoutKwaliteit As Integer ' Boutkwaliteit
Dim MilieuKorrosief As Integer ' Milieu korrosief: 0=nee, 1=ja

<MarshalAs(UnmanagedType.ByValArray, 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(UnmanagedType.ByValArray, SizeConst:=260)> _
Dim ProfLijst() As Byte ' Naam van actueel gekozen profiellijst

<MarshalAs(UnmanagedType.ByValArray, SizeConst:=240)> _
Dim Profiel(,) As Byte ' Laatst gebruikte profielnamen in
wizard
<MarshalAs(UnmanagedType.ByValArray, 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_StdInstel in the procedure:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim f As New STR_STANDAARD_INSTELLINGEN
f.Initialize()
VRB_IO_StdInstel(0, "C:\Windows\TsWin.ini", f)
End Sub
it give an error like this:
"An unhandled exception of type 'System.TypeLoadException' occurred in
WindowsApplication1.exe

Additional information: Can not marshal field Profiel of type
STR_STANDAARD_INSTELLINGEN: 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

Nov 23 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Hi,

"avy31" <av**********@no-mx.forums.yourdomain.com.au> wrote in message
news:av**********@no-mx.forums.yourdomain.com.au...

Hy,
I have a problem at which I can not find the solution:
I have this:
Declare Sub VRB_IO_StdInstel Lib "TWVRB408.DLL" Alias
"_VRB_IO_StdInstel@12" (ByVal Mode As Integer, ByVal szIniFile As
String, ByRef pStdInstel As STR_STANDAARD_INSTELLINGEN)
Structure STR_STANDAARD_INSTELLINGEN
Dim VerbType As Integer ' Verbindingstype: 1..6
Dim DoorgaandProfiel 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(UnmanagedType.ByValArray, SizeConst:=2)> _
Dim padding_1() As Byte ' Boutkwaliteit
Dim BoutKwaliteit As Integer ' Boutkwaliteit
Dim MilieuKorrosief As Integer ' Milieu korrosief: 0=nee, 1=ja

<MarshalAs(UnmanagedType.ByValArray, 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(UnmanagedType.ByValArray, SizeConst:=260)> _
Dim ProfLijst() As Byte ' Naam van actueel gekozen profiellijst

<MarshalAs(UnmanagedType.ByValArray, SizeConst:=240)> _
Dim Profiel(,) As Byte ' Laatst gebruikte profielnamen in
wizard
<MarshalAs(UnmanagedType.ByValArray, 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_StdInstel in the procedure:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
Dim f As New STR_STANDAARD_INSTELLINGEN
f.Initialize()
VRB_IO_StdInstel(0, "C:\Windows\TsWin.ini", f)
End Sub
it give an error like this:
"An unhandled exception of type 'System.TypeLoadException' occurred in
WindowsApplication1.exe

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

Could anyone give me a solution for this error?
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
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

Nov 23 '05 #2

P: n/a

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

Nov 23 '05 #3

P: n/a
Hi,

"avy31" <av**********@no-mx.forums.yourdomain.com.au> wrote in message
news:av**********@no-mx.forums.yourdomain.com.au...

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.
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.BlockCopy to copy the single dimension array to a
mutli dimension array (and back).

HTH,
Greetings
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

Nov 23 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.