J
jg
I having trouble with the keyword "ArraySubType" in Visual basic studio beta 2.
I got "Error 1 Name 'ArraySubType' is not declared. Test.vb 1061 4 ..."
for
' array TO COM LPStr
Public Function etst(ByVal iCnt As Integer, _
<MarshalAs(UnmanagedType.LPArray, _
ArraySubType = UnmanagedType.LPStr, SizeParamIndex:=0)> ByRef strMatchReslts() As String) As Integer
The Only thing I have different from the documentation is
- the use of ByVal and ByRef.. However, if I don't use nay, VB will put in ByVal anyway.
- I am declaring a function instead of sub
According to the "Passing Arrays to COM" section of the article
"Default Marshaling for Arrays" on
http://msdn.microsoft.com/library/d...uide/html/cpconDefaultMarshalingForArrays.asp
ELEMENT_TYPE_SZARRAY
When a method containing an ELEMENT_TYPE_SZARRAY parameter (one-dimensional array) is exported from a .NET assembly to a type library, the array parameter is converted to a SAFEARRAY of a given type. The same conversion rules apply to the array element types. The contents of the managed array are automatically copied from managed memory into the SAFEARRAY. For example:
Managed signature
[Visual Basic]
Sub [New](<MarshalAs(UnmanagedType.LPArray, SizeParamIndex:=1)> _
ar() As Long, size as Integer )
Sub [New](<MarshalAs(UnmanagedType.LPArray, SizeParamIndex:=1)> _
ar() As String, size as Integer )
Sub [New](<MarshalAs(UnmanagedType.LPArray, _
ArraySubType= UnmanagedType.LPStr, SizeParamIndex:=1)> _
ar() As String, size as Integer )
[C#]
.......Unmanaged signature
HRESULT New(long ar[]);
HRESULT New(BSTR ar[]);
HRESULT New(LPStr ar[]);
I got "Error 1 Name 'ArraySubType' is not declared. Test.vb 1061 4 ..."
for
' array TO COM LPStr
Public Function etst(ByVal iCnt As Integer, _
<MarshalAs(UnmanagedType.LPArray, _
ArraySubType = UnmanagedType.LPStr, SizeParamIndex:=0)> ByRef strMatchReslts() As String) As Integer
The Only thing I have different from the documentation is
- the use of ByVal and ByRef.. However, if I don't use nay, VB will put in ByVal anyway.
- I am declaring a function instead of sub
According to the "Passing Arrays to COM" section of the article
"Default Marshaling for Arrays" on
http://msdn.microsoft.com/library/d...uide/html/cpconDefaultMarshalingForArrays.asp
ELEMENT_TYPE_SZARRAY
When a method containing an ELEMENT_TYPE_SZARRAY parameter (one-dimensional array) is exported from a .NET assembly to a type library, the array parameter is converted to a SAFEARRAY of a given type. The same conversion rules apply to the array element types. The contents of the managed array are automatically copied from managed memory into the SAFEARRAY. For example:
Managed signature
[Visual Basic]
Sub [New](<MarshalAs(UnmanagedType.LPArray, SizeParamIndex:=1)> _
ar() As Long, size as Integer )
Sub [New](<MarshalAs(UnmanagedType.LPArray, SizeParamIndex:=1)> _
ar() As String, size as Integer )
Sub [New](<MarshalAs(UnmanagedType.LPArray, _
ArraySubType= UnmanagedType.LPStr, SizeParamIndex:=1)> _
ar() As String, size as Integer )
[C#]
.......Unmanaged signature
HRESULT New(long ar[]);
HRESULT New(BSTR ar[]);
HRESULT New(LPStr ar[]);