473,795 Members | 2,919 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Marshalling Variant Arrays from COM

Helo all,

I have a standalone unmanaged C++ application that makes a call on another
standalone COM server, which raises an event that should be handled in C#.

I am trying to send: unsigned long, double, BSTR, and VARIANT.

The unsigned long, double, and BSTR (marshalled to System.String) work just
fine and dandy.

Now we get to the variants.

I build a SAFEARRAY in C++, and assign first doubles, the fire the COM call;
then integers, fire the COM call, then BSTR, and fire the COM call.

Only the integers make it to the C# event handler.

I am using 1 method to handle ANY variant. I tried 3 different methods, one
each for VARIANTs containing an array of doubles, array of unsigned longs and
array of BSTR. Only the Integer array made it through.

I also changed my code, so instead of assigning VARIANT.vt = R8 | VT_ARRAY
(or VT_BSTR | VT_ARRAY) I used VT_I4 | VT_ARRAY and it made it across all
three times.

Can anyone enlighten me as to just what is going on? It seems like the C#
compiler or processor is checking the underlying TYPES in the VARIANT, and
only allowing over VT_I4 types.

Am I assigning the VARIANT.vt field wrong in C++?

Thanks in advance,

Andrew S. Giles
Nov 17 '05 #1
0 1912

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
7371
by: Thilanga | last post by:
Hi, I want to access a VARIANT array returned by a method in VC++, that is supposed to be a long array. Can anybody suggest me a way of access this array and get the values in it. Following is a sample code:
1
2702
by: Reynardine | last post by:
I am calling a C/C++ DLL from C# and I am marshalling the parameters to the API call by doing a type conversion for each parameter. For example, here is my C++ API method : short int XENO_API XcDatabaseCodes ( HWND hwnd, char FAR * pszDatabase, char FAR * HUGE * FAR * pszItemCategories
0
1079
by: Michael Moreno | last post by:
Hello, I do not find the solution on how to convert this code into .Net public function MyFunc() as variant Dim R as Variant Redim R(0 to 10) as double MyFunc = R end function
1
1548
by: jsshah | last post by:
Hi I want to marshal following Win32 struct into .NEt class or struct as I want to call a native dll function from a Csharp code. The win32 struct ----------------------- typedef struct _FILE_OBJECT_ID_BUFFER {
1
2257
by: gilnux | last post by:
Hi all I've got nearly 2 years experience programming in C and image processing. Now I have to migrate one of my applications to a MFC interface. I am having problems with the VARIANT variable. Let's see. I have been using Matrox Imaging Lybrary (MIL). With this library, I can load an image and pass this image into a C array using the function MbufGet() and perform all my calculations using C.
4
6001
by: buzzluck68 | last post by:
Hello, I am having trouble upgrading my VB apps to .net. When i started at my company there was a dll created here in vb6, and i need to use that dll for many functions that would take too much time to re-create for the limit that i am given. I have to create a new app in .net, per my instructions, but the dll uses variant arrays, and i keep getting an error whenever i pass an object array from my .net app to the vb6 dll which needs...
2
4147
by: Simply_Red | last post by:
I'm using VC6. i have a DLL written in VC6 and used by VB6( and VBA Excel), i use SafeArray as parameter, the array is created(declared), in VB and C++ fill it. now i need VC++ to get an array of array of different sizes, and VB can't know the size of these arrays, so the arrays will be 'created' in VC. here the code that i use(and it crashes):
2
3353
by: calenlas | last post by:
Hi all, I'm taking my first steps into C# <--C++ DLL Interop and unfortunately I've run into (what seems to be) a very complicated case as my first task. Perhaps someone here can help me. I need to pass an array of RADIO_INFO2 structures to be filled by a function in the DLL. This is how the structure is defined in the C++ example that comes with the DLL:
3
397
by: Saad | last post by:
Hi, I have a struct as follows: public __gc struct STTemp { public: int someint; System::Collections::ArrayList* arrTemp;
0
9673
marktang
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...
0
10443
Oralloy
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...
0
10216
jinu1996
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...
1
10165
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,...
0
9044
agi2029
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...
0
6783
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();...
0
5437
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4113
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 we have to send another system
3
2921
bsmnconsultancy
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...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.