dotnet / sdk

Core functionality needed to create .NET Core projects, that is shared between Visual Studio and CLI
https://dot.net/core
MIT License
2.75k stars 1.07k forks source link

Migrating C++/CLI project throws compiler warning C4945 #31123

Open NavrimCPP opened 1 year ago

NavrimCPP commented 1 year ago

The Solution contains a combination of C#, C++/CLI and C++ projects. I followed the guide for migrating C++/CLI projects.(https://learn.microsoft.com/en-us/dotnet/core/porting/cpp-cli.)

I need to specify the FrameworkReference for WPF ().

When compiling, I get many C4945 warnings. Because we have TreatWarningsAsErrors enabled, the project can't be compiled. Disabling TreatWarningsAsErrors or disabling the C4945 warnings is not a permanent solution for us.

Example C4945 warning: warning C4945: 'BulletChrome': cannot import symbol from 'C:\Program Files\dotnet\packs\Microsoft.WindowsDesktop.App.Ref\6.0.14\ref\net6.0\PresentationFramework.Aero2.dll': as 'Microsoft::Windows::Themes::BulletChrome' has already been imported from another assembly 'PresentationFramework.Aero'

The warnings can be easily reproduced

What can I do to stop these warnings from occurring?

Previously, I was able to reference explicitly, e.g.

<ItemGroup>
    <Reference Include="PresentationCore" />
    <Reference Include="System" />
    <Reference Include="System.Core" />
    <Reference Include="System.Xaml" />
    <Reference Include="WindowsBase" />
</ItemGroup>
marcpopMSFT commented 1 year ago

@jaredpar any pointers on those compiler warnings in a c++/CLI app?

jaredpar commented 1 year ago

@dangrif have any pointers here?

NavrimCPP commented 1 year ago

Hi, is there any new information about the problem?

Wittenborn commented 6 months ago

We encountered the same problem. Is there any news regarding the problem or advice on how to work around the error?

I have created a minimal project to reproduce the warning and it is sufficient to simply reference the framework to trigger the warning: https://github.com/Wittenborn/cpp-cli-warning-C4945/

as32 commented 3 months ago

Same problem here. Any news?

sensslen commented 3 months ago

Same problem over here. However I'm targeting .net 8 instead of .net 6. Everything else stays the same.

santiagoIT commented 2 months ago

Same problem here.

rfvan commented 1 month ago

Same problem here too.

gazette2 commented 1 week ago

exact same problem occurs in C++/CLI for .NET 9 as well.