How to run tests on a net6.0-windows project - c#

I have two projects in my solution:
A Windows UI automation project migrated from .NET Framework 4.x to net6.0-windows. Uses System.Windows.Automation only available on net6.0-windows
A Tests project with these Nuget packages installed: Microsoft.NET.Test.Sdk 17.3.0; MSTest.TestAdapter 2.2.10; MSTest.TestFramework 2.2.10. This project references the project above. The target framework is net6.0-windows.
I can't continue since I encounter the following errors:
Microsoft.VisualStudio.TestPlatform.ObjectModel.TestPlatformException: Testhost process exited with error: Unhandled exception. System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.TestPlatform.CoreUtilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
File name: 'Microsoft.TestPlatform.CoreUtilities, Version=15.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
Installed Microsoft.TestPlatform 17.3.0 but assemblies aren't copied to the bin folder.
The tests work on net6 target framework, but the UI Automation project can't use that target. Thank you in advance!

Related

Roslyn Microsoft.CodeAnalysis.Scripting .NET 4.7.1 Problems

I'm using the Roslyn library to execute dynamic c# scripts:
https://github.com/dotnet/roslyn/
For some reason, it only works on .NET framework 4.6. Upgrading to 4.7.1 throws the following errors:
FileNotFoundException: Could not load file or assembly
'System.Runtime, Version=4.0.20.0, Culture=neutral,
PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The
system cannot find the file specified.
I have updated and reinstalled the Nuget package:
Install-Package Microsoft.CodeAnalysis.CSharp.Scripting
Any ideas what could be wrong?
UPDATE
I read that creating a .Net Standard project and implementing Roslyn there while referencing the project solves the issues. I did not find this to work at all

Could not load file or assembly system.memory version 4.1.0.0

I have asp.net core project which runs on Asp.Net Core V2.1.0 which has signal r integrated. I have downloaded a sample project from aspnetbrolerplate. When I try to run the application it gives me following error.
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Memory, Version=4.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.'
Can anyone please suggest me possible solution for this issue.
I found installing the System.Memory NuGet package resolves the issue.
It is confusing that earliest version is 4.5.1, but if you install it, you will find the assembly versioned a System.Memory, Version=4.1.0.0.
For my .NET Framework project I installed NuGet version 4.5.4 which contains System.Memory, Version=4.0.1.1 assembly.
I found that this is a known issue for UWP. Update to Asp.Net Core 2.1.1 and Microsoft.AspNetCore.SignalR.Client NuGet Package to at least 1.0.1, which has a fix for this UWP issue.
Maybe it also fixes your issue.

C# - Xamarin.Froms.Build.Task.GetTaskAbi - error

I have been getting the below error everytime I try to build a Xamarin Forms App.
Does anyone have a solution to this error.
I have uninstalled and reinstalled VS2017 two times.
I have deleted all the folder to do a clean install.
Severity Code Description Project File Line Suppression State
Error The "Xamarin.Forms.Build.Tasks.GetTasksAbi" task could not be loaded from the assembly C:\Users\Regardt.nuget\packages\xamarin.forms\3.0.0.446417\build\netstandard2.0\Xamarin.Forms.Build.Tasks.dll. Could not load file or assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. Confirm that the declaration is correct, that the assembly and all its dependencies are available, and that the task contains a public class that implements Microsoft.Build.Framework.ITask. App2.Android
Download and install .NET Framework 4.7.1 or 4.7.2 then seemed to resolve the issue.
Microsoft .NET Framework 4.7.1 (Offline Installer):
https://www.microsoft.com/en-us/download/details.aspx?id=56116
Microsoft .NET Framework 4.7.2 offline installer for Windows:
https://support.microsoft.com/en-us/help/4054530/microsoft-net-framework-4-7-2-offline-installer-for-windows

Xamarin build fails to load assembly I'm not even referencing

I have a Xamarin.Android project loaded in VS 2017. When I build the project I get error: Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.IdentityModel.Tokens.Jwt, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. Perhaps it doesn't exist in the Mono for Android profile?
System.IdentityModel.Tokens.Jwt is not referenced by this project, i.e. it's not under References, nor packages.config. It's not listed in Nuget Package Manager's list of installed packages.
How can I figure out why the build is trying to load that assembly?
Why is the build even trying to load assemblies, shouldn't that be the responsability of the application, not of the build? (Not saying it does, but an app may "know" how to load its assemblies using a custom ResolveEventHandler, the build can't "know" that.)

System.Data.Linq in netstandard20

I have a netstandard20 project that references a .Net 4.6 Project, all compiles and runs except where I call any functionality in the .Net 4.6 project, I get the following error.
FileNotFoundException: Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. The system cannot find the file specified.
In VS 2017, in the project explorer under Dependancies / SDK / Microsoft.NETCore.App I can see System.Data.dll and System.Data.Common.dll but no reference to System.Data.Linq.dll, I am assuming this is my problem and it has not been pulled in.
How do I get my project to include System.Data.Linq.dll?
If I include C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.6\System.Data.Linq.dll I get the following error
BadImageFormatException: Could not load file or assembly 'System.Data.Linq, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
I was able to solve my need to use System.Data.Linq in a .NET Standard 2.0 library by using the Mindbox.Data.Linq NuGet package.
After installing it you should be able to use the System.Data.Linq namespace just like you could when writing for .NET Framework!
System.Data.Linq is not part of .NET Standard 2.0 and .NET Core 2.0 and therefore cannot be used on that platform.
Even tough you have been able add a reference to a .NET 4.6 project via the compatibility shims, it fails at runtime because of a feature that is not available on the target runtime

Categories