Re: Arrays from C# to VB6
Why dont you try this:
public void ReferenceArray(ref short[] VB6ArrayRef)
{
VB6ArrayRef = mDefinedArray;
}
and pass in the array that you would like to reference mDefinedArray. I think this should work.
Re: Arrays from C# to VB6
The reason why it doesn't work is that you're expecting to get access to the pointer to the block of memory containing the .NET array.
You don't get this. In fact you should never get this : because the memory is managed it can change location at any time therefore if you could gain access to this pointer then it'd not be safe to assume it won't change.
What interop does is to COPY the array i.e. it creates an intermediate copy of the array which it passes back to VB6.
Therefore when you call ReferenceArray twice you're getting two copies of the array.
In fact .NET is conforming to good practice for DLLs. DLLs should NEVER pass pointers to internal memory back to clients. They should either copy the memory into some form of app-boundary safe memory (global or CoTaskMem type memory) and pass this back or get client to allocate the memory itself first and then copy the contents of its memory into that.
I hope this is clear.
Darwen.