views:

32

answers:

1

Is there a good way of marshalling a Dictionary<string, string> over COM interop?

Ideas so far include tokenising each KeyPair to an array of strings which can be marshalled as a SafeArray, or having two string arrays containing keys and values.

Neither seems particularly satisfactory. Any ideas?

+1  A: 

I doubt you will find a very elegant solution, since COM interop with non-trivial managed types is always going to involve custom code.

Since your recipient COM client has to know the semantics of the data, you could just marshal to a single SafeArray whose entries are Key1, Value1, Key2, Value2, and so on. Maybe that's just a restatement of the first option you described above, though?

Steve Townsend