Solved

C# Calling COM

Posted on 2003-12-04
2
335 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

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction This article series is supposed to shed some light on the use of IDisposable and objects that inherit from it. In essence, a more apt title for this article would be: using (IDisposable) {}. I’m just not sure how many people would ge…
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…
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

706 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now