IEnumVariant in C#

  • Thread starter Thread starter Jozsef Bekes
  • Start date Start date
J

Jozsef Bekes

Hello,

I need to derive an interface in C# from a COM interface that has been
declared in C++, and this parent interface uses the type IEnumVariant a a
function parameter. Since the stdole namespace does not know about this
type, the C# code fails to compile. I have no idea what to do, I cannot
change the original interface. Does anyone have a suggestion for this
problem?

Thank you for your help.

Regards,
Jozsi
 
Hello,

The interface in question is defined in %WINSYSDIR%\stdole32.tlb as follows:

[
odl,
uuid(00020404-0000-0000-C000-000000000046),
hidden
]
interface IEnumVARIANT : IUnknown {
HRESULT _stdcall Next(
[in] unsigned long celt,
[in] VARIANT* rgvar,
[out] unsigned long* pceltFetched);
HRESULT _stdcall Skip([in] unsigned long celt);
HRESULT _stdcall Reset();
HRESULT _stdcall Clone([out] IEnumVARIANT** ppenum);
};

As it is hidden, tlbimp.exe does not transfer its declaration to the interop
library. However, in the .NET world, this interface's counterpart is
System.Collections.IEnumerator (according to MSDN article titled
'Troubleshooting .NET Interoperability'), and I guess this is what you need
to use.
 
Hi

It did compile, thank you for your help.

Jozsi

Dmytro Lapshyn said:
Hello,

The interface in question is defined in %WINSYSDIR%\stdole32.tlb as
follows:

[
odl,
uuid(00020404-0000-0000-C000-000000000046),
hidden
]
interface IEnumVARIANT : IUnknown {
HRESULT _stdcall Next(
[in] unsigned long celt,
[in] VARIANT* rgvar,
[out] unsigned long* pceltFetched);
HRESULT _stdcall Skip([in] unsigned long celt);
HRESULT _stdcall Reset();
HRESULT _stdcall Clone([out] IEnumVARIANT** ppenum);
};

As it is hidden, tlbimp.exe does not transfer its declaration to the
interop library. However, in the .NET world, this interface's counterpart
is System.Collections.IEnumerator (according to MSDN article titled
'Troubleshooting .NET Interoperability'), and I guess this is what you
need to use.

--
Sincerely,
Dmytro Lapshyn [Visual Developer - Visual C# MVP]


Jozsef Bekes said:
Hello,

I need to derive an interface in C# from a COM interface that has been
declared in C++, and this parent interface uses the type IEnumVariant a a
function parameter. Since the stdole namespace does not know about this
type, the C# code fails to compile. I have no idea what to do, I cannot
change the original interface. Does anyone have a suggestion for this
problem?

Thank you for your help.

Regards,
Jozsi
 
Back
Top