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 1836
Niklas,
You should be able to declare it with the MarshalAs attribute, like
this:
void DoSomething([MarshalAs(Unman agedType.SafeAr ray,
SafeArraySubTyp e=VarType.VT_DI SPATCH)] 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.co m
"Niklas" <Ni****@discuss ions.microsoft. com> wrote in message
news:85******** *************** ***********@mic rosoft.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_dispat ch([in, out]
SAFEARRAY(IDisp atch*)* 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(Unman agedType.SafeAr ray, SafeArraySubTyp e=VarType.VT_DI SPATCH)] 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.co m
"Niklas" <Ni****@discuss ions.microsoft. com> wrote in message news:85******** *************** ***********@mic rosoft.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) {
document.images.src = eval("mt" +menu+ ".src")
}
alert("imgOff_hidemenu");
hideMenu=setTimeout('Hide(menu,num)',500);
|
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 code...
TCHAR myArray;
DoStuff(myArray);
|
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 am using vector
class(STL), the compiler does not allow me to do this.
I do realize there is a pitfall in this approach(size of arrays not
matching etc), but I wonder how to get around this problem. I have a
class hierachy with abstract base...
|
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 method.
I can debug the method and values are being assigned.
But when I am in the calling procedure I no longer see the values, I
|
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:
public void DisplayVals(params object objArray) {
foreach (object o in objArray)
Console.WriteLine(o.ToString());
}
| |
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 a variant containing an array,
and interop expects a parameter of type object if you are passing a variant
(you are expected to cast it to the correct type in your code). I'd like to
find a way of passing arrays so that you don't need to change...
|
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 Object, it throws a cast error. The only way I've been able to get
this to work is to return an ArrayList and then use the .CopyTo method of the ArrayList to stuff the ArrayList into my array. I've
tried DirectCast and several other methods to get...
|
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
Dim ExistingTolerances() As Double
'oSurfBody is declared and assigned in the following
Call oSurfBody.GetExistingFacetTolerances(ToleranceCount,
ExistingTolerances)
|
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 number) which is the last line of the
following sub routine:
' procedure modifies elements of array and assigns
' new reference (note ByVal)
Sub FirstDouble(ByVal array As Integer())
Dim i As Integer
|
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 to show the array data to the end user.
Can I do that?
How?
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |