Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I deploy Interop.x.dll files with .NET application?

We have a .NET app that consumes COM-objects in different DLLs, also used in the VB6 part of our app. When referencing a COM library, Visual Studio 2012 creates an Interop.x.DLL and references that instead. Should I be distributing Interop.x.DLL from the build machine or regenerating it using some .NET command-line tool? What tool? What is the best practice for deploying a .NET app that references COM?

like image 447
flipdoubt Avatar asked Aug 14 '14 16:08

flipdoubt


People also ask

How do I make my DLL COM visible in C#?

In Project Properties > Application tab > Assembly Information button > check "Make assembly COM-Visible". This makes all public methods in the class COM visible. In Project Properties > Build tab > Set "Platform target" to x86. That's all you need to do to create the DLL.

What is interop DLL C#?

The interop DLL wraps the calls to the VB6 component and makes them transparent. When registering the DLLs on the machine you'll be executing the application on, you still have to register the VB6 DLL. The interop DLL will sit your app's bin folder and Marshal the calls out.

What is .NET interop assembly?

NET client assembly, one or more interop assemblies representing distinct COM type libraries, and one or more registered COM components. Visual Studio and the Windows SDK provide tools to import and convert a type library to an interop assembly, as discussed in Importing a Type Library as an Assembly.

How do you distribute a .NET application?

The . NET Framework provides the following options for distributing applications: Use XCOPY or FTP. Because common language runtime applications are self-describing and require no registry entries, you can use XCOPY or FTP to simply copy the application to an appropriate directory.

How do I deploy an Interop application?

There are two ways to deploy an interop application: By using embedded interop types: Beginning with the .NET Framework 4, you can instruct the compiler to embed type information from an interop assembly into your executable. The compiler embeds only the type information that your application uses.

How do you use Interop types in an executable?

By using embedded interop types: Beginning with the .NET Framework 4, you can instruct the compiler to embed type information from an interop assembly into your executable. The compiler embeds only the type information that your application uses. You do not have to deploy the interop assembly with your application.

What DLL file do I need to install/deploy a C# application?

I hope my question makes sense. I need to install/deploy a C# application to a number of desktops. It needs a third-party DLL file: A C++ library ("lpsolve55.dll", for those interested, it is a free MIP/LP solver, see lpsolve.sourceforge.net/5.5/).

What is COM Interop?

What is COM Interop? COM Interop is a technology included in the .NET Framework Common Language Runtime (CLR) that enables Component Object Model (COM) objects to interact with .NET objects, and vice versa. COM Interop aims to provide access to the existing COM components without requiring that the original component be modified.


1 Answers

No, that is not necessary anymore since VS2010 and .NET 4.0. You simply set the Embed Interop Types property of the interop assembly reference to True. The default setting.

With this option in effect, the interop types get copied into your own assembly, as though you had written the [ComImport] declarations yourself by hand. And only the ones you actually use in your code. The feature pays off most for large ones, the Microsoft.Office.Interop assemblies in particular are very large. But of course always handy as well for small components since you don't have to deploy the interop assembly anymore.

like image 81
Hans Passant Avatar answered Sep 21 '22 21:09

Hans Passant