sebastian.dau@googlemail.com
5/15/2007 8:55:00 AM
Hello News Group,
I try to expose a managed class that has a method returning a managed
array of reference types. However, I cannot get it to run as I receive
Type Missmatch Error in VB when accessing the return value of the
method.
managed code (exported through tlbexp):
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface IAdapterFactory
{
[return: MarshalAs(UnmanagedType.SafeArray )]
ISpectraAdapter[] GetSA();
}
[InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface ISpectraAdapter
{
//omited
}
[ComVisible(true)]
public class SpectraAdapter: ISpectraAdapter
{
//omitted
}
[ComVisible(true)]
public class AdapterFactory : IAdapterFactory
{
public AdapterFactory (){}
public ISpectraAdapter[] GetSA()
{
return this._spectraAdapter;
}
}
VB 6 Consumer:
Private Sub Form_Load()
Dim bla As IAdapterFactory
Dim s() As ISpectraAdapter
Dim ar(1) As Integer
Set bla = New AdapterFactory
bla.InitBLC "42aa9b3c-6c74-46f2-8c67-c621b9078436"
bla.Load
'this call fails
s = bla.GetSA()
Does anyone of you has experiences in exposing typed managed arrays to
COM so that they can get used by VB6 and VBA?
Thanks in advance, Sebastian Dau [MCPD]