COM interop dictionary used in C#

0

I have a third party DLL i need to call from my C# program.

I have added the dll to the references in my project and VS2010 has generated an COM - interop wrapper dll. The interfaces and classes defined in the DLL are now available in my program and working as they should.

Now the problem are the methods which returns a "dictionary" consisting of a key value pair of an integer and a TSEnt object. In the DLL the return type are defined as VARIANT* and in the wrapper as "object". The DLL dosn't include any dictionary interface.

The only interface i have found in C#, that I can successfully cast this returnvalue to is a IEnumerable. But fetching values from the returnvalue using a foreach statement only returns a int32, which is the key-part of the underlying key/value pair.

How do i get the value-part of this dictionary ?

I have tried to cast this to IDictionary, IDictionary< int, object >, Hashtable and many more but all with the same result ... cast error. I guess the DLL is originally written in an early version of Visual Basic.

Please help ... The problem has haunted me for the last 2 weeks ...

Regards Jesper Sandgaard

From the documentation:

Query(String ObjectType, String PropName, String Pattern)
Queries the repository for Objects of type ObjectType with the property PropName 
that have the value Pattern. Returns a Dictionary object containing a list of TSEnt
objects that the repository returns. This list is keyed by the index of the elements
in the list starting from 0. Pattern can contain ‘*’ as wildcard. If the Property
name is a Domained value, use the Display Value in the repository model.

From the DLL (ITypeLib Viewer):

[id(0x00000006), helpstring("method Query")]
HRESULT Query(
[in] BSTR Type,
[in] BSTR PropertyName,
[in] BSTR Pattern,
[out, retval] VARIANT* result);

Definition in VS:

[DispId(6)]
object Query(string Type, string PropertyName, string Pattern);
c#
com
dictionary
vb6
interop
asked on Stack Overflow Jun 25, 2012 by Jesper Sandgaard Sørensen • edited Jun 25, 2012 by Tim Williams

1 Answer

2

If memory serves me right it is Dictionary object from an old COM runtime scripting library: SCRRUN.dll Import COM-TLB into your project and cast a variant that you are getting to that type.

answered on Stack Overflow Jun 25, 2012 by alexm • edited Dec 29, 2018 by jmoreno

User contributions licensed under CC BY-SA 3.0