Is there any possibility for Interop across a COM/.NET boundary between ADODB.Stream and System.IO.Stream?

StackOverflow https://stackoverflow.com/questions/1634598

Question

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?

Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top