473,326 Members | 2,136 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

crash when calling a method with multi dimensional string array

Hi all,

I encounter a problem with a library method that should create a multi
dimensional string array.

Below is the method:
--------------------------------------------------------------------------------
public class StringArrayLibrary
{
public void Create(ref string[,] names)
{
names = new string[3,3];

for (int i = 0; i < 3; i++)
{
for (int j = 0; j < 3; j++)
{
names[i, j] = "John Smith";
}
}
}
}
--------------------------------------------------------------------------------
Calling this method from another c# program is not a problem and works
as expected.

This method has to be available for COM applications also, so i
changed the project property
[assembly: ComVisible(true)]

and I registered the assembly via:
regasm /codebase arraylibrary.dll

Aff course I want to test the com interface by creating a VB6
application and adding the following piece of code in the form_load

----------------------------------------------------------------------
Private Sub Form_Load()
Dim lib As Object
Dim names() As String

Set lib = CreateObject("ArrayLibrary.StringArrayLibrary")

lib.Create names
End Sub
----------------------------------------------------------------------
This program crashes big time and even closes VB6 development
environment.

Next I did was creating the VB6 .EXE and set the "Start external
program" of the .Net arraylibrary project the the vb6 project.exe to
debug the method from VS2005. This crashes with the following
exception:
------------------------------------------------------------
FatalExecutionEngineError was detected:
The runtime has encountered a fatal error. The address of the error
was at 0x7a03d1be, on thread 0xc9c. The error code is 0xc0000005. This
error may be a bug in the CLR or in the unsafe or non-verifiable
portions of user code. Common sources of this bug include user
marshaling errors for COM-interop or PInvoke, which may corrupt the
stack.
------------------------------------------------------------
n.b. 1.
When the C# method is changed to return the string[,] it works fine,
but in my situation is has to be a (reference) parameter.

n.b. 2.
Changing from late binding to early binding does not change the
behaviour.
Any ideas what to do to solve this problem?

Thanks in advance,

Rik Moed

Aug 3 '07 #1
0 1330

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

Similar topics

5
by: KGriffin | last post by:
Hello, I want to store values from several text boxes into a "list" and associate a string with each value. should i use a multi dimensional array, and how do i use it? Thanks, k ***...
4
by: Tad Marshall | last post by:
Hi, I'm reading about arrays in VB.NET and I seem to have a few options for my data structure. I need a multi-dimensional array of structures, and my first thought was Public Structure myStr...
4
by: entitledX | last post by:
Hi, I'm trying to use the HDF library to read a few HDF files that I need to process. The data in each file varies in rows, but the columns remain constant. Because of that, I had dynamically...
4
by: Balaskas Evaggelos | last post by:
Hi, does anyone know how i can sort a multi-dimensional array by a specific field ? for example i want to sort arr where n=2, but i need the data of every array to follow that order. ...
3
by: vvenk | last post by:
Hello: Is is possible to declare a 2-dimensional array, the first dimension being an Integer and the 2nd dimension another data type, say string? Or, is this a bad choice and a dataset may be...
8
by: per9000 | last post by:
Hi all, I have a two-dimensional array of data, f.x int's. We can imagine that the array is "really large". Now I want the data in it and store this in a one-dimensional array. The obvious...
11
by: gianluca | last post by:
Hy list, I've to declare a 3D matrix in C . I tried with that code: double ***mat; mat=(double***)G_malloc(ndimension*(sizeof(double)); but the program send me a run time error.
152
by: vippstar | last post by:
The subject might be misleading. Regardless, is this code valid: #include <stdio.h> void f(double *p, size_t size) { while(size--) printf("%f\n", *p++); } int main(void) { double array = { {...
4
by: =?Utf-8?B?SGVucmlrIFNjaG1pZA==?= | last post by:
Hi, consider the attached code. Serializing the multi-dimensional array takes about 36s vs. 0.36s for the single-dimensional array. Initializing the multi-dimensional array takes about 4s...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

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.