Solved

C# Calling COM

Posted on 2003-12-04
2
342 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
2 Comments
 
LVL 6

Accepted Solution

by:
townsma earned 50 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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Hey!! 5 37
Object Oriented Programming, C#, referencing, scoping. 13 69
bound data table problem 2 33
.NET Enums [Flags] & Bitwise Design Question 6 27
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

860 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