I am in the process of upgrading a C# plugin library from .net framework 4.8 to .net 8.0 targeting windows. However for compatibility I also want to continue compiling for older versions using framework 4.8 I have done this with another project successfully, using the in-place upgrade built into Visual Studio and hand editing the csproj as necessary. On the second project that I am upgrading I received following error when compiling.
MC1000 Unknown build error, 'Could not find type 'System.Resources.SatelliteContractVersionAttribute' in assembly 'C:Program Files (x86)Reference AssembliesMicrosoftFramework.NETFrameworkv4.8FacadesSystem.Runtime.dll'.' *ProjectName*
C:Program Filesdotnetsdk8.0.302SdksMicrosoft.NET.Sdk.WindowsDesktoptargetsMicrosoft.WinFX.targets
In my csproj I have tried multiple things. The only thing that removes the error is setting <UseWPF>
to false
. However that breaks the build in other ways as I have several WPF UI elements that need to be compiled.
When I compile against .net 8.0, the build succeeds. It is only against framework 4.8 that it fails.
Below is a sanitized version of the csproj.
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<SccProjectName>SAK</SccProjectName>
<SccLocalPath>SAK</SccLocalPath>
<SccAuxPath>SAK</SccAuxPath>
<SccProvider>SAK</SccProvider>
<Configurations>Release;ReleaseR24;ReleaseR23;ReleaseR22;ReleaseR21;ReleaseR20;Debug;DebugR24;DebugR23;DebugR22;DebugR21;DebugR20</Configurations>
<PlatformTarget>AnyCPU</PlatformTarget>
<OutputType>Library</OutputType>
<RootNamespace>Internal</RootNamespace>
<NoWarn>1701;1702;SYSLIB0011;CA1416;MSB3270;CA2213;CA1060;msb3277</NoWarn>
<ErrorReport>prompt</ErrorReport>
<Prefer32Bit>false</Prefer32Bit>
<CodeAnalysisRuleSet>MinimumRecommendedRules.ruleset</CodeAnalysisRuleSet>
<UseWindowsForms>true</UseWindowsForms>
<UseWPF>true</UseWPF>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<Deterministic>false</Deterministic>
</PropertyGroup>
<!-- Generic imports Debug/Release> -->
<PropertyGroup Condition="$(Configuration.Contains('Release'))">
<DebugType>pdbonly</DebugType>
<Optimize>true</Optimize>
<WarningLevel>4</WarningLevel>
</PropertyGroup>
<PropertyGroup Condition="$(Configuration.Contains('Debug'))">
<DebugSymbols>true</DebugSymbols>
<DebugType>full</DebugType>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|AnyCPU'">
<DefineConstants>TRACE</DefineConstants>
<TargetFramework>net8.0-windows</TargetFramework>
<OutputPath>binRelease</OutputPath>
<AssemblyName>Internal</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
<TargetFramework>net8.0-windows</TargetFramework>
<OutputPath>binDebug</OutputPath>
<AssemblyName>Internal</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseR24|AnyCPU'">
<DefineConstants>TRACE</DefineConstants>
<TargetFramework>net48</TargetFramework>
<OutputPath>binReleaseR24</OutputPath>
<AssemblyName>Internal</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugR24|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
<TargetFramework>net48</TargetFramework>
<OutputPath>binDebugR24</OutputPath>
<AssemblyName>Internal</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseR23|AnyCPU'">
<DefineConstants>TRACE</DefineConstants>
<TargetFramework>net48</TargetFramework>
<OutputPath>binRelease$23</OutputPath>
<AssemblyName>Internal</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugR23|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
<TargetFramework>net48</TargetFramework>
<OutputPath>binDebugR23</OutputPath>
<AssemblyName>Internal</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseR22|AnyCPU'">
<DefineConstants>TRACE</DefineConstants>
<TargetFramework>net48</TargetFramework>
<OutputPath>binReleaseR22</OutputPath>
<AssemblyName>Internal</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugR22|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
<TargetFramework>net48</TargetFramework>
<OutputPath>binDebugR22</OutputPath>
<AssemblyName>Internal</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseR21|AnyCPU'">
<DefineConstants>TRACE</DefineConstants>
<TargetFramework>net48</TargetFramework>
<OutputPath>binReleaseR21</OutputPath>
<AssemblyName>Internal</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugR21|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
<TargetFramework>net48</TargetFramework>
<OutputPath>binDebugR21</OutputPath>
<AssemblyName>Internal</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'ReleaseR20|AnyCPU'">
<DefineConstants>TRACE</DefineConstants>
<TargetFramework>net48</TargetFramework>
<OutputPath>binReleaseR20</OutputPath>
<AssemblyName>Internal</AssemblyName>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'DebugR20|AnyCPU'">
<DefineConstants>TRACE;DEBUG</DefineConstants>
<TargetFramework>net48</TargetFramework>
<OutputPath>binDebugR20</OutputPath>
<AssemblyName>Internal</AssemblyName>
</PropertyGroup>
<ItemGroup Condition="'$(Configuration)' == 'Release' Or '$(Configuration)' == 'Debug'">
<Reference Include="LibsInternal25***.dll" />
</ItemGroup>
<ItemGroup Condition="$(Configuration.Contains('R24'))">
<Reference Include="LibsInterna24***.dll" />
</ItemGroup>
<ItemGroup Condition="$(Configuration.Contains('R23'))">
<Reference Include="LibsInternal23***.dll" />
</ItemGroup>
<ItemGroup Condition="$(Configuration.Contains('R22'))">
<Reference Include="LibsInternal22***.dll" />
</ItemGroup>
<ItemGroup Condition="$(Configuration.Contains('R21'))">
<Reference Include="LibsInternal21***.dll" />
</ItemGroup>
<ItemGroup Condition="$(Configuration.Contains('R20'))">
<Reference Include="LibsInternal20***.dll" />
</ItemGroup>
<!-- .NET 8 (Core) -->
<ItemGroup Condition="'$(TargetFramework)' == 'net8.0-windows'">
<Reference Include="Libsnetcoredevexpress*.dll" />
<PackageReference Include="Ribbon.Fork.NET" Version="6.0.0" />
<PackageReference Include="DocumentFormat.OpenXml" Version="3.0.2" />
<PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.10.0" />
<PackageReference Include="SpreadsheetLight.Core" Version="3.4.0" />
<PackageReference Include="unvell.ReoGrid8.dll" Version="8.1.0" />
<PackageReference Include="Microsoft.Windows.Compatibility" Version="8.0.6" />
<PackageReference Include="System.ServiceModel.Primitives" Version="8.0.0" />
<PackageReference Include="System.ServiceModel.Http" Version="8.0.0" />
<PackageReference Include="System.ServiceModel.Duplex" Version="6.0.0" />
<PackageReference Include="System.ServiceModel.NetTcp" Version="8.0.0" />
<PackageReference Include="System.ServiceModel.Security" Version="6.0.0" />
<PackageReference Include="System.ServiceModel.Federation" Version="8.0.0" />
<PackageReference Include="System.Windows.Forms.DataVisualization" Version="1.0.0-prerelease.20110.1" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="System.Configuration.ConfigurationManager" Version="8.0.0" />
<PackageReference Include="System.Drawing.Common" Version="8.0.6" />
<PackageReference Include="System.IO.Packaging" Version="8.0.0" />
<PackageReference Include="System.Text.Json" Version="8.0.3" />
</ItemGroup>
<!-- .NET Framework 4.8 -->
<ItemGroup Condition="'$(TargetFramework)' == 'net48'">
<Reference Include="Libsnetframeworkdevexpress*.dll" />
<PackageReference Include="SpreadsheetLight" Version="3.4.9" />
<PackageReference Include="unvell.ReoGrid.dll" Version="3.0.0" />
</ItemGroup>
<!-- Common -->
<ItemGroup>
<Reference Include="LibsPrivate.Internal.dll" />
<Reference Include="LibsPrivate.Internal.dll" />
<Reference Include="LibsPrivate.Internal.dll" />
<Reference Include="LibsPrivate.Internal.dll" />
<PackageReference Include="SpreadsheetGear" Version="9.2.44" />
<PackageReference Include="TaskScheduler" Version="2.11.0" />
<PackageReference Include="Microsoft.AspNetCore.SystemWebAdapters" Version="1.3.0" />
</ItemGroup>
</Project>
I have tried a number of things.
Clean and Build. Updated Visual Studio. Included a package reference to System.Runtime from Nuget. Set <ImportFrameworkWinFXTargets>
to false
and true
just to make sure. I’ve looked at the output in diagnostic mode (not sure it told me a lot more about what is happening). I’ve re-installed the dev SDK and the runtime for .net framework 4.8. Restarted my computer. Asked a co-worker.
Using IlSpy I’ve looked at the Nuget version of System.Runtime and the version referenced in the error message and they don’t have the SatelliteContractVersion attribute set.
Not sure how best to proceed from here.
chunkles is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.