Solved

COM dll - paramater wants an object

Posted on 2006-06-30
6
221 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
  • 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
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

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…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

758 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now