473,473 Members | 2,262 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

help needed passing array to COM caller by marshalling

jg
I have searched marshaling articles from MSDN and Google but I am stuck
with solving my problem to marshal arrays to COM caller from my managed COM
class

I built a .net COM class in VB and tested it from an application built with
C tool.. It worked well except for those functions in the VB com class with
arrays.
I had no trouble with scalar parameters passing back and forth between the
COM class and the legacy caller

I got a vague message of
"Error calling external object function etst at line ...."

here is the problematic function in my VB COM class
' 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
' ???what is wrong with this??
Dim strMyC As String() = {"abcdef string 1", "abcdef string 2", _
"abcdef string 3", "abcdef string 4", "abcdef string 5"}
strMatchReslts = strMyC
Return strMyC.GetUpperBound(0)
End Function
in my .net test com class

However after compilation of this test Com class, I tried call from a com
client ( the syntax may look a bit odd because I am using it from an OO
application tool that was buildt with C from some vendor)
long lsz = 5, l
String strArr[]
for l = 1, 1, lsz
strArr[l] = fill(100)
next

/* ...... after steting up and intializing myCOMObj
.... use myCOMObj call some simple test function within COM class with non
array arguments
... and they worked
*/

// so myCOMObj has been setup correctly wihtotu question

long iActualSzReturned
iActualSzReturned = myCOMObj .

myComObj.eTst(lsz, Ref strArr) // no such thing as Out in this language.
Ref is the one to use
// ooops I got runtime error here, unfortunately, it does not tell me
// the exact message
// other then Error calling external object function etst at line 15
// which is the above statment

Nov 21 '05 #1
1 1154
See my answer in your previous thread.

Roman
Nov 21 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Terence | last post by:
Help Need!!! I am writing a program for a distributed system course. I need to marshall all the messages in order to send them thru a socket. The first 8 bytes of the message are used to store the...
6
by: DeepaK K C | last post by:
Could anybody tell me how to pass array to a function by value? -Deepak
17
by: VM | last post by:
In my Windows app, I'm running a batch process that's composed of a FOR loop that'll run 15,000 times (datatable row count), copy cthe data of each row -3 fields- to a struct, and send the strct to...
5
by: Bradley1234 | last post by:
Typically when passing by reference you point to the location of the variable, and can modify the original When passing by value, you include a disposable copy of the variable, but it protects...
4
by: DOTNET | last post by:
Hi, Anybody help me regarding this error: I am assigning the values to the session variables when the button is clicked and passing these session variables to the next page and when I am...
10
by: Russell Mangel | last post by:
I have written the following program using VS2005. The program is a Dynamic Array similar to System.Collections.ArrayList in .NET. The program works okay until I reach 65536, I can't seem to figure...
5
by: totoro2468 | last post by:
Here is a code I am writing. I keep geting segmentation fault. I'm not sure what i'm doing wrong. Can you explain it to me in PLAIN ENGLISH?? void ReadString (char *filename, int *lengthPtr,...
4
by: Christian Maier | last post by:
Hi After surfing a while I have still trouble with this array thing. I have the following function and recive a Segmentation fault, how must I code this right?? Thanks Christian Maier
8
by: =?Utf-8?B?UHVjY2E=?= | last post by:
Hi, I'm using vs2005, .net 2, C# for Windows application. I use DllImport so I can call up a function written in C++ as unmanaged code and compiled as a dll us vs2005. My application is able to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.