Groups | Blog | Home
all groups > dotnet interop > november 2006 >

dotnet interop : Extract Interop file from DLL by VB.NET code


Carmine Cairo
11/9/2006 4:02:03 AM
Hi all,

I'm newbie on this NG.
I have a basic question for the expert programmers.

I use VB .NET by 3 months about.
When I want use a factory COM dll in my program normally I follow this
steps in Microsoft Visual Basic .NET Development environment:
1) Add Reference ...
2) Browse for the correct COM component and select it

Automatically the development environment extract the interop file on
the binary directory of the project.

When I run my application I need this file (for Interoperability
issue).

Some time the factory change the version of the COM component, adding
features or fixing bug.
I need to substitute the interop file by hand in the installation
directory of my application to ensure the correct execution of my
application.

Are there a method to extract, by code, the interop file from a DLL
knowing the complete pathname of DLL?

Thanks in advance.
Carmine
TDC
11/9/2006 6:55:53 AM
You can use the tlbimp utility, or you can call the same functionality
via the System.Runtime.InteropServices.TypeLibConverter class.

HTH,
Tom

[quoted text, click to view]
Carmine Cairo
11/9/2006 9:29:39 AM


[quoted text, click to view]

OK, you are the best :-)
Thanks a lot.

[quoted text, click to view]

Carmine
Phil Wilson
11/12/2006 11:49:08 AM
How can this scheme be useful for you? If that COM component adds new
features (interfaces or methods?) you can't call them with your existing
code anyway because your code doesn't know about them. Your VB.NET program
is compiled with a reference to an interop assembly, so you can't use
anything really new in the COM component that it describes unless you
re-compile your program with a reference to the new interop assembly that
exposes the new methods etc. If you were using late-binding calls (like
vbscript) you'd have some hope of discovering new interfaces and methods,
but not with a compile-time reference to an interop assembly.

One of the key points of COM is that upgrades to components must be
compatible with older existing clients, so your existing code will continue
to work because you're calling your current interop assembly that is then
calling the methods in the upgraded COM component. The code in those methods
can change, but if new interfaces and methods are added you won't see them
because you're not compiled with a reference to the new interop assembly. So
you don't need a new interop assembly to call corrected code in the upgraded
COM component, and you need to be compiled with a reference to the new COM
component's new interop assembly before you can call new methods (if you're
not using late binding).
--
Phil Wilson
[Microsoft MVP-Windows Installer]
[quoted text, click to view]

AddThis Social Bookmark Button