views:

45

answers:

1

I have a COM-Callable Wrapper on a .NET assembly. Some of the methods use streams (System.IO.Stream): either they accept a System.IO.Stream as input, or they return a System.IO.Stream .

I'd like to call one of those methods from a COM environment - Classic ASP.

Is there any possibility to get interop using ADODB.Stream? In other words, I'd like to invoke a method on the COM wrapper and get back, instead of a System.IO.Stream , an instance of ADODB.Stream.

Does this happen automatically?


If not, then can I construct the .NET code so that it does? If so, how? I imagine doing this: on the .NET side of the house, calling CreateInstance on an ADODB.Stream, wrapping it around the existing System.IO.Stream and then returning the instance of the ADODB.Stream to the COM caller. Is this possible? Will it work?

+2  A: 

They are two different objects. They have the same interface, sure, but you can not cast one to another.

You can write code that read from one and then write to another using their IStream interfacer (read to buffer then write to the other stream until there's no more data), if you want to copy the data. Or you can create a class from System.IO.Stream that uses a ADODB.Stream as the data store by forwarding calls to ADODB.Stream.

Sheng Jiang 蒋晟