COM dll - paramater wants an object

Posted on 2006-06-30
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?

Question by:Mr_A_Smith
  • 3
  • 2

Author Comment

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

Author Comment

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

Accepted Solution

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, ..);

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

LVL 13

Expert Comment

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.
LVL 13

Expert Comment

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.

Author Comment

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?

Featured Post

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Printing 1 51
VB: Convert 2 dates to specific format 24 48
Example works but why do I need to click twice on button 4 43
C# winforms programmitically move panels 6 29
This article describes a simple method to resize a control at runtime.  It includes ready-to-use source code and a complete sample demonstration application.  We'll also talk about C# Extension Methods. Introduction In one of my applications…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
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…

832 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