Migrating C++/CLI project throws compiler warning C4945
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 (<FrameworkReferenceInclude="Microsoft.WindowsDesktop.App.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
-
Create a new C++/CLI(.NET) Project
-
Add the following to the .vcxproj file
<ItemGroup>
<FrameworkReference Include="Microsoft.WindowsDesktop.App.Wpf" />
</ItemGroup>
- And Compile
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>
@jaredpar any pointers on those compiler warnings in a c++/CLI app?
@dangrif have any pointers here?
Hi, is there any new information about the problem?
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/
Same problem here. Any news?
Same problem over here. However I'm targeting .net 8 instead of .net 6. Everything else stays the same.
Same problem here.
Same problem here too.
exact same problem occurs in C++/CLI for .NET 9 as well.
same problem
This suggested solution seems to help: