[Last Call] Learn about multicloud storage options and how to improve your company's cloud strategy. Register Now

x
?
Solved

C# Calling COM

Posted on 2003-12-04
2
Medium Priority
?
347 Views
Last Modified: 2010-04-16
All,
i have an unmanaged C++ COM object, can i call it directly form C# ? if so, could you outline the steps please ?
thanks
0
Comment
Question by:Shay050799
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 6

Accepted Solution

by:
townsma earned 150 total points
ID: 9878631
Using an unmanaged C++ COM object is pretty straight forward.  Firstly, in the Solution Explorer locate you form, and the entry called References. Right click on References to Add Reference. On the selection form select the COM Tab.  Scroll down the list to locate the COM object you require.  If your COM Object isn't listed, you may not have registered you object. Finally use the Select button to add a reference to you COM Object.

Within you code you will need to make a variable of the type of your COM Object, this variable is then used to call the methods and properties of the COM Object.  See sample code below.

      COMSCORINGLib.PlayersClass oPlayers = new COMSCORINGLib.PlayersClass();
      oPlayers.GetRS();

COMSCORINGLib is the name of the COM Object.
PlayersClass is the name of a class within the COM Object.
oPlayers is a local variable to hold the instance of the COM Object.
GetRS() is a method within the class.

Hope this helps, good luck.
0
 
LVL 4

Expert Comment

by:bsmuehmer
ID: 9881660
for more information on this topic there is an excellent book:

.NET and COM: The Complete Interoperability Guide
by Adam Nathan

Paperback: 1608 pages
Publisher: SAMS; 1st edition (January 31, 2002)
ISBN: 067232170X
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

656 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question