HighTechTalks DotNet Forums  

Type Missmatch Error consuming managed Array in VB6

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss Type Missmatch Error consuming managed Array in VB6 in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
sebastian.dau@googlemail.com
 
Posts: n/a

Default Type Missmatch Error consuming managed Array in VB6 - 05-15-2007 , 04:55 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.InterfaceIsIDispatc h)]
public interface IAdapterFactory
{
[return: MarshalAs(UnmanagedType.SafeArray )]
ISpectraAdapter[] GetSA();
}

[InterfaceType(ComInterfaceType.InterfaceIsIDispatc h)]
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]


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.