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

Exposing unmanaged C++ COM to managed C++ application

Hi, everybody,

I found some simple example of writing of a service application in
managed C++. The only thing my service has to do is periodically to
call some COM Server function written in managed C++.

If I had to expose the interface of my COM Server to unmanaged C++, I
could've simply used:
#include <atlbase.h>
#include "MyCOMServer_i.h"
#include "MyCOMServer_i.c"
..................
...................
...................
In C# I believe, I can "Add Reference" ..

So my question is how can I expose functions of unmanaged C++ COM
to the managed C++ application? Or this is not a trivial task?

Thanks,
Alex

Sep 7 '07 #1
4 1585
Calling COM objects from managed C++ is trivial, since one can readily mix managed and unmanaged code.

Just call CoCreateInstance and go to town.

If you prefer to code managed code only, then "Add Reference" and select the COM tab.

Brian

Sep 7 '07 #2
On Sep 7, 3:06 pm, "Brian Muth" <bm...@mvps.orgwrote:
Calling COM objects from managed C++ is trivial, since one can readily mix managed and unmanaged code.

Just call CoCreateInstance and go to town.

If you prefer to code managed code only, then "Add Reference" and select the COM tab.

Brian
Maybe I wasn't clear in my first post... but
a) I know that I can AddReference in C# project, but I cannot find
this menu item in my C++ project GUI.

b) before I can call CoCreateInstance in my unmanaged application I
use corresponding "#include", I cannot do this in managed project, so
how can I replace this #include in managed C++ project?

Thanks

Sep 7 '07 #3
Hi Alex,
>Calling COM objects from managed C++ is trivial, since one can readily
mix managed and unmanaged code.

Just call CoCreateInstance and go to town.

If you prefer to code managed code only, then "Add Reference" and
select the COM tab.

Brian

Maybe I wasn't clear in my first post... but
a) I know that I can AddReference in C# project, but I cannot find
this menu item in my C++ project GUI.
Right click on the project in the solution explorer, there you find Add
Reference
b) before I can call CoCreateInstance in my unmanaged application I
use corresponding "#include", I cannot do this in managed project, so
how can I replace this #include in managed C++ project?
You can use the #import statement to generate wrapper classes based on the
type library of your COM objects.
Check MSDN for details.

--
SvenC

Sep 8 '07 #4

"Alex" <al******@hotmail.comwrote in message
news:11**********************@50g2000hsm.googlegro ups.com...
Hi, everybody,

I found some simple example of writing of a service application in
managed C++. The only thing my service has to do is periodically to
call some COM Server function written in managed C++.
You have a managed service calling a managed library? Forget about COM, use
the .NET classes directly.
>
If I had to expose the interface of my COM Server to unmanaged C++, I
could've simply used:
#include <atlbase.h>
#include "MyCOMServer_i.h"
#include "MyCOMServer_i.c"
..................
..................
..................
In C# I believe, I can "Add Reference" ..

So my question is how can I expose functions of unmanaged C++ COM
to the managed C++ application? Or this is not a trivial task?
Unmanaged COM you can call the same as always, what makes you think that
#include won't work?
>
Thanks,
Alex

Sep 11 '07 #5

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

Similar topics

0
by: david chang via DotNetMonster.com | last post by:
Hi, guys I am trapped into a big trouble on how to use unmanaged class library code in a C# web application. Now, I am working on a project to develop a web interface for SPlus, a statistical...
3
by: zhphust | last post by:
I want to convert a object of a managed class to a unmanaged structure that has the same member with that managed class. Can anybody tell me how i can do it? Thanks in advance. -- zhphust...
1
by: Sparhawk | last post by:
Hi, my company is going to migrate a large VC++ application to .NET to make use of Windows Forms (the old class library is not updated any more). We are not planning to migrate the rest of the...
2
by: shyam | last post by:
I have a C++ COM based windows service which have more than 30k lines of code and which is stablized over years. We need to take the advantage of the ..NET framework for this project, especially...
9
by: Amit Dedhia | last post by:
Hi All I have a VC++ 2005 MFC application with all classes defined as unmanaged classes. I want to write my application data in xml format. Since ADO.NET has buit in functions available for...
3
by: =?Utf-8?B?U2hhcm9u?= | last post by:
I'm trying to specify the requirement from unmanaged DLL component that will be used by a managed application written in C#. The unmanaged DLL is implementing some kind of algorithm for defect...
3
by: Pixel.to.life | last post by:
Hi, Gurus, I recently attempted to build a .Net forms application, that links with old style unmanaged C++ static libs. Of course I had to recompile the static lib projects to link properly...
3
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...
3
by: Dean Mitchell | last post by:
Hi everyone, We have a c++ server application that we are writing a GUI client application for. To save our time and to avoid duplicating all the code and functionality that already exists in...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: 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
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...
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,...

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.