This is most probably related to dotnet/efcore#8922 . None of the workarounds there help. The major problem is that it's simply impossible to force the linker to preserve an entire assembly.
Steps to Reproduce
- Use a library, such as Microsoft.Extensions.Identity.Stores, which (indirectly) depends on System.Runtime.CompilerServices.Unsafe, in a Xamarin.Android project;
- Build the project in Release - ensure linking is not set to "None";
- Run it on a device.
Expected Behavior
The application runs.
Actual Behavior
The application does not load at all with:
Could not load assembly 'System.Runtime.CompilerServices.Unsafe' during startup registration.
Version Information
Microsoft Visual Studio Community 2017
Version 15.5.3
VisualStudio.15.Release/15.5.3+27130.2020
Microsoft .NET Framework
Version 4.7.02558
Installed Version: Community
Visual Basic 2017 00369-60000-00001-AA416
Microsoft Visual Basic 2017
Visual C# 2017 00369-60000-00001-AA416
Microsoft Visual C# 2017
Visual C++ 2017 00369-60000-00001-AA416
Microsoft Visual C++ 2017
Visual F# 4.1 00369-60000-00001-AA416
Microsoft Visual F# 4.1
Application Insights Tools for Visual Studio Package 8.10.01106.1
Application Insights Tools for Visual Studio
ASP.NET and Web Tools 2017 15.0.31127.0
ASP.NET and Web Tools 2017
ASP.NET Core Razor Language Services 1.0
Provides languages services for ASP.NET Core Razor.
ASP.NET Web Frameworks and Tools 2017 5.2.51007.0
For additional information, visit https://www.asp.net/
Azure App Service Tools v3.0.0 15.0.31106.0
Azure App Service Tools v3.0.0
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
EZ-GIT 1.7.2
GradleBindings.VisualStudio 1.0
Creates Xamarin Android Binding projects from a gradle file.
JavaScript Language Service 2.0
JavaScript Language Service
Merq 1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.
Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.51120.3
Microsoft Continuous Delivery Tools for Visual Studio 0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards
Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.
Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package
Mono Debugging for Visual Studio 4.8.4-pre (3fe64e3)
Support for debugging Mono processes with Visual Studio.
NpgsqlVSPackage Extension 1.0
NpgsqlVSPackage Visual Studio Extension Detailed Info
NuGet Package Manager 4.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
Qt Visual Studio Tools 2.1.2
The Qt Visual Studio Tools allow developers to use the standard development environment without having to worry about any Qt-related build steps or tools.
SQL Server Data Tools 15.1.61710.120
Microsoft SQL Server Data Tools
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
Xamarin 4.8.0.757 (7f9ec2a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 4.8.188 (c5813fa34)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin.Android SDK 8.1.3.0 (HEAD/ef47226b7)
Xamarin.Android Reference Assemblies and MSBuild support.
Xamarin.iOS and Xamarin.Mac SDK 11.6.1.2 (6857dfc)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.
This is most probably related to dotnet/efcore#8922 . None of the workarounds there help. The major problem is that it's simply impossible to force the linker to preserve an entire assembly.
Steps to Reproduce
Expected Behavior
The application runs.
Actual Behavior
The application does not load at all with:
Could not load assembly 'System.Runtime.CompilerServices.Unsafe' during startup registration.
Version Information
Microsoft Visual Studio Community 2017
Version 15.5.3
VisualStudio.15.Release/15.5.3+27130.2020
Microsoft .NET Framework
Version 4.7.02558
Installed Version: Community
Visual Basic 2017 00369-60000-00001-AA416
Microsoft Visual Basic 2017
Visual C# 2017 00369-60000-00001-AA416
Microsoft Visual C# 2017
Visual C++ 2017 00369-60000-00001-AA416
Microsoft Visual C++ 2017
Visual F# 4.1 00369-60000-00001-AA416
Microsoft Visual F# 4.1
Application Insights Tools for Visual Studio Package 8.10.01106.1
Application Insights Tools for Visual Studio
ASP.NET and Web Tools 2017 15.0.31127.0
ASP.NET and Web Tools 2017
ASP.NET Core Razor Language Services 1.0
Provides languages services for ASP.NET Core Razor.
ASP.NET Web Frameworks and Tools 2017 5.2.51007.0
For additional information, visit https://www.asp.net/
Azure App Service Tools v3.0.0 15.0.31106.0
Azure App Service Tools v3.0.0
Common Azure Tools 1.10
Provides common services for use by Azure Mobile Services and Microsoft Azure Tools.
EZ-GIT 1.7.2
GradleBindings.VisualStudio 1.0
Creates Xamarin Android Binding projects from a gradle file.
JavaScript Language Service 2.0
JavaScript Language Service
Merq 1.1.17-rc (cba4571)
Command Bus, Event Stream and Async Manager for Visual Studio extensions.
Microsoft Azure Tools 2.9
Microsoft Azure Tools for Microsoft Visual Studio 2017 - v2.9.51120.3
Microsoft Continuous Delivery Tools for Visual Studio 0.3
Simplifying the configuration of continuous build integration and continuous build delivery from within the Visual Studio IDE.
Microsoft JVM Debugger 1.0
Provides support for connecting the Visual Studio debugger to JDWP compatible Java Virtual Machines
Microsoft MI-Based Debugger 1.0
Provides support for connecting Visual Studio to MI compatible debuggers
Microsoft Visual C++ Wizards 1.0
Microsoft Visual C++ Wizards
Microsoft Visual Studio Tools for Containers 1.1
Develop, run, validate your ASP.NET Core applications in the target environment. F5 your application directly into a container with debugging, or CTRL + F5 to edit & refresh your app without having to rebuild the container.
Microsoft Visual Studio VC Package 1.0
Microsoft Visual Studio VC Package
Mono Debugging for Visual Studio 4.8.4-pre (3fe64e3)
Support for debugging Mono processes with Visual Studio.
NpgsqlVSPackage Extension 1.0
NpgsqlVSPackage Visual Studio Extension Detailed Info
NuGet Package Manager 4.5.0
NuGet Package Manager in Visual Studio. For more information about NuGet, visit http://docs.nuget.org/.
Qt Visual Studio Tools 2.1.2
The Qt Visual Studio Tools allow developers to use the standard development environment without having to worry about any Qt-related build steps or tools.
SQL Server Data Tools 15.1.61710.120
Microsoft SQL Server Data Tools
Visual Studio Code Debug Adapter Host Package 1.0
Interop layer for hosting Visual Studio Code debug adapters in Visual Studio
Visual Studio Tools for CMake 1.0
Visual Studio Tools for CMake
VisualStudio.Mac 1.0
Mac Extension for Visual Studio
Xamarin 4.8.0.757 (7f9ec2a)
Visual Studio extension to enable development for Xamarin.iOS and Xamarin.Android.
Xamarin Designer 4.8.188 (c5813fa34)
Visual Studio extension to enable Xamarin Designer tools in Visual Studio.
Xamarin.Android SDK 8.1.3.0 (HEAD/ef47226b7)
Xamarin.Android Reference Assemblies and MSBuild support.
Xamarin.iOS and Xamarin.Mac SDK 11.6.1.2 (6857dfc)
Xamarin.iOS and Xamarin.Mac Reference Assemblies and MSBuild support.