By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,203 Members | 1,620 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,203 IT Pros & Developers. It's quick & easy.

crash when calling a method with multi dimensional string array

P: n/a
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
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.