Passing arrays from VB6 to C# ActiveX
From: Eugene Khosid (eugenek_at_gweiss.com)
Date: 02/24/04
- Next message: Paul Brun: "Calling C runtime methods in Managed C++ - getting exception, please help"
- Previous message: TheGurr: "Re: Managed c++ DLL call from C#"
- Next in thread: Ying-Shen Yu[MSFT]: "RE: Passing arrays from VB6 to C# ActiveX"
- Reply: Ying-Shen Yu[MSFT]: "RE: Passing arrays from VB6 to C# ActiveX"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 24 Feb 2004 14:03:00 -0500
Hi all,
I ran into this problem and I don't really know which peace of software it
to blame. Anyway, all I'm trying to do is to pass an array of strings
(variable size) from a VB6 client to C# class that exposes an ActiveX
interface. I tried to do various things without much success
1. Do nothing - just declare a class in C# that has a public method that
takes an array of strings and register the class for interop.
If I DONT use ClassInterface(ClassInterfaceType.None), attribute in C# I
dont get the list of availbale member functions in VB but the code WORKS. My
guess is because it uses late binding here.
If I use ClassInterface(ClassInterfaceType.None), attribute in C# then I'm
getting the following error message "Function or interface marked as
restricted, or the function uses an Automation type not supported by VB"
2. Use [MarshalAs(UnmanagedType.SafeArray)] in the declaration in C# code.
The result is same as above.
3. Use [MarshalAs(UnmanagedType.SafeArray)] in the declaration in C# code.
The result is also rather strange. The method is dropped from the type
library and therefore is not available in VB. The type library file looks
like this
[
odl,
uuid(DC6ECF1D-1E43-46BD-AC2D-FBC3222BB938),
version(1.0),
dual,
oleautomation,
custom({0F21F359-AB84-41E8-9A78-36D110E6D2F9},
"com.gweiss.Portal.Class1")
]
interface IPriceFeedExActiveX : IDispatch {
[id(0x60020000)]
HRESULT m1([in] aa* value);
[id(0x60020001)]
HRESULT m2([in] aa* value);
[id(0x60020002)]
HRESULT m3([out, retval] VARIANT_BOOL* pRetVal);
[id(0x60020003)]
HRESULT m4([out, retval] BSTR* pRetVal);
[id(0x60020004)]
HRESULT m5(
[in] ISymbolId* p_sRic,
[in] SAFEARRAY(BSTR) p_aFieldNames,
[out, retval] VARIANT_BOOL* pRetVal);
[id(0x60020006)]
HRESULT m7(
[in] ISymbolId* p_sRic,
[out, retval] VARIANT_BOOL* pRetVal);
[id(0x60020007)]
HRESULT m8(
[in] ISymbolId* p_sRic,
[out, retval] VARIANT_BOOL* pRetVal);
};
Notice the missing entry of m6(...)
I'm really bothered by all these things. I use VS.NET 2003 and VB6 SP5.
Also, everything works fine when calling C# ActiveX from an Excel
spread***.
If anyone can explain these anomalies I'd like to hear it!!
Thanks,
Eugene
- Next message: Paul Brun: "Calling C runtime methods in Managed C++ - getting exception, please help"
- Previous message: TheGurr: "Re: Managed c++ DLL call from C#"
- Next in thread: Ying-Shen Yu[MSFT]: "RE: Passing arrays from VB6 to C# ActiveX"
- Reply: Ying-Shen Yu[MSFT]: "RE: Passing arrays from VB6 to C# ActiveX"
- Messages sorted by: [ date ] [ thread ]