473,569 Members | 2,572 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Calling managed code

Hi,

I just created a solution that is based on unmanaged C++ code. Now, the .net
framework consists of some cool functions and classes - there is especially
one namespace I'd like to use.
That's why I'm currently trying to figure out what's the best way to use
this managed code snippet.
Is it possible to create a managed Dll (in any language, C#,VB,C.net) and
call this out of my unmanged C++ code?
If not, is it possible to create an old-style C++ dll (for calling
convention) and to insert some managed code (just like building a 'hybrid')?

Thanks for any help
Peter
Jul 21 '05 #1
2 1346
You can make a COM callable wrapper for your .Net code and compile it
do a .dll which you will call from your unmanaged code. Here is a link
that may help.

http://www.csharpfriends.com/Article...x?articleID=41

Jul 21 '05 #2
Peter Schmitz wrote:
Hi,

I just created a solution that is based on unmanaged C++ code. Now, the .net
framework consists of some cool functions and classes - there is especially
one namespace I'd like to use.
That's why I'm currently trying to figure out what's the best way to use
this managed code snippet.
Is it possible to create a managed Dll (in any language, C#,VB,C.net) and
call this out of my unmanged C++ code?
If not, is it possible to create an old-style C++ dll (for calling
convention) and to insert some managed code (just like building a 'hybrid')?

Thanks for any help
Peter


Yes, you can. However, I cannot confirm it is a safe method.

I have many cases which need to call Dotnet libraries from C/C++ native
code.

I will create a C/C++ DLL project in VS.NET and complie it with Assembly
Support (/clr).

The project exports native C DLL exported functions as normal.
However, in the functions, it calls to the Dotnet classes (e.g. in C#).

The C/C++ functions need to wrap any input/output parameters between
native and Dotnet datatype.
I still do not encounter any great problem by using this method.

--
Jacky Kwok
jacky@alumni_DO T_cuhk_DOT_edu_ DOT_hk
jacky@compose_D OT_com_DOT_hk
Jul 21 '05 #3

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

Similar topics

2
408
by: b.bardugo | last post by:
Hi all, I have a C# user control (a little app I made to display video). In this code I am using a third party .dll, which is written in C++ (un-managed). I am tring to put this control on a web page and somehow the managed code is working OK but when it arrives the part of the code where it is calling the un-managed .dll it gets an exception...
15
11746
by: Bryan | last post by:
I have a multi-threaded C# console application that uses WMI (System.Management namespace) to make RPC calls to several servers (600+ ) and returns ScheduledJobs. The section of my code that performs the query is contained in a delegate function that I execute via a second thread. On 1 or 2 of the 600+ servers the query hangs. I've tried to...
4
4343
by: zlatko | last post by:
Hello. I am new to .net . I have a managed C++ library. It looks like this. // header file namespace cppnetdll { public __gc class Class1 { public: static int foo_int(void);
5
1767
by: Virajitha Sarma | last post by:
Hi, Can u plz help me out with how to call a C# DLL from C... I tried to find out by searching in net..but i couldnot find anything on it.... Thanku Virajitha *** Sent via Developersdex http://www.developersdex.com ***
1
2889
by: Jesse McGrew | last post by:
Hi all, I'm trying to make a plugin DLL for a third-party application, using VC++ .NET 2003. This DLL acts as a bridge between the C++ plugin API of the application, and my actual plugin code written in C#. When the app calls my unmanaged functions, they work fine. But as soon as my unmanaged functions call managed functions (in the same...
1
2592
by: H.B. | last post by:
Hi, I need to make a function that can display data on my Managed C++ app and be called by an unmanaged C++ DLL. Something like : void Form1::Form1_Load(System::Object * sender, System::EventArgs * e) { MyDLLInit(MyAppDisplayFunction); }
1
3429
by: MC-Advantica | last post by:
Does anyone have a simple "Hello World" like application that demonstrates unmanaged C++ calling managed C++ developed in VS2005? I'm confused by many posts as they discuss managed extensions from VS2003, and related techniques. I have found managed to unmanaged technique very easy in VS2005, but have not been able to build anything with...
11
3181
by: briankirkpatrick | last post by:
Forgive me if my post seems a little amateurish... I'm requesting assistance from some of you smart folks out there to get the managed calls write that meet the specification in the esa.h for Esa_Init. When I make a call, VS2005 reports "AccessViolationException" and refers to the 4th parameter (EsaT_State_Handle). I don't know how to...
3
4695
by: Klaus | last post by:
Hi, I have an existing VC 6 MFC application which communicates asynchronly with a VC 2005 managed code dll. I use an unmanaged base class with virtual functions to access methods in the MFC application. Furthermore, I use a pointer to an unmanaged function to jump back into the managed dll. The managed part is basically a remoting...
7
2668
by: =?Utf-8?B?UVNJRGV2ZWxvcGVy?= | last post by:
I have a C# logging assembly with a static constructor and methods that is called from another C# Assembly that is used as a COM interface for a VB6 Application. Ideally I need to build a file name based on the name of the VB6 application. A second choice would be a file name based on the # COM interface assembly. I have tried calling...
0
7700
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...
0
7614
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...
0
7924
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. ...
1
7676
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
6284
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...
0
3642
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2114
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
1
1221
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.