Hi
I'm creating a .NET dll, which I will use in VB 6. I have no problem
declaring methods, which will take a single Object, String, Integer and so on
as a parameter. I manage even to transfer arrays of Strings and integer, but
I fail to pass an array of Objects in a parameter. How do I declare a method,
where one of the parameters is an Object array, in .NET, which I will use in
VB6?
Regards
/Niklas 2 3891
Niklas,
You should be able to declare it with the MarshalAs attribute, like
this:
void DoSomething([MarshalAs(UnmanagedType.SafeArray,
SafeArraySubType=VarType.VT_DISPATCH)] ref object[] array)
{
// Do something with the array.
}
I'm not sure about the ref, you might need it for VB6 (you can try it
with and without).
Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com
"Niklas" <Ni****@discussions.microsoft.com> wrote in message
news:85**********************************@microsof t.com... Hi I'm creating a .NET dll, which I will use in VB 6. I have no problem declaring methods, which will take a single Object, String, Integer and so on as a parameter. I manage even to transfer arrays of Strings and integer, but I fail to pass an array of Objects in a parameter. How do I declare a method, where one of the parameters is an Object array, in .NET, which I will use in VB6? Regards /Niklas
Hi
Thank you. The VT_DISPATCH worked. The unmanaged signature looks like this
for ref:
[id(0x6002000d)]
BSTR E_a_testObj_obj_ref_att_dispatch([in, out]
SAFEARRAY(IDispatch*)* Value);
Both ByRef and ByVal worked.
Regards
/Niklas
"Nicholas Paldino [.NET/C# MVP]" wrote: Niklas,
You should be able to declare it with the MarshalAs attribute, like this:
void DoSomething([MarshalAs(UnmanagedType.SafeArray, SafeArraySubType=VarType.VT_DISPATCH)] ref object[] array) { // Do something with the array. }
I'm not sure about the ref, you might need it for VB6 (you can try it with and without).
Hope this helps.
-- - Nicholas Paldino [.NET/C# MVP] - mv*@spam.guard.caspershouse.com
"Niklas" <Ni****@discussions.microsoft.com> wrote in message news:85**********************************@microsof t.com... Hi I'm creating a .NET dll, which I will use in VB 6. I have no problem declaring methods, which will take a single Object, String, Integer and so on as a parameter. I manage even to transfer arrays of Strings and integer, but I fail to pass an array of Objects in a parameter. How do I declare a method, where one of the parameters is an Object array, in .NET, which I will use in VB6? Regards /Niklas This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: domeceo |
last post by:
can anyone tell me why I cannot pass values in a setTimeout function
whenever I use this function it says "menu is undefined" after th
alert.
function imgOff(menu, num) {
if (document.images) {...
|
by: jr |
last post by:
Sorry for this very dumb question, but I've clearly got a long way to go!
Can someone please help me pass an array into a function. Here's a starting
point.
void TheMainFunc()
{
// Body of...
|
by: justanotherguy63 |
last post by:
Hi,
I am designing an application where to preserve the hierachy and for
code substitability, I need to pass an array of derived class object in
place of an array of base class object. Since I...
|
by: craigkenisston |
last post by:
Hi,
I created an array of objects like this :
object Values = {myObject.myprop, otherobject.otherprop,
thirdobject.xprop};
Then I pass it to a method. and I get the values filled in that...
|
by: Darsin |
last post by:
Hi all,
I am a new programmer to C# and i am having a following problem.
I want to make a single method which takes a variable length array and
display it contents.
i have defined the method as:...
| |
by: Mark |
last post by:
Hi
From what I understand, you can pass arrays from classic ASP to .NET using
interop, but you have to change the type of the.NET parameter to object.
This seems to be because classic ASP passes...
|
by: Stephen Travis |
last post by:
I'm trying to write a subroutine that will fill an array of some type with several objects of that type. The subroutine works fine
if I directly reference the array but if I pass the array as an...
|
by: Neil Munro |
last post by:
I'm having some "type" difficulty in passing a .NET array (byref) to a COM
based API (Autodesk Inventor). In VB6 the code to return an array of
tolerance values is:
Dim ToleranceCount As Long...
|
by: John Pass |
last post by:
Hi,
In the attached example, I do understand that the references are not changed
if an array is passed by Val. What I do not understand is the result of line
99 (If one can find this by line...
|
by: =?Utf-8?B?U2hhcm9u?= |
last post by:
Hi Gurus,
I need to transfer a jagged array of byte by reference to unmanaged
function, The unmanaged code should changed the values of the array, and when
the unmanaged function returns I need...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...
| |