Problem passing OBJECT to a COM server

Hi
I have an ATL COM Server that accepts an argument of type variant*.
With VB6 we haven't problems, passing to VB.NET the server method fails because the data is always VT_EMPTY.

// MIDL --

[id(6), helpstring("method ResponseArray")] HRESULT ResponseArray([out] LONG* Slave, [out] LONG* Function, [out] LONG* Count, [in,out] VARIANT* TelegramData, [in] LONG WaitTime);


// Server -

STDMETHODIMP CModBusConnection::ResponseArray(LONG* Slave, LONG* Function, LONG* Count, VARIANT* TelegramData, LONG WaitTime){

if( m_pModBus == NULL )
return E_ACCESSDENIED;

if( !m_pModBus->Connected() )
r
eturn E_ABORT;

if( TelegramData == NULL ){
ATLASSERT( TelegramData != NULL );
return E_INVALIDARG;
}

if( TelegramData->vt != (VT_BYREF | VT_ARRAY | VT_UI1)) {
ATLASSERT( TelegramData->vt == (VT_BYREF | VT_ARRAY | VT_UI1) ) ;
return E_INVALIDARG;
}

long Dims = SafeArrayGetDim(*TelegramData->pparray);

if( Dims !=1 )
return E_INVALIDARG;

long LowerBounds,UpperBounds;

if( FAILED(SafeArrayGetLBound(*TelegramData->pparray,1,&LowerBounds)) )
return E_FAIL;

if( FAILED(SafeArrayGetUBound(*TelegramData->pparray,1,&UpperBounds)) )
return
E_FAIL;

if( LowerBounds <0 || UpperBounds <1024 )
return E_INVALIDARG;

....
// Client -

VB.NET CODE
PrivateSub btnReadRegisters_Click(ByVal senderAs System.Object,ByVal eAs System.EventArgs)Handles btnReadRegisters.Click

Dim RxSlaveAsLong
Dim RxFunctionAsLong
Dim RxByteCountAsLong
Dim ErrorCodeAsLong
Dim DataBuf(1024)AsByte

modbus.ResponseArray(RxSlave, RxFunction, RxByteCount, DataBuf,1000)

Any help would be appreciated.
Thanks

[4776 byte] By [r.guerzoni] at [2008-2-20]
# 1

What version of the runtime (CLR) are you using? Are you using implicit latebinding in your VB.NET client (i.e. Option Strict Off)? If this call is actual a latebound call through IDispatch then there is no way to pass a VARIANT of type VT_VARIANT | VT_BYREF through interop in versions 1.0 and 1.1 of the runtime. See http://blogs.msdn.com/yalvi/archive/2005/02/18/376381.aspx for more details.

YasirAlvi at 2007-9-9 > top of Msdn Tech,.NET Development,Common Language Runtime...

.NET Development

Site Classified