473,386 Members | 1,803 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,386 software developers and data experts.

uses managed c++ classes in c#

I can't call a method with managed(__gc) c++ class arguments.
e.g.
c++:
public __gc class Point { ... }

public __gc class Line
{
Line(Point *p0, Point *p1) { ... }
}

c#
namespace MyName
{
...
Point p0 = new Point(1,1);
Point p1 = new Point(2,2);
-> Line line = new Line(p0, p1);
...

I get following compiler error at the marked -> line:
error CS1502 ...
error CS1503 Argument1 can't be converted from MyName.Point to Point

Anybody know, how can I call the 'Line constructor' with 'Point' arguments?

Thanks in advance
Thomas
Nov 16 '05 #1
2 2989
Hard to say if you don't post the whole code, but I guess you have defined
Point in the MyName namespace too.

Following works for me:

// File: point.cpp
// Compile with : CL /clr /LD point.cpp
public __gc class Point
{
public:
Point(int p1, int p2)
{
v1 = p1;
v2 = p2;
}
private:
int v1;
int v2;

};
public __gc class Line
{

public:
Line(Point* p1, Point* p2)
{}

// File: test.cs
// Compiler command : csc /r:point.dll test.cs
using System;
namespace MyName
{
class Tester
{
static void Main()
{
Point p1, p2;
p1 = new Point(1,1);
p2 = new Point(2,2);
Line l = new Line(p1, p2);
}
}
}
Willy.
"Thomas" <ad***@versanet.de> wrote in message
news:41********@olaf.komtel.net...
I can't call a method with managed(__gc) c++ class arguments.
e.g.
c++:
public __gc class Point { ... }

public __gc class Line
{
Line(Point *p0, Point *p1) { ... }
}

c#
namespace MyName
{
...
Point p0 = new Point(1,1);
Point p1 = new Point(2,2);
-> Line line = new Line(p0, p1);
...

I get following compiler error at the marked -> line:
error CS1502 ...
error CS1503 Argument1 can't be converted from MyName.Point to Point

Anybody know, how can I call the 'Line constructor' with 'Point'
arguments?

Thanks in advance
Thomas

Nov 16 '05 #2
Your are right. I created a second Point definition in the namespace MyName.
Sorry and thanks
Thomas
"Willy Denoyette [MVP]" <wi*************@pandora.be> schrieb im Newsbeitrag
news:O%***************@TK2MSFTNGP12.phx.gbl...
Hard to say if you don't post the whole code, but I guess you have
defined Point in the MyName namespace too.

Following works for me:

// File: point.cpp
// Compile with : CL /clr /LD point.cpp
public __gc class Point
{
public:
Point(int p1, int p2)
{
v1 = p1;
v2 = p2;
}
private:
int v1;
int v2;

};
public __gc class Line
{

public:
Line(Point* p1, Point* p2)
{}

// File: test.cs
// Compiler command : csc /r:point.dll test.cs
using System;
namespace MyName
{
class Tester
{
static void Main()
{
Point p1, p2;
p1 = new Point(1,1);
p2 = new Point(2,2);
Line l = new Line(p1, p2);
}
}
}
Willy.
"Thomas" <ad***@versanet.de> wrote in message
news:41********@olaf.komtel.net...
I can't call a method with managed(__gc) c++ class arguments.
e.g.
c++:
public __gc class Point { ... }

public __gc class Line
{
Line(Point *p0, Point *p1) { ... }
}

c#
namespace MyName
{
...
Point p0 = new Point(1,1);
Point p1 = new Point(2,2);
-> Line line = new Line(p0, p1);
...

I get following compiler error at the marked -> line:
error CS1502 ...
error CS1503 Argument1 can't be converted from MyName.Point to Point

Anybody know, how can I call the 'Line constructor' with 'Point'
arguments?

Thanks in advance
Thomas


Nov 16 '05 #3

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

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
6
by: Shai Levi | last post by:
Hi, I'm trying to migrate native c++ class to managed c++ class. The native class header definition looks as: class NativeClass { public: typedef void (CbFunc1)(int n,void* p);
4
by: 0to60 | last post by:
I'm trying to create a .dll with VS.NET 2003 Architect that contains a math computational component. I need the guts of the thing to be in native code, as performance is key for that part. But, I...
10
by: Edward Diener | last post by:
The documentation states the names of the various managed operators but does not give the signature for them. Is there some documentation which I have missed that gives the correct signature ? In...
2
by: Paul Kenny | last post by:
Hi, I am trying to expose the functionality of an unmanaged C++ class to the other languages available in the .NET Framework. I have decided to do this by wrapping the unmanaged C++ class in a...
10
by: E.T. Grey | last post by:
Hi, I have a C++ DLL that I want to use from a C# project. I am actually usng a lot of advanced C++ features like templates, partial/specialized templates, functors and callbacks. I am also...
2
by: Steven Cool | last post by:
Hi, DA PROBLEM: Once I wrote a c++ dll. I wanted to use that dll in my new c# project, so I compiled it with the CLR option. The compilation was ok. Like I said, I wanted to use the dll (with...
0
by: Anna | last post by:
Hi, (Initial info: .Net 2003 on Win2000) I'm developing a .Net App that uses a dll (say, dll_1) created in VC6 and _successfully_ recompiled in .Net 2003 (unmanaged, no wrappers). The dll_1...
3
by: WithPit | last post by:
I am trying to create an managed wrapper but have some problems with it by using abstract classes. In my unmanaged library code i had the following three classes with the following hierarchy ...
9
by: Herby | last post by:
Is possible to have a managed method within a Native(un-managed) class within a \clr project? E.g. class myClass { public: #pragma managed void myMethod(void);
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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,...
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...

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.