Hi,
I have a set of classes source in C++ and I want to use those from C#, can
I just make these into a regular DLL and export these and DllImport these
from C# with no problems?
Is it that easy? 13 1860
Hi,
You cannot use DllImport with classes, only with plain C-style functions.
Therefore, you should probably implement a kind of facade API serving as a
bridge between the managed code and the unmanaged object-oriented C++ code.
You can also expose your C++ classes through COM - this would retain the
object-orientness of your unmanaged library to a certain degree, but would
also require more effort.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
<.> wrote in message news:uj*************@tk2msftngp13.phx.gbl... Hi,
I have a set of classes source in C++ and I want to use those from C#,
can I just make these into a regular DLL and export these and DllImport these from C# with no problems?
Is it that easy?
Cant I make a mixed mode assembly?
I mean I have the class source here (Its not mine) and can I make a new .NET
assembly in C++ and make it visible to C# that way?
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:uV**************@tk2msftngp13.phx.gbl... Hi,
You cannot use DllImport with classes, only with plain C-style functions. Therefore, you should probably implement a kind of facade API serving as a bridge between the managed code and the unmanaged object-oriented C++
code. You can also expose your C++ classes through COM - this would retain the object-orientness of your unmanaged library to a certain degree, but would also require more effort.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://www.x-unity.net/teststudio.aspx Bring the power of unit testing to VS .NET IDE
<.> wrote in message news:uj*************@tk2msftngp13.phx.gbl... Hi,
I have a set of classes source in C++ and I want to use those from C#, can I just make these into a regular DLL and export these and DllImport
these from C# with no problems?
Is it that easy?
I just need the fastest way to get access to these classses in C#
I really dont care for the complexity or s.hitness of the library I have to
use. I just have a few days to get it visible in C# :D
<.> wrote in message news:u%****************@TK2MSFTNGP11.phx.gbl... Cant I make a mixed mode assembly?
I mean I have the class source here (Its not mine) and can I make a new
..NET assembly in C++ and make it visible to C# that way? "Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:uV**************@tk2msftngp13.phx.gbl... Hi,
You cannot use DllImport with classes, only with plain C-style
functions. Therefore, you should probably implement a kind of facade API serving as
a bridge between the managed code and the unmanaged object-oriented C++ code. You can also expose your C++ classes through COM - this would retain the object-orientness of your unmanaged library to a certain degree, but
would also require more effort.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://www.x-unity.net/teststudio.aspx Bring the power of unit testing to VS .NET IDE
<.> wrote in message news:uj*************@tk2msftngp13.phx.gbl... Hi,
I have a set of classes source in C++ and I want to use those from
C#, can I just make these into a regular DLL and export these and DllImport
these from C# with no problems?
Is it that easy?
I think it's pretty possible to mix managed and unmanaged code in Managed
C++ projects - so this can really be a viable solution. I haven't done much
Managed C++ programming though (as probably many subscribers to this NG) so
you'd better ask in the more appropriate newsgroup.
--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio http://www.x-unity.net/teststudio.aspx
Bring the power of unit testing to VS .NET IDE
<.> wrote in message news:O2**************@TK2MSFTNGP10.phx.gbl... I just need the fastest way to get access to these classses in C# I really dont care for the complexity or s.hitness of the library I have
to use. I just have a few days to get it visible in C# :D
<.> wrote in message news:u%****************@TK2MSFTNGP11.phx.gbl... Cant I make a mixed mode assembly?
I mean I have the class source here (Its not mine) and can I make a new .NET assembly in C++ and make it visible to C# that way? "Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com>
wrote in message news:uV**************@tk2msftngp13.phx.gbl... Hi,
You cannot use DllImport with classes, only with plain C-style functions. Therefore, you should probably implement a kind of facade API serving
as a bridge between the managed code and the unmanaged object-oriented C++ code. You can also expose your C++ classes through COM - this would retain
the object-orientness of your unmanaged library to a certain degree, but
would also require more effort.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://www.x-unity.net/teststudio.aspx Bring the power of unit testing to VS .NET IDE
<.> wrote in message news:uj*************@tk2msftngp13.phx.gbl... > Hi, > > I have a set of classes source in C++ and I want to use those from C#, can > I just make these into a regular DLL and export these and DllImport these > from C# with no problems? > > Is it that easy? > >
Im hoping it is, I havnt done much C++/CLI code but there is always a first.
I hope I can just make a new project, include these classes and expose them
somehow.
I dont want to have to implement my own API via a facade or worse, COM
belugh.
Doing COM to me is timewasted, I can use theyre native flatt DLL and port
the actual code myself from C++ to C# worst case.
Im gona try for a mixed mode interop assembly as to me thats why we have
such a feature on the .NET platform.
"Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote
in message news:uH**************@TK2MSFTNGP10.phx.gbl... I think it's pretty possible to mix managed and unmanaged code in Managed C++ projects - so this can really be a viable solution. I haven't done
much Managed C++ programming though (as probably many subscribers to this NG)
so you'd better ask in the more appropriate newsgroup.
-- Dmitriy Lapshin [C# / .NET MVP] X-Unity Test Studio http://www.x-unity.net/teststudio.aspx Bring the power of unit testing to VS .NET IDE
<.> wrote in message news:O2**************@TK2MSFTNGP10.phx.gbl... I just need the fastest way to get access to these classses in C# I really dont care for the complexity or s.hitness of the library I have to use. I just have a few days to get it visible in C# :D
<.> wrote in message news:u%****************@TK2MSFTNGP11.phx.gbl... Cant I make a mixed mode assembly?
I mean I have the class source here (Its not mine) and can I make a
new .NET assembly in C++ and make it visible to C# that way? "Dmitriy Lapshin [C# / .NET MVP]" <x-****@no-spam-please.hotpop.com> wrote in message news:uV**************@tk2msftngp13.phx.gbl... > Hi, > > You cannot use DllImport with classes, only with plain C-style functions. > Therefore, you should probably implement a kind of facade API
serving as a > bridge between the managed code and the unmanaged object-oriented
C++ code. > > You can also expose your C++ classes through COM - this would retain the > object-orientness of your unmanaged library to a certain degree, but
would > also require more effort. > > -- > Dmitriy Lapshin [C# / .NET MVP] > X-Unity Test Studio > http://www.x-unity.net/teststudio.aspx > Bring the power of unit testing to VS .NET IDE > > <.> wrote in message news:uj*************@tk2msftngp13.phx.gbl... > > Hi, > > > > I have a set of classes source in C++ and I want to use those
from C#, > can > > I just make these into a regular DLL and export these and
DllImport these > > from C# with no problems? > > > > Is it that easy? > > > > >
<.> wrote in message news:O2**************@TK2MSFTNGP10.phx.gbl... I just need the fastest way to get access to these classses in C# I really dont care for the complexity or s.hitness of the library I have
to use. I just have a few days to get it visible in C# :D
I would build a COM-wrapper for the C++ code. There are tools that do that
for you. Keep the 'dirt' in the C++-DLL, and the C# code neat (using
com-interop). That way future .NET developers can maintain your code without
them knowing anything about unmanaged code.
- Michael S
> Im gona try for a mixed mode interop assembly as to me thats why we have such a feature on the .NET platform.
I'm monitoring this thread. Please report on your findings on mixed mode
interop, if you find the time. I haven't tried that myself and are quite
curious of your experience.
Get back to us...
Regards
- Michael S
Where can I get these tools because I dont want to end up knee deep in COM
s.hit. I want to modify these classes a little as possible if at all
because they are not maintained by me, they are by a 3rd party.
I havnt got alot of COM expereience.
"Michael S" <a@b.c> wrote in message
news:u%****************@TK2MSFTNGP11.phx.gbl... <.> wrote in message news:O2**************@TK2MSFTNGP10.phx.gbl... I just need the fastest way to get access to these classses in C# I really dont care for the complexity or s.hitness of the library I have to use. I just have a few days to get it visible in C# :D
I would build a COM-wrapper for the C++ code. There are tools that do that for you. Keep the 'dirt' in the C++-DLL, and the C# code neat (using com-interop). That way future .NET developers can maintain your code
without them knowing anything about unmanaged code.
- Michael S
I found this on MSDN. http://msdn.microsoft.com/library/de...rp07152002.asp
<.> wrote in message news:uB**************@TK2MSFTNGP10.phx.gbl... Where can I get these tools because I dont want to end up knee deep in COM s.hit. I want to modify these classes a little as possible if at all because they are not maintained by me, they are by a 3rd party.
I havnt got alot of COM expereience.
"Michael S" <a@b.c> wrote in message news:u%****************@TK2MSFTNGP11.phx.gbl... <.> wrote in message news:O2**************@TK2MSFTNGP10.phx.gbl... I just need the fastest way to get access to these classses in C# I really dont care for the complexity or s.hitness of the library I
have to use. I just have a few days to get it visible in C# :D
I would build a COM-wrapper for the C++ code. There are tools that do
that for you. Keep the 'dirt' in the C++-DLL, and the C# code neat (using com-interop). That way future .NET developers can maintain your code
without them knowing anything about unmanaged code.
- Michael S
Is it a big job to make these classes a COM component?
Do I just add a IDL file or something or must I modify the code alot?
<.> wrote in message news:er*************@tk2msftngp13.phx.gbl... I found this on MSDN.
http://msdn.microsoft.com/library/de...us/dncscol/htm
l/csharp07152002.asp
<.> wrote in message news:uB**************@TK2MSFTNGP10.phx.gbl... Where can I get these tools because I dont want to end up knee deep in
COM s.hit. I want to modify these classes a little as possible if at all because they are not maintained by me, they are by a 3rd party.
I havnt got alot of COM expereience.
"Michael S" <a@b.c> wrote in message news:u%****************@TK2MSFTNGP11.phx.gbl... <.> wrote in message news:O2**************@TK2MSFTNGP10.phx.gbl... > I just need the fastest way to get access to these classses in C# > I really dont care for the complexity or s.hitness of the library I
have to > use. I just have a few days to get it visible in C# :D
I would build a COM-wrapper for the C++ code. There are tools that do that for you. Keep the 'dirt' in the C++-DLL, and the C# code neat (using com-interop). That way future .NET developers can maintain your code
without them knowing anything about unmanaged code.
- Michael S
Maybe the most simple solution would be to do the following type of wrapper.
public __gc class SomeWrapper
{
public: SomeWrapper()
{
sc = new SomeClass();
}
public: double someMethod(double num1, double num2)
{
return sc->Add(num1,num2);
}
public: ~SomeWrapper()
{
delete sc;
}
private: SomeClass* sc;
};
<.> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... Is it a big job to make these classes a COM component?
Do I just add a IDL file or something or must I modify the code alot? <.> wrote in message news:er*************@tk2msftngp13.phx.gbl... I found this on MSDN.
http://msdn.microsoft.com/library/de...us/dncscol/htm l/csharp07152002.asp
<.> wrote in message news:uB**************@TK2MSFTNGP10.phx.gbl... Where can I get these tools because I dont want to end up knee deep in COM s.hit. I want to modify these classes a little as possible if at all because they are not maintained by me, they are by a 3rd party.
I havnt got alot of COM expereience.
"Michael S" <a@b.c> wrote in message news:u%****************@TK2MSFTNGP11.phx.gbl... > > <.> wrote in message news:O2**************@TK2MSFTNGP10.phx.gbl... > > I just need the fastest way to get access to these classses in C# > > I really dont care for the complexity or s.hitness of the library
I have > to > > use. I just have a few days to get it visible in C# :D > > I would build a COM-wrapper for the C++ code. There are tools that
do that > for you. Keep the 'dirt' in the C++-DLL, and the C# code neat
(using > com-interop). That way future .NET developers can maintain your code without > them knowing anything about unmanaged code. > > - Michael S > >
Well, so far so good, its building and visible, whether it works or not we
will see :D
<.> wrote in message news:%2****************@TK2MSFTNGP09.phx.gbl... Maybe the most simple solution would be to do the following type of
wrapper.
public __gc class SomeWrapper { public: SomeWrapper() { sc = new SomeClass(); }
public: double someMethod(double num1, double num2) { return sc->Add(num1,num2); }
public: ~SomeWrapper() { delete sc; }
private: SomeClass* sc; };
<.> wrote in message news:%2****************@TK2MSFTNGP12.phx.gbl... Is it a big job to make these classes a COM component?
Do I just add a IDL file or something or must I modify the code alot? <.> wrote in message news:er*************@tk2msftngp13.phx.gbl... I found this on MSDN.
http://msdn.microsoft.com/library/de...us/dncscol/htm l/csharp07152002.asp
<.> wrote in message news:uB**************@TK2MSFTNGP10.phx.gbl... > Where can I get these tools because I dont want to end up knee deep
in COM > s.hit. I want to modify these classes a little as possible if at
all > because they are not maintained by me, they are by a 3rd party. > > I havnt got alot of COM expereience. > > > "Michael S" <a@b.c> wrote in message > news:u%****************@TK2MSFTNGP11.phx.gbl... > > > > <.> wrote in message news:O2**************@TK2MSFTNGP10.phx.gbl... > > > I just need the fastest way to get access to these classses in
C# > > > I really dont care for the complexity or s.hitness of the
library I have > > to > > > use. I just have a few days to get it visible in C# :D > > > > I would build a COM-wrapper for the C++ code. There are tools that do that > > for you. Keep the 'dirt' in the C++-DLL, and the C# code neat (using > > com-interop). That way future .NET developers can maintain your
code > without > > them knowing anything about unmanaged code. > > > > - Michael S > > > > > >
Hello,
In addition, I strongly recommend you the following article which provides
detailed information on wrapping C++ classes in mixed mode.
Managed C++ Migration guide (.doc) http://www.gotdotnet.com/team/cplusp.../mcmigrate.doc
Have a nice day!
Regards,
HuangTM
Microsoft Online Partner Support
MCSE/MCSD
Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: roy |
last post by:
I try to call com written in VB 6.0. When I use VS.net
Studio to do the debuging, some time it works fine, some
time I got the following message:
Server Error in '/GISOnlineReservation'...
|
by: roy |
last post by:
I try to call com written in VB 6.0., some time it works
fine, some time I got the following message:
Server Error in '/GISOnlineReservation' Application....
|
by: keefah |
last post by:
Hi,
I'm writing a C# web app that uses Outlook to send email. I use a reference
to the Microsoft Outlook 11.0 Object Library, but it's giving me problems. I
tracked down some stuff on the Net...
|
by: lacour |
last post by:
I can't seem to figure out the difference between adding a COM dll
reference in VS2003 and by using TLBIMP.
I have a COM dll that references another COM dll, and I want the syntax
of my...
|
by: Nadav |
last post by:
Hi,
Introduction
***************
I have a system build of a collection of 'Native COM objects' and '.NET COM interop' objects, all of the COM objects are managed through a 'Native COM' layer,...
|
by: Rob Edwards |
last post by:
When trying to add the Microsoft CDO for Exchange Management Library (aka CDOEXM.dll) I receive the following message:
"A reference to 'Microsoft CDO for Exchange Management Library' could not be...
|
by: R Reyes |
last post by:
Can someone please explain to me why I can't get the MS Word Interop assembly
to work in my VS2005 project? I'm trying to manipulate MS Word from my Web
Form application and I can't get passed...
|
by: JC |
last post by:
Anybody knows what problem has this code? I think, in the Garbage
Collector? You know the Solution?
The program in the test's case, whit 350 contacts, run OK before number
86. The error is a...
|
by: allbelonging |
last post by:
C#.Net Outlook 2003 automation (programmatically) with Office.Interop.Outlook
Problem:
I have my outlook 2003 configured with multiple mailbox on my local machine.
I want to specify the mailbox...
|
by: Tina |
last post by:
I've gotten this before where it says there is a problem with Interop.MSDASC
but I can't remember what causes this. This is a 1.1 app I'm trying to
debug in vs2005. It was running yesterday just...
|
by: DolphinDB |
last post by:
Tired of spending countless mintues downsampling your data? Look no further!
In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
|
by: ryjfgjl |
last post by:
ExcelToDatabase: batch import excel into database automatically...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM).
In this month's session, we are pleased to welcome back...
|
by: Vimpel783 |
last post by:
Hello!
Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
|
by: jfyes |
last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
|
by: ArrayDB |
last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
|
by: PapaRatzi |
last post by:
Hello,
I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
|
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...
| |