469,332 Members | 6,650 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,332 developers. It's quick & easy.

Need an IStream object for COM, help please!

Hi all,
I'm trying to call a COM function from C#
The function gets a paramter of type IStream in C++. I've found the
type System.Runtime.InteropServices.ComTypes.IStream, however I'm not
sure how to create an instance of it to pass as the parameter. Anyone
can tell me what to do? i dont know what to pass in as the parameter,
because I'm not sure how to create an instance of the "IStream" object
in C#

Oct 20 '07 #1
3 4304
Kourosh,

In COM, IStream is not an object, but an interface. You have to
implement that interface on a class, and pass that implementation to the
method to be acted upon.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kourosh" <kd*********@msn.comwrote in message
news:11*********************@v23g2000prn.googlegro ups.com...
Hi all,
I'm trying to call a COM function from C#
The function gets a paramter of type IStream in C++. I've found the
type System.Runtime.InteropServices.ComTypes.IStream, however I'm not
sure how to create an instance of it to pass as the parameter. Anyone
can tell me what to do? i dont know what to pass in as the parameter,
because I'm not sure how to create an instance of the "IStream" object
in C#
Oct 21 '07 #2
oh yea oops :D
so there is no easy way in C# to perhaps use the Stream class, or any
built in COM object from .NET for this purpose?
On Oct 20, 7:02 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
Kourosh,

In COM, IStream is not an object, but an interface. You have to
implement that interface on a class, and pass that implementation to the
method to be acted upon.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Kourosh" <kderakhs...@msn.comwrote in message

news:11*********************@v23g2000prn.googlegro ups.com...
Hi all,
I'm trying to call a COM function from C#
The function gets a paramter of type IStream in C++. I've found the
type System.Runtime.InteropServices.ComTypes.IStream, however I'm not
sure how to create an instance of it to pass as the parameter. Anyone
can tell me what to do? i dont know what to pass in as the parameter,
because I'm not sure how to create an instance of the "IStream" object
in C#- Hide quoted text -

- Show quoted text -

Oct 21 '07 #3
You could create a wrapper which maps the IStream implementation to the
methods on Stream (there isn't a one-to-one correspondence between the
methods on IStream and Stream, but it shouldn't be hard).

However, it depends on what you are trying to feed the method. What is
it that you have the data in which you want the method to access through the
IStream?
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Kourosh" <kd*********@msn.comwrote in message
news:11**********************@v29g2000prd.googlegr oups.com...
oh yea oops :D
so there is no easy way in C# to perhaps use the Stream class, or any
built in COM object from .NET for this purpose?
On Oct 20, 7:02 pm, "Nicholas Paldino [.NET/C# MVP]"
<m...@spam.guard.caspershouse.comwrote:
>Kourosh,

In COM, IStream is not an object, but an interface. You have to
implement that interface on a class, and pass that implementation to the
method to be acted upon.

--
- Nicholas Paldino [.NET/C# MVP]
- m...@spam.guard.caspershouse.com

"Kourosh" <kderakhs...@msn.comwrote in message

news:11*********************@v23g2000prn.googlegr oups.com...
Hi all,
I'm trying to call a COM function from C#
The function gets a paramter of type IStream in C++. I've found the
type System.Runtime.InteropServices.ComTypes.IStream, however I'm not
sure how to create an instance of it to pass as the parameter. Anyone
can tell me what to do? i dont know what to pass in as the parameter,
because I'm not sure how to create an instance of the "IStream" object
in C#- Hide quoted text -

- Show quoted text -

Oct 21 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Juan Carlos CORUÑA | last post: by
1 post views Thread by Jason Heyes | last post: by
1 post views Thread by akickdoe22 | last post: by
3 posts views Thread by Charles Law | last post: by
21 posts views Thread by Peter Larsen [] | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by haryvincent176 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.