Reputation: 338
I'm getting lots of errors like this in my VS2022 C++ library project that references a C# library that uses .NET8.
1>C:\Users\user\.nuget\packages\system.security.permissions\4.5.0\ref\netstandard2.0\System.Security.Permissions.dll(1,1): warning C4945: 'PermissionSet': cannot import symbol from 'C:\Users\user\.nuget\packages\system.security.permissions\4.5.0\ref\netstandard2.0\System.Security.Permissions.dll': as 'System::Security::PermissionSet' has already been imported from another assembly 'C:\Program Files\dotnet\packs\Microsoft.NETCore.App.Ref\8.0.12\ref\net8.0\System.Runtime.dll'
1>(compiling source file 'x64/Debug/vs2022/.NETCoreApp,Version=v8.0.AssemblyAttributes.cpp')
1> C:\Users\user\.nuget\packages\system.security.permissions\4.5.0\ref\netstandard2.0\System.Security.Permissions.dll(1,1):
1> first seen type is used; re-order imported assemblies to use the current type
1> C:\Users\user\.nuget\packages\system.security.permissions\4.5.0\ref\netstandard2.0\System.Security.Permissions.dll(1,1):
1> This diagnostic occurred while importing type 'System.Security.PermissionSet' from assembly 'System.Security.Permissions, Version=4.0.1.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'.
I understand the basic reason of what is happening and what the meaning of the error, but I don't know how to fix it. Nowhere in the .vcxproj file is System.Security referenced... In fact, the only reference listed in the .vcxproj file is my C# library, yet other (apparently dependent) references are listed in the solution tree:
What should I change to get rid of the warnings? My intention is to only use .NET8 (not framework 4.5 or whatever is apparently being referenced) Thanks for any help you can provide. -E.
relevant portions of the .vcxproj file:
...
<PropertyGroup Label="Globals">
<VCProjectVersion>17.0</VCProjectVersion>
<EnableManagedPackageReferenceSupport>true</EnableManagedPackageReferenceSupport>
<ProjectGuid>{some-guid}</ProjectGuid>
<Keyword>NetCoreCProj</Keyword>
<RootNamespace>MyLibName</RootNamespace>
<WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>
<TargetFramework>net8.0</TargetFramework>
<WindowsTargetPlatformMinVersion>10.0.22621.0</WindowsTargetPlatformMinVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CLRSupport>NetCore</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>DynamicLibrary</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v143</PlatformToolset>
<CLRSupport>NetCore</CLRSupport>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
...
<ItemGroup>
<ProjectReference Include="..\..\company\myCsharpLib.csproj">
<Project>{some-guid}</Project>
<Private>true</Private>
</ProjectReference>
</ItemGroup>
...
Upvotes: -2
Views: 41