473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

Get an IntPtr from Istream interface implementation

I have implemented a C# wrapper (MyStream) for IStream interface. I want to pass an object of type IStream into a COM dll as an IntPtr. For this, I create a MyStream object by reading in a file using File.Read method (which returns a FileStream and I pass that into the MyStream whose constructor takes in the FileStream). The pseudocode is as given below:

Expand|Select|Wrap|Line Numbers
  1.  
  2. MyStream : System.Runtime.Interopservices.ComTypes.IStream
  3. {
  4.    MyStream(System.IO.Stream stream)
  5.    { this.stream = stream }
  6.    //Implement all methods of IStream
  7. }
  8.  
  9. @@@@@@@@@@@@@@@@@@@@
  10.  
  11. MyStream myIStreamObject = new MyStream(File.Read(fileName));
  12.  
  13.  
The myIStreamObject is an implementation of IStream. Is there any way I can get an IntPtr from this myIStreamObject to pass into the COM dll as the dll deals only with IntPtr?
Any help will be appreciated.
Mar 30 '11 #1
1 3304
Plater
7,872 Expert 4TB
I think you are going to need to use the Marshal class.
You will probably need to instanciate your class in a special way so that the memory location can be passed to a COM object.
Apr 12 '11 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: Steve W. | last post by:
I just read the section (and did the exercise) in the C# Step by Step book that covers Explict Interface Implementation (where you specify in the method implementation the specific interface that...
5
by: Keith Patrick | last post by:
Could someone tell me if it's possible (and if so, how) to call an explicitly-implemented interface method from a subclass? I have a class in which I have to explicity implement some methods, but...
2
by: COLIN JACK | last post by:
Hi All, I've got a situation where I'm implementing an interface (BaseInterface in example below) and I want to use explicity interface implementation of an event so that I can add type safety. ...
0
by: Brandon Driesen | last post by:
The following illustrates my question. Why is it when I bind to an a collection of items whose interface implementation is explicit, there is an error during the binding process wherein the error...
4
by: =?Utf-8?B?Sm9obg==?= | last post by:
Hi all, I am developing website application in asp.net , visual C# and atl com. I am using atl com component in visual C# application. One of the function of com component interface returns...
17
by: Galian | last post by:
Hi all. I have some questions about interface implementation, if anybody can help me, I will be very thank. So: If i have some interface IA: class IA { virtual void SomePureVirtFunc() = 0;...
6
by: =?Utf-8?B?RG9uYWxkIFhpZQ==?= | last post by:
In C# 2, this works just fine: public class foo : IEnumerable<string> { private string _list; public IEnumerator<stringGetEnumerator() { foreach (string s in _list) yield return s; }
7
by: Mukesh | last post by:
Hi, Consider a situation where a class (Say C1) is implementing two interfaces (I1, I2). Both the interface contains a method (M1) with the same signature. class C1:I1, I2 { //implementation...
4
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, i am looking for an example that shows how to implement a COM Interface (with events) and pass it to a Windows API Call via pointer. Since this is really new to me, i dont know where to...
2
by: puzzlecracker | last post by:
I don't see the purpose of explicit interface implementation other than to hide its signature in the class that implements it, and, instead, write your own, perhaps with a different signature,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.