Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to call my automation method from VB.NET

12 views
Skip to first unread message

Art

unread,
Apr 29, 2009, 1:11:02 PM4/29/09
to
I've developed an Automation Server and I'm attempting to provide examples
for our customers from various languages. I have my C++ example working, but
I'm having difficulting implementing the same example within VB 2005.

My server provides a method "SetTransformArg" which has an argument to
specify the tranform / matrix. With my C++ test program I did the following:

COleSafeArray matrixArray;
DWORD numElements[] = {4, 4};
matrixArray.Create(VT_R8, 2, numElements);
long index[2];
for(long row = 0; row < 4; row++) {
index[0] = row;
for(long col = 0; col < 4; col++) {
index[1] = col;
double val = row + col*10; // make up values
matrixArray.PutElement(index, &val);
}
}
m_SpatialAnalyzerSDKObject.SetTransformArg(_T("Transform in Working
Coordinates"), matrixArray);

I can't figure out how to do this under VB. From VB, the automation server
method is defined as:

Function SetTransformArg(ByVal argName As String, ByRef matrix As Object) As
Boolean
Member of: SpatialAnalyzerSDK.ISpatialAnalyzerSDK

I've tried simple things like:

Dim matrix(4, 4) As Double
Dim row, col
Dim dval As Double
For row = 0 To 3
For col = 0 To 3
dval = row + col * 10.0
matrix(row, col) = dval ' make up values
Next
Next
NRKSdk.SetTransformArg("Transform in Working Coordinates", matrix)

No matter what I've tried, I always get the runtime error:

An unhandled exception of type 'System.Runtime.InteropServices.COMException'
occurred in mscorlib.dll
Additional information: Type mismatch. (Exception from HRESULT: 0x80020005
(DISP_E_TYPEMISMATCH))

Any help you can shed on this matter would be greatly appreciated!

Thanks in advance!

0 new messages