473,804 Members | 3,461 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 3008
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.ne t...
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%******** *******@TK2MSFT NGP12.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.ne t...
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
741
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 managed point-of-view I've noticed that: 1) for each managed and unmanaged C function (not C++ classes) I get a public managed static method (defined on a 'Global Functions' class) in the generated assembly with an export name of the form...
6
2771
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
2528
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 need a .net wrapper because this "calculator" is actually a component used by an enterprise app written entirely in .net. What I want to do is have one project. I've created an MC++ .dll project. Its got a __gc class (the wrapper) and a...
10
1651
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 particular I want to implement the op_Assign (=) operator for a __value struct.
2
6018
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 managed one. I have taken a look at following sample code on how to do this. http://longhorn.msdn.microsoft.com/lhsdk/ndp/vcmg_appendixs amplecode.aspx
10
1445
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 using STL containers like std::string, std::vector and std::map quite extensively in my C++ DLL API. However, I can simplify the API so as to make it easier to use from C#. Below, is a very simple "proof of concept" C++ DLL. I would be extremely...
2
4742
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 several classes in it), in my c# project. I added the reference to my c# project. But still I can't use the classes. Do I need to use Dllimport?. When I look at the object browser, i can see all the classes but there
0
1147
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 is set as a dependency in the application project properties (Linker->Input- >Additional Dependencies).
3
1816
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 Referenced (class) Object (abstract class, inheriting from referenced) Node (class, inheriting from object)
9
2075
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
9705
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
9576
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,...
0
10567
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
10323
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...
0
10074
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9138
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
6847
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();...
1
4291
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
2
3809
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.