What is dll interop?

I need clarification. I have a Reportwriter DLL that uses Crystal Reports. It is written in VB6. I have to add this dll to my asp.net project where it creates the interop dll.

As far as I understand, interop dll exists as an intermediary, so my .net code can talk with Reportwriter DLL.

So am I registering an interop DLL or registering the source dll?

+44
interop crystal-reports
Nov 03 '09 at 23:58
source share
4 answers

When you write code in VB6, the compiled result is a COM component. COM components provide interfaces, co-classes, structures, and enumerations that are typically described using a library of type COM. However, in order to consume this COM component in .NET, you need to enter a type description in a format that .NET understands, that is, the .NET assembly (since it cannot directly work with type libraries). Thus, the interop assembly is simply a β€œconverted” COM-type library in which it contains descriptions of interfaces, structures, etc. Which correspond to the same things in the type library.

(The above is somewhat simplified since the interop assembly does not need to be created from the type library - you can, for example, manually specify the code if you want).

Contrary to what is often said, the interop assembly does not contain executable code, and it does not perform any sorting. It contains only type definitions, and the only place it can have methods is interfaces, and methods on interfaces have no implementation. Marshalling .NET calls for COM packages are actually made by the CLR itself based on type descriptions loaded from interop collectors - it generates all the necessary code on the fly.

Now about your question. You need to register the COM-DLL (the output of your VB6) - for example, using regsvr32.exe . You should not (in fact, you cannot) register the interop assembly in this way, because it is not a COM component - it is just a simple .NET assembly, so you can either put it in the same folder with your .exe / .dll , or put it in the GAC as usual.

+85
Nov 04 '09 at 0:12
source share

Good answer from Paul. In addition, starting with the .NET Framework version 4, you do not need to deploy the interop assembly with your application - http://msdn.microsoft.com/en-us/library/tc0204w0.aspx

+7
Jul 10 2018-12-12T00:
source share

You're right. An interoperable DLL transfers calls to the VB6 component and makes them transparent.

When registering the DLL on the computer, you will run the application, you still need to register the VB6 DLL. An interactive DLL will host your application folder and marshal.

+2
Nov 04 '09 at 12:00
source share

You need to register the VB6 dll and specify it in your .NET project; this link will create your Interop.dll

+2
Nov 04 '09 at 12:00
source share



All Articles