I just try using/generating COM under C# .NET VS2008 and I have 3 questions:
1. why in some projects I see GUID defined for every interface and class and
in some projects is only written [ComVisible(true)] ? Why both approaches are
allowed ?
2. I did register COM "MyClassLibrary.dll" with:
regasm MyClassLibrary.dll /tlb: MyClassLibrary.TLB
and in another project(but in the same solution) I needed reference to
MyClassLibrary.dll COM object but in COM Tab von "Add Reference" Dialog there
was only MyClassLibrary.TLB and not MyClassLibrary.dll !?
In order to use COM I needed to go to location where COM MyClassLibrary.dll
is located and to add it as assembly reference. In the normal COM programming
one expect to use COM and OS should find (through Registry entry) exact COM
location, right ?
Why In COM Tab where the list of all COM are is not listed
MyClassLibrary.dll ?
3. in a couple of examples projects I saw in Object Browser (after double
click on COM reference) that name of COM in "Object Browser" tool is not any
more "Some_COM_Name" but "Interop.Some_COM_name", why ?
Any help is appretiated!
BR,
Milan
I think the rest of your question can be answered by saying that a managed
code reference to a Win32 COM object starts as a reference to its type
library, and then via a generated interop assembly (converted from the tlb)
and that's what your code calls. In Win32 COM Dlls the typelibrary is often
embedded in the Dll but it doesn't have to be.You don't need the actual COM
Dll to do development, just the type lib. Testing you need both of course.
However, if you're not using any Win32 code at all, and you are calling from
managed code to managed code then you're not expected to be using COM at
all, just normal Add Reference to an assembly. So the only actual COM
reference you can add is to the type library (and an interop assembly). I
don't believe managed code->interop assembly->CCW->managed code actually
works, so don't bother with COM at all if all your calls are managed code to
managed code.
--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972
"Milan" <Mi...@discussions.microsoft.com> wrote in message
news:023521B5-759E-43E9...@microsoft.com...
the "Type Library" is not always denoted with extension ".TLB", right ? so
how to know if something is type library or not ?
Is it possible from .TBL to generate manage assemblies for .NET ?
and do I have to register both .TBL and .dll files if .dll has actual C++
COM definition ?
BR,
Zoki
Generating a managed assembly from a type library is exactly what tlbimp
does, the result being a COM interop assembly.
--
Phil Wilson
The Definitive Guide to Windows Installer
http://www.apress.com/book/view/1590592972
"Milan" <Mi...@discussions.microsoft.com> wrote in message
news:005FA8BB-C11C-411D...@microsoft.com...