tags:

views:

312

answers:

4

Hello.

For one of a side-projects i need to write a C# app that required to use a third-party INPROC COM object. Unfortunately, C# is not my primary programming language, so my knowledge is a bit limited. Is it any good tutorials available on how to access COM object from C#? The usage of this third-party COM object requires me to create implementation of specified COM interface and supply that implementation into COM object in order for it to function.

+3  A: 

Maybe this is useful for you: http://msdn.microsoft.com/en-us/library/aa645736%28VS.71%29.aspx

Konamiman
A: 

The basics are pretty straightforward, and MSDN has good reference information.

In your C# project, use "Add Reference" to add a reference to the COM component.

If you need to implement a COM interface, create a class that inherits from it:

class MyClass : IMyComInterface
{
   ...
}
Joe
+11  A: 

There is a good book called .NET and COM: The Complete Interoperability Guide that I am about to start reading as I want a better understanding of COM interop. Maybe it would be useful for you too, check it out.

The focus of the book is on COM Interoperability (since it's a much larger subject), and the heart of the discussion is broken down into four parts:

* Using COM Components Within the .NET Framework
* Using .NET Framework Components from COM
* Designing Good .NET Framework Components for COM Clients
* Designing Good COM Components for .NET Framework Clients

The scope of the book is just about everything related to using "unmanaged code" in the .NET Framework. Technologies built on top of COM Interoperability are also covered-Interoperability of Windows Forms Controls and ActiveX controls, Interoperability with COM+, and Interoperability with Distributed COM (DCOM). Although Platform Invocation Services is a separate technology from COM Interoperability, there are many areas of overlap, so including in the book is a natural fit. All of these technologies are a core part of the Common Language Runtime and .NET Framework, and will likely be used not only as the path of migration for existing software projects, but for brand new software development for the next several years

Also have a look at this (legally) free pdf ebook COM and .NET Interoperability which you can download from TheServerSide.com. You have to register before you can download, but you can just bugmenot if you don't feel like it.

Dale Halliwell
Isn't this book a little old? It's year 2002, first versions of .net and c# was just released that time.
Eye of Hell
Yeah, I wondered that too, but I don't think the way COM interop works has changed since the early days of .NET.
Dale Halliwell
+6  A: 

I have quite a large .NET <-> COM bookmark collection that I'm dumping below.

The problem is that no one tutorial/article covers all the basics and gotacha's. So you need to go through a couple of them and mix and match, depending on what you want to do.

Here's the best of what I've found so far...

General .NET COM Articles/Tutorials

MSDN on .NET & COM

ActiveX in .NET

ParmesanCodice
Life saver .... this is exactly what I was looking for .... im not a big fan on the subject but i need to revise this boring topic !!!thanks for the bookmark dumP !!!
IbrarMumtaz