COM Interop, isolation and exclusion of duplicate links

We use the COM-DLL provided by Microsoft (dsofile.dll) in C # dll written by us (assembly A). In order not to register COM-dll, I switched the property of the Contour to the link to dsofile.dll to true.

This means that when compiling our dll, the visual studio copies dsofile.dll, Interop.DSOfile.dll and its own manifest files to the bin folders of our solution, and the application can work without registering dsofile.dll.

This approach was successful in a small test application.

However, in a real application, Assembly A refers to some of our other DLLs (assembly B and assembly C) and the EXE application. When the native manifest file and the interop dll are copied to the bin folder of the application, different copies of each file are used, since each dll that refers to our first dll creates its own copy.

The result is several copies of the files displayed as links in the installation project (for example, dsofile.dll from the assembly folders A, B and C and EXE, Interop.DSOFile.dll from the assembly A, B and C and EXE, Native.Assembly A .manifest from the assembly folders A, B, C, and EXE) and the compiler warning ("Two or more objects have the same target location").

In addition, if the manifest and interop dll that were copied to the destination folder did not come directly from the Assembly A folder (because duplicate files are overwritten with each other), the application cannot successfully load the COM DLL.

I was forced to manually exclude duplicate file copies from the installation dependencies, but they reappear when the solution reboots or rebuilds.

Can someone help with a better method for isolated deployment of a dll COM library? I would also like to include manifests, if possible, but I have not been successful so far.

As an alternative, I studied the automation of the task of eliminating duplicate copies using EnvDTE for Visual Studio Automation, but I could not learn how to access the nodes of the detected dependencies so that I could identify and exclude them. Access to them with the UIHierarchyItem interface shows the name of the installation project as a name property for each file and does not have an exception option.

Any advice would be appreciated.

+3
source share
1 answer

I solved a similar problem in the past, referring to the projects, not the assemblies themselves. The deployment project has some problems with several assembly references that are built into the solution.

+2
source

Source: https://habr.com/ru/post/1014701/


All Articles