0

My solution structure looks like this:enter image description here

The compiler complains that it finds duplicate types (of every public interface/class) in WCL1.winmd b/c that winmd file already exists in WCL4's bin directory.

One problem is that I know absolutely nothing about C++ and the link offered in the Answer to this question provides a C++ workaround that doesn't help (it's literally like reading a different-but-related language -- i.e. reading German when I only know English).

I also found this which provides another workaround but doesn't tell you where to put it. I added the specified ItemGroupDescription element into every .csproj file as well as the application's PropertySheet.props file to no avail.

I have also done the following:

  • Moved the code from WCL2 into WCL3 and removed WCL2 from the solution.
  • Had the application reference WCL1, WCL3 and WCL4.

Anyone else got any ideas? It would be greatly appreciated....

UPDATE:

Here's a link to a small solution that reproduces the compile errors. It seems that it comes from the Microsoft.Windows.CppWinRT NuGet package referenced by the C++ Application. That package auto-generates C++ header files from the .winmd files generated by the component projects referenced by the Application.

jasonxz
  • 139
  • 1
  • 9
  • Do you have a small reproducing set of files we could look at? – Simon Mourier Nov 11 '21 at 06:09
  • @SimonMourier - I'll will take some time this morning to create that. Thanks. – jasonxz Nov 11 '21 at 14:56
  • @SimonMourier - I'll get something created but I thought I'd add that everything compiles fine until I add a reference to the Microsoft.Windows.CppWinRT NuGet package in the Application. This package generates the C++ header files from the Windows Runtime Component libraries that the Application references. – jasonxz Nov 11 '21 at 20:39
  • Please tell more detail your os version and app's target and min version. – Nico Zhu Nov 12 '21 at 03:15
  • @NicoZhu-MSFT - OS version is 10.0.22000.0. Minimum Target for the Applicatioon is 10.0.17134.0. Minimum Target for each of the component projects is Creators Update (Build 15063) as is recommended here (despite that version being 2 years out of support): https://learn.microsoft.com/en-us/windows/uwp/cpp-and-winrt-apis/use-csharp-component-from-cpp-winrt – jasonxz Nov 12 '21 at 14:53
  • @NicoZhu-MSFT - I run into the same problem on another device running Windows 10.0.19041.0. – jasonxz Nov 12 '21 at 14:55

1 Answers1

1

Well....it's not perfect but this is how I got around the problem...Add the following line to each ProjectReference in each Component .csproj file: enter image description here

I'm not sure what the intention of this particular Xml element was, but by setting Private=false, the compiler doesn't copy the InterfaceDefinitionComponent.winmd file into the other Components' bin directory which prevents the C++ compiler from seeing duplicate .winmd files and blowing up because it's trying to generate multiple identical C++ header files for the same Type.

jasonxz
  • 139
  • 1
  • 9