473,466 Members | 1,388 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Passing by Reference between C++ and C# using VS.NET 2005 Beta 2

I've got a C++ DLL that I'm trying to pass a value type into by reference.
My C++ class looks like:
public ref class Class1
{
public:
System::Boolean DoSomething(System::Boolean &b)
{
b = !b;
return True;
}
};

My C# code (that won't compile) looks like:

Boolean b = true;
Class1 z = new Class1();
z.DoSomething(ref b);

I've tried all sorts of things without any luck. My first attempt in C++
had:
System::Boolean DoSomething(System::Boolean ^b)
.... but that's a a pass-by-value, and won't allow the calling method to
change the value.
What am I missing?

--
Chris Mullnis
Nov 17 '05 #1
2 918
Try

System::Boolean DoSomething(System::Boolean% b)

Marcus Heege
"Chris Mullins" <cm******@coversant.net> wrote in message
news:Ok**************@TK2MSFTNGP14.phx.gbl...
I've got a C++ DLL that I'm trying to pass a value type into by reference.
My C++ class looks like:
public ref class Class1
{
public:
System::Boolean DoSomething(System::Boolean &b)
{
b = !b;
return True;
}
};

My C# code (that won't compile) looks like:

Boolean b = true;
Class1 z = new Class1();
z.DoSomething(ref b);

I've tried all sorts of things without any luck. My first attempt in C++
had:
System::Boolean DoSomething(System::Boolean ^b)
... but that's a a pass-by-value, and won't allow the calling method to
change the value.
What am I missing?

--
Chris Mullnis

Nov 17 '05 #2
System::Boolean DoSomething(System::Boolean% b)

"Chris Mullins" <cm******@coversant.net> wrote in message
news:Ok**************@TK2MSFTNGP14.phx.gbl...
I've got a C++ DLL that I'm trying to pass a value type into by reference.
My C++ class looks like:
public ref class Class1
{
public:
System::Boolean DoSomething(System::Boolean &b)
{
b = !b;
return True;
}
};

My C# code (that won't compile) looks like:

Boolean b = true;
Class1 z = new Class1();
z.DoSomething(ref b);

I've tried all sorts of things without any luck. My first attempt in C++
had:
System::Boolean DoSomething(System::Boolean ^b)
... but that's a a pass-by-value, and won't allow the calling method to
change the value.
What am I missing?

--
Chris Mullnis

Nov 17 '05 #3

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

Similar topics

48
by: ik | last post by:
ERROR after uninstalling SQL Server 2005 Express I get this message, SQLDMO has not been registered. Please re-run your setupand contact your system administrator. GREAT!!! ReInstalled SQL...
0
by: Raphael Rodrigues | last post by:
Hello, i have a webservice that was functioning perfectly in VS Express 2005 Beta 1. Now i have installed the VS 2005 Professional Pre Beta 2 and when i create a new project and try to add the WEB...
1
by: sofakingfree | last post by:
I keep getting an invalid property assignment error when tring to reference a subform. All I am trying to do is substitute this: Forms!!.SetFocus for this: FormAndSubForm.SetFocus
39
by: Mike MacSween | last post by:
Just spent a happy 10 mins trying to understand a function I wrote sometime ago. Then remembered that arguments are passed by reference, by default. Does the fact that this slowed me down...
11
by: truckaxle | last post by:
I am trying to pass a slice from a larger 2-dimensional array to a function that will work on a smaller region of the array space. The code below is a distillation of what I am trying to...
2
by: Chris Mullins | last post by:
I've got a C++ DLL that I'm trying to pass a value type into by reference. My C++ class looks like: public ref class Class1 { public: System::Boolean DoSomething(System::Boolean &b) { b = !b;...
1
by: Bob | last post by:
Trying to use VBisual web developer express 2005 beta 2. Dragged an accessdatasource to the blank web page. Started to configure. Entered location of an access database. On next page, clicked...
3
by: Adam | last post by:
We have a web site that uses .vb for the web pages and .cs for a class module. We are getting the error in .NET 2.0 and VS 2005 beta 2. It does work with .NET 1.1. When trying to access a page...
3
by: Ross McLean | last post by:
Hi all, I've been teaching myself C# for a new project at work. I have a bit of a background in c++ and java but never been what you could call a guru. I'm having some strange things happening...
12
by: Andrew Bullock | last post by:
Hi, I have two classes, A and B, B takes an A as an argument in its constructor: A a1 = new A(); B b = new B(a1);
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...
0
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...
0
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,...
0
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...
0
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,...
0
isladogs
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...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
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 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.