I am consuming a COM object written in Delphi that requires a Stream.
The interface generated by VS requests a parameter of type "object"
comReader.LoadFromStream(object stream)
When I use a FileStream or MemoryStream I get an "Invalid argument"-exception.
How do I marshal a stream for COM consummation?
Edit I found this interesting answer: How do I declare an IStream in idl so visual studio maps it to s.w.interop.comtypes?
Basically what you want to do is to implement
System.Runtime.InteropServices.ComTypes.IStream
or use an existing implementing class.If all else fails You should be able to marshal arbitrary data using UnmanagedMemoryStream. (MSDN page)
I think you should create wrapper for .Net Stream that implements COM
IStream
interfaceSee this article (There is partly implementation)