A referenced assembly was compiled using a newer version of Microsoft.Windows.SDK.NET.dll - .net-5

I try-converted a windows form app to .NET 5 and I was able to build and run it last week. Now, it has an error building.
NETSDK1148 A referenced assembly was compiled using a newer version of Microsoft.Windows.SDK.NET.dll. Please update to a newer .NET SDK in order to reference this assembly. APP C:\Program Files\dotnet\sdk\5.0.201\Sdks\Microsoft.NET.Sdk\targets\Microsoft.NET.Windows.targets
Target framework for the csproj is <TargetFramework>net5.0-windows10.0.19041.0</TargetFramework>
I'm unsure what to change/update. Error is a little vague.

Removing Microsoft.Bcl.Build from the project fixed this issue. See https://github.com/dotnet/sdk/issues/16360

Related

regasm on a .net framework library now wants netstandard 2.1.0.0

I have a .net framework 4.8 library I have been working on for months in VS19. The project is configured to "Register for COM interop" (which runs regasm.exe on the dll).
Recently (in last few days) I installed VS22 and have been playing around with some .net core projects in here.
I have come back to my original library in VS19 which when compiling now reports (during the regasm call):
Cannot register assembly "X:\<removed>\my-lib.dll". Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.
I get the same result from manually trying to register the dll or trying to load and compile the project in VS22. I have installed all VS19 updates and rebooted the computer, no change.
It is my understanding that netstandard 2.1 has nothing to do with framework and netstandard is not specifically mentioned anywhere in my code or config. The gacutil /l output shows netstandard 2.0.0.0 is installed but nothing else.
It would seem the installation of VS22 may have shifted something in my environment and I'm not sure how to correct it?

Xamarin solution only builds with MSBuildPlatform.x86

I have the following question:
I'm using CakeBuild to build my Xamarin.Forms solution on a Windows computer (Windows 10).
Everything builds fine when I'm using the following command:
MSBuild("MyXamarinApp.sln", configurator =>
configurator.SetConfiguration("Debug")
.SetMSBuildPlatform(MSBuildPlatform.x86));
But if I remove "SetMSBuildPlatform(MSBuildPlatform.x86)" it uses internally "MSBuildPlatform.x64" and then I get the following error:
(_GetReferenceAssemblyPaths target) ->
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(566,2): error MSB3644: The reference assemblies for framework "MonoAndroid,Version=v1.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
Can someone explain this behaviour? Can I only use the x86 version of MSBuild to build Xamarin projects?
You need to set that platform in you Android application target. (AndroidProject -> Options).
x86 that desktop architecture. You can use it to build and test on simulator, but for a real device you will need to select at least one mobile architecture (any architecture that's not x86 or x86_64)

Windows RT 8.1 Sharpdevelop Issue (MSB3644) (MSB3248)

I've signed the Windows RT Desktop version of Sharpdevelop, but I continuously get this error
Build started.
Warning MSB3644: The reference assemblies for framework ".NETFramework,Version=v4.0" were not found. To resolve this, install the SDK or Targeting Pack for this framework version or retarget your application to a version of the framework for which you have the SDK or Targeting Pack installed. Note that assemblies will be resolved from the Global Assembly Cache (GAC) and will be used in place of reference assemblies. Therefore your assembly may not be correctly targeted for the framework you intend.
Error MSB3248: Parameter "SearchPaths" has invalid value "{CandidateAssemblyFiles}%3b
%3b
{HintPathFromItem}%3b
{TargetFrameworkDirectory}%3b
{Registry:Software\Microsoft\.NETFramework,v4.0,AssemblyFoldersEx}%3b
%3b
{GAC}%3b
{RawFileName}%3b
bin\Release\System.winmd". Illegal characters in path.
Build failed. (00:00:01.5781253)
All I need to do is get the exe compiled. I can sign it separately.

could not load file or assembly 'system.core version=2.0.5.0

I was trying to use ReactiveUI in a WPF application that makes use of Prism. I installed the packages with NuGet, but simply adding the references led to the exception specified in the title during the initialization of the ModuleCatalog.
Edit:
As Pierre Arnaud pointed out, the problem is Microsoft.Bcl.Async not being able to resolve System.Core version 2.0.5.0.
We moved to Visual Studio 2012 since i first posted this question. The same problem persists and i can't even install the fix suggested by Pierre since i have installed .Net 4.5 now. The project is still targeting .Net 4.0.
Please install KB2468871, which solves the issue related to Microsoft.Bcl.Async not being able to resolve System.Core version 2.0.5.0.
See also Issue 8 in the async targeting pack knowledge base.
Here are the direct download links for the fixes, for the x86 and x64 environments:
http://download.microsoft.com/download/2/B/F/2BF4D7D1-E781-4EE0-9E4F-FDD44A2F8934/NDP40-KB2468871-v2-x86.exe
http://download.microsoft.com/download/2/B/F/2BF4D7D1-E781-4EE0-9E4F-FDD44A2F8934/NDP40-KB2468871-v2-x64.exe
This isn't happening for me. Is it possible that NuGet has added the SL5 DLLs as a reference to your project?

system.diagnostics.contracts.contract exists in both v4.0 v3.5

I just upgraded to visual studio 2010 and installed the code contracts msi. When I try to use it I get a compiler error that the system.diagnostics.contracts.contract dll exists in both the v3.5 and v4 framework. Anyone know what I should do to resolve this? Thanks.
If you're upgrading a .NET 3.5 project that uses contracts to .NET 4.0, make sure you remove your reference to the Microsoft.Contracts assembly.
The Microsoft.Contracts assembly provides code contracts for use in .NET 2.0 or 3.5 projects, but is provided by default with .NET 4.0 in mscorlib, so you don't need it. They both share the System.Diagnostics.Contracts namespace, so by having references to both at the same time, the compiler isn't able to figure out which one you're trying to use.
I solved it by first installing it, thou that did not actually solve it.
Then removed the references and then I changed the project versions to 4.5 and after that, it worked.

Resources