Solved

COM dll - paramater wants an object

Posted on 2006-06-30
6
225 Views
Last Modified: 2010-04-16
dear experts

I am using a dll in my program, I need to call a method in a class in this dll file. the method signature is:--

method(.., ref object dataBuffer, ..);

The dataBuffer must contain some audio data, so I read in the audio file like this:

FileStream fs = new FileStream("audiodata.wav", FileMode.Open, FileAccess.Read);
byte[] audioDataBuffer = new byte[fs.Length];
fs.Read(audioDataBuffer, 0, audioDataBuffer.Length);

and then called that method like this:---

method(.., ref audioDataBuffer, ..);

When i compile this it complains that the method call has invalid arguments. How should i send the audio data to that method?



0
Comment
Question by:Mr_A_Smith
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Author Comment

by:Mr_A_Smith
ID: 17018693
note -- the error i get is at compile time, not runtime
0
 

Author Comment

by:Mr_A_Smith
ID: 17018711
i suspect that the error is because the parameter is wanting an "object" type, but im sending it a byte array
0
 
LVL 5

Accepted Solution

by:
AdGroot earned 125 total points
ID: 17018920

Try this, it will compile, but a do not know if its works at runtime


FileStream fs = new FileStream("audiodata.wav", FileMode.Open, FileAccess.Read);
byte[] audioDataBuffer = new byte[fs.Length];
fs.Read(audioDataBuffer, 0, audioDataBuffer.Length);

object objAudioDataBuffer = (object)audioDataBuffer;
     
method(.., ref objAudioDataBuffer, ..);

Ad
 
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 13

Expert Comment

by:devsolns
ID: 17018957
no a byte[] can be sent as an object because it does dervice from object.  byte[] is a class under the covers which is why you get all of the helper methods and properties.

what do all the params look like, lets see.
0
 
LVL 13

Expert Comment

by:devsolns
ID: 17018965
ok its all about the ref keyword.  normally you can simply pass in byte[] in object param and you'll be fine.  but is not the case when using ref keyword.
0
 

Author Comment

by:Mr_A_Smith
ID: 17019029
hi, the API documentation says this:

The 'char *' and 'const char *' buffers of the serialization functions are replaced by 'VARIANT *' pointers on the COM interface (type is VT_ARRAY|VT_UI1).

does this make any sense?
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question