Solved

COM dll - paramater wants an object

Posted on 2006-06-30
6
222 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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 video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 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

9 Experts available now in Live!

Get 1:1 Help Now