Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 236
  • Last Modified:

COM dll - paramater wants an object

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
Mr_A_Smith
Asked:
Mr_A_Smith
  • 3
  • 2
1 Solution
 
Mr_A_SmithAuthor Commented:
note -- the error i get is at compile time, not runtime
0
 
Mr_A_SmithAuthor Commented:
i suspect that the error is because the parameter is wanting an "object" type, but im sending it a byte array
0
 
AdGrootCommented:

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 Kind of Coding Program is Right for You?

There are many ways to learn to code these days. From coding bootcamps like Flatiron School to online courses to totally free beginner resources. The best way to learn to code depends on many factors, but the most important one is you. See what course is best for you.

 
devsolnsCommented:
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
 
devsolnsCommented:
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
 
Mr_A_SmithAuthor Commented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now