By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,906 Members | 1,771 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,906 IT Pros & Developers. It's quick & easy.

Need an IStream object for COM, help please!

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.