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?
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.
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.
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.
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.
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.
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.
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? 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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With