xamarin / Xamarin.Forms

Xamarin.Forms is no longer supported. Migrate your apps to .NET MAUI.
https://aka.ms/xamarin-upgrade
Other
5.64k stars 1.88k forks source link

An System.TypeLoadException was encountered during unit testing due to the visual property when set in the style of a Label control. #15688

Open VijayakumarViswanathan opened 1 year ago

VijayakumarViswanathan commented 1 year ago

Description

An exception was encountered during unit testing due to the visual property when set in the style of a Label control. I found on a project that unit tests would run on windows but on mac they fail. The following exception would be thrown:

System.TypeLoadException : Could not load type 'System.Windows.Freezable' from assembly 'WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

This would happen during InitializeComponent() of the app class when creating a unit test instance of the Xamarin.Forms.Application class used for the forms app. It also happens when setting the Visual property in the xaml of a ContentPage.

Steps to Reproduce

Windows (Working)

  1. Pull the sample code on windows
  2. Open project in visual studio
  3. Build the solution
  4. Run unit tests
  5. Tests pass

macOS (Failing)

  1. Pull the sample code on macOS
  2. Open project in visual studio for mac
  3. Build the solution
  4. Run unit tests
  5. Tests fail
  6. Comment out stylings in App.Xaml
  7. Return tests
  8. Tests pass

Basic Information

Environment

Visual Studio Community 2022 for Mac Preview Version 17.5 Preview (17.5 build 437) Installation UUID: fd0bf3d1-adbf-42ea-bdcc-f1fe8b315aa5

Runtime .NET 7.0.0 (64-bit) Architecture: X64

Roslyn (Language Service) 4.4.0-3.22461.4+8ab250290a4010c11a21521f78dbc87dbb7aac81

NuGet Version: 6.3.1.1

.NET SDK (x64) SDK: /usr/local/share/dotnet/sdk/7.0.100/Sdks SDK Versions: 7.0.100 6.0.403 MSBuild SDKs: /Applications/Visual Studio (Preview).app/Contents/MonoBundle/MSBuild/Current/bin/Sdks

.NET Runtime (x64) Runtime: /usr/local/share/dotnet/dotnet Runtime Versions: 7.0.0 6.0.11

Xamarin.Profiler Version: 1.8.0.19 Location: /Applications/Xamarin Profiler.app/Contents/MacOS/Xamarin Profiler

Updater Version: 11

Xamarin Designer Version: 17.5.1.13 Hash: 14bdde937f Branch: remotes/origin/d17-5 Build date: 2022-11-02 21:36:45 UTC

Apple Developer Tools Xcode 14.2 (21534) Build 14C18

Xamarin.Mac Version: 8.12.0.2 (Visual Studio Community) Hash: 87f98a75e Branch: d17-3 Build date: 2022-07-25 20:18:54-0400

Xamarin.iOS Version: 16.0.0.72 (Visual Studio Community) Hash: 6756a1146 Branch: release/6.0.4xx-xcode14 Build date: 2022-09-21 08:51:06-0400

Xamarin.Android Version: 13.1.0.1 (Visual Studio Community) Commit: xamarin-android/d17-4/13ba222 Android SDK: /Users/syncfusion/Library/Developer/Xamarin/android-sdk-macosx Supported Android versions: 12.0 (API level 31) 13.0 (API level 33)

SDK Command-line Tools Version: 7.0 SDK Platform Tools Version: 33.0.2 SDK Build Tools Version: 32.0.0

Build Information: Mono: a96bde9 Java.Interop: https://github.com/xamarin/java.interop/commit/fcc33ce2 SQLite: https://github.com/xamarin/sqlite/commit/23e1ae7 Xamarin.Android Tools: https://github.com/xamarin/xamarin-android-tools/commit/0be567a

Microsoft Build of OpenJDK Java SDK: /Library/Java/JavaVirtualMachines/microsoft-11.jdk 11.0.16.1 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

Eclipse Temurin JDK Java SDK: /Library/Java/JavaVirtualMachines/temurin-8.jdk 1.8.0.302 Android Designer EPL code available here: https://github.com/xamarin/AndroidDesigner.EPL

Android SDK Manager Version: 17.5.0.8 Hash: 6f27afd Branch: remotes/origin/HEAD Build date: 2022-11-02 21:36:49 UTC

Android Device Manager Version: 0.0.0.1217 Hash: 6175224 Branch: main Build date: 2022-11-02 21:36:49 UTC

Build Information Release ID: 1705000437 Git revision: a5d0fb913c1ff781c80fe725a3e0511c34e26a08 Build date: 2022-11-02 21:34:21+00 Build branch: release-17.5 Build lane: release-17.5

Operating System Mac OS X 12.6.1 Darwin 21.6.0 Darwin Kernel Version 21.6.0 Thu Sep 29 20:12:57 PDT 2022 root:xnu-8020.240.7~1/RELEASE_X86_64 x86_64

GitHub - xamarin/AndroidDesigner.EPL

Contribute to xamarin/AndroidDesigner.EPL development by creating an account on GitHub.

Reproduction Link

(https://github.com/VijayakumarViswanathan/VisualPropertyIssue)

Workaround

no workaround was tried.

b12kab commented 1 year ago

I'm also getting this exact same error on running unit tests.