PC Review


Reply
Thread Tools Rate Thread

calling cpp file from c#

 
 
Ohad
Guest
Posts: n/a
 
      4th Jan 2005
Hi,

Can I use c++ source files in my c# project, and in c# call the c++ classes?
If so, how can I do it?

please cc to my mailbox: (E-Mail Removed)

Thanks a lot
Ohad


 
Reply With Quote
 
 
 
 
Willy Denoyette [MVP]
Guest
Posts: n/a
 
      4th Jan 2005

"Ohad" <(E-Mail Removed)> wrote in message
news:crdmkt$31j$(E-Mail Removed)...
> Hi,
>
> Can I use c++ source files in my c# project, and in c# call the c++
> classes?
> If so, how can I do it?


No, you can't use C++ in a C# project.
You don't CALL classes, you CREATE INSTANCES of c++ classes and you call
methods of these classes, however, this is not possible from C#. One option
is to wrap your C++ classes with managed C++ classes (using VS2003 MC++)
that delegate the method call's.

Willy.


 
Reply With Quote
 
thomas
Guest
Posts: n/a
 
      5th Jan 2005
Hi,

I wraped my C++ classes and it works fine.
There is an other problem. I defined two wrapper classes and I want to use
one of these class to construct an instance the other wrapper class. But the
c# compiler complained and throw an error:

e.g.
c++
public __gc Class1 { ... };
public __gc Class2 {
Class2(Class1 c1, Class1 c2) {... }
};

c##

namespace NewNamespace

Class1 a1, b1;
...
Class2 c2 = new Class2(a1, b1); <-- compiler throw an error

error: NewNamespace::Class1 cannot be converted to Class1

Is there anybody whoe know why it not works?

Thanks in advance
Thomas

"Willy Denoyette [MVP]" <(E-Mail Removed)> schrieb im Newsbeitrag
news:ui%(E-Mail Removed)...
>
> "Ohad" <(E-Mail Removed)> wrote in message
> news:crdmkt$31j$(E-Mail Removed)...
>> Hi,
>>
>> Can I use c++ source files in my c# project, and in c# call the c++
>> classes?
>> If so, how can I do it?

>
> No, you can't use C++ in a C# project.
> You don't CALL classes, you CREATE INSTANCES of c++ classes and you call
> methods of these classes, however, this is not possible from C#. One
> option is to wrap your C++ classes with managed C++ classes (using VS2003
> MC++) that delegate the method call's.
>
> Willy.
>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
batch file calling exe file problem JPS Windows Vista Security 1 20th Dec 2007 01:18 AM
C# ASP.Net calling a CHM file =?Utf-8?B?Sm9zZXBo?= Microsoft C# .NET 1 14th Nov 2006 09:57 PM
Calling FileStream.Create after File.Move gets old file handle =?Utf-8?B?QyMgRGV2?= Microsoft Dot NET Framework 4 13th Jul 2006 12:28 PM
Re: Calling an exe file from FP JL Amerson Microsoft Frontpage 0 16th Mar 2004 04:32 PM
Re: Calling an exe file from FP Steve Easton Microsoft Frontpage 0 16th Mar 2004 04:30 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:14 PM.