473,383 Members | 1,789 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

out keyword (function prototype)

I trying to send an array to my C# dll function which the
prototype as "C# COM (Dll)":

public int PrintIO(out System.Int64 [] FreeIO ,out int len)

But when trying to call this function (CPP file)

__int64 *heelp;
int len=0;
if (cpi->PrintIO(&heelp,&len) == 0)
i get the following error:

"
COMClient.cpp(60): error
C2664: 'IManagedInterface::PrintIO' : cannot convert
parameter 1 from '__int64 ** ' to 'SAFEARRAY ** '
"
Nov 15 '05 #1
5 2119
i get the following error:

"
COMClient.cpp(60): error
C2664: 'IManagedInterface::PrintIO' : cannot convert
parameter 1 from '__int64 ** ' to 'SAFEARRAY ** '
"


This is more of a C++ question, but basicly you have to create a
SAFEARRAY and pass in that instead.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #2
Jim
Well, I'm a little new to the C# way of doing things
myself, as you'll see from some of my posts in this forum,
so I'm by no means the authority on the subject but...

It seems to me that your C# fxn wants an array of
pointers, and you're making it an OUT argument, presumably
becasue it will modify the contents of the original array
(otherwise you woldn't pass ti as an out, which is, as I
understand it, effectively passing it by reference instead
of by value). However, you are only passing in the
address of a pinter to an __int64, not a pointer to an
array. Me thinks you might want to change your variable
declaration in the C++ file to

__int64* heelp[20]; // or however many you need.

If you don't know how many you need, then you'll have to
create a (**) (piotner to a pointer... Man I love C++ :-
) )... and then initialize it with something...

__int64 **help; // Pointer to a pointer of __int64
*heelp = new __int64[25];
....
delete *heelp[];

But that might put you right back in the same boat. There
is another fxn in C++ I used to use when donig stuff with
ADO and dynamic arrays, a fxn called "CreateSaffeArray()",
and you might want to take a look at that as well.

Again, I'm not the authoority on C#, nor anything else...
Hehehe.. But I hope that helps you out. If not, let me
know and we can take another stab at it. :)

JIM

-----Original Message-----
I trying to send an array to my C# dll function which the
prototype as "C# COM (Dll)":

public int PrintIO(out System.Int64 [] FreeIO ,out int len)
But when trying to call this function (CPP file)

__int64 *heelp;
int len=0;
if (cpi->PrintIO(&heelp,&len) == 0)
i get the following error:

"
COMClient.cpp(60): error
C2664: 'IManagedInterface::PrintIO' : cannot convert
parameter 1 from '__int64 ** ' to 'SAFEARRAY ** '
"
.

Nov 15 '05 #3
"create a SAFEARRAY and pass in that instead."
How to do that?
-----Original Message-----
i get the following error:

"
COMClient.cpp(60): error
C2664: 'IManagedInterface::PrintIO' : cannot convert
parameter 1 from '__int64 ** ' to 'SAFEARRAY ** '
"
This is more of a C++ question, but basicly you have to

create aSAFEARRAY and pass in that instead.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
.

Nov 15 '05 #4
"create a SAFEARRAY and pass in that instead."
How to do that?


Use the SafeArrayCreateEx API or some wrapper class. I'm sure you can
get more help in this in the C++ newsgroup.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/
Please reply only to the newsgroup.
Nov 15 '05 #5
Look up SafeArray in the help.

//should work
public int PrintIO(([MarshalAs(UnmanagedType.SafeArray,
SafeArraySubType=VT_I8)]System.Int64 [] FreeIO ,out int len);

On Tue, 18 Nov 2003 07:15:21 -0800, "[GHO}" <yo*****@taux01.nsc.com>
wrote:
I trying to send an array to my C# dll function which the
prototype as "C# COM (Dll)":

public int PrintIO(out System.Int64 [] FreeIO ,out int len)

But when trying to call this function (CPP file)

__int64 *heelp;
int len=0;
if (cpi->PrintIO(&heelp,&len) == 0)
i get the following error:

"
COMClient.cpp(60): error
C2664: 'IManagedInterface::PrintIO' : cannot convert
parameter 1 from '__int64 ** ' to 'SAFEARRAY ** '
"


Nov 15 '05 #6

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

Similar topics

3
by: Derek Basch | last post by:
Is it bad form to use the global window variable to reference an event handlers window? Like so: function SortableTable() { oFilterAdd = this.document.createElement("button");...
21
by: Rob Somers | last post by:
Hey people, I read a good thread on here regarding the reason why we use function prototypes, and it answered most of my questions, but I wanted to double check on a couple of things, as I am...
18
by: tweak | last post by:
What's the best way to use extern when using multiplefiles that is easiest to maintain? Is it best to declare: extern int a; in a header file and include the header file in all files except...
5
by: siliconwafer | last post by:
Hi all, I wanted to know that is use of extern keyword mandatory in case of global variables and functions used in other source files? i.e consider a following piece of code from MSDN explaining...
1
by: [Yosi] | last post by:
I have the following DLL function prototype: RW_DLL_API int ReadBDll(DWORD Address,DWORD NumOfUnits, BYTE * val); I use this function from C# application as following: extern static int...
41
by: Telmo Costa | last post by:
Hi. I have the following code: -------------------------------------- function Tunnel() { //arguments(???); } function Sum() { var sum = 0; for (i=0; i<arguments.length; i++) sum +=...
32
by: lcdgoncalves | last post by:
Hi everyone Is there a real need to use keyword static with functions, if we simply don't declare their prototypes in .h file? Many textbooks avoid to discuss this matter and/or discuss only...
2
by: DaTurk | last post by:
Hi, I have an interesting issue, well, it's not really an issue, but I'd like to understand the mechanics of what's going on. I have a file, in CLI, which has a class declared, and a static...
23
by: raashid bhatt | last post by:
what is restrict keyword used for? eg int *restrict p;
11
by: moltendorf | last post by:
Alright, another question to pin on the experts. :D I have an issue with "this" keyword in this case. The way I got around it before was to use a window property, but in this case I'm trying to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.