I have installed VS 2022 and tried to migrate my project from VS 2019. My VS 2019 project worked ok with the original MTAdmob, however, when building the new project I receive the following error message:
System.IO.FileNotFoundException: Could not load assembly 'Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken='.
If I remove the MauiMTAdmob nuget package and all code references from my VS 2022 project then the rest of my app builds and runs without an issue.
Steps to reproduce:
Install VS 2022 with the .NET Multi-platform App UI Developement and .NET Desktop development workloads
Using command line dotnet workload install maui and maui-android
Create a new VS 2022 project with the same project name as original
Go into old project and copy classes from VS 2019 into VS 2022 project
In new project, check that code works without additional MTAdmob package, clean and build app
In new project, install MauiMTAdmob NuGet package
Versions:
Microsoft Visual Studio Community 2022 (64-bit)
Version 17.3.3
dotnet version 6.0.400
Logs
There is a build error in release mode that mentions the package:
Precompiling failed for C:\Users\hidden\obj\Release\net6.0-android\android-x86\linked\Plugin.MauiMtAdmob.dll.
Failed to load method 0x6000095 from 'C:\Users\hidden\obj\Release\net6.0-android\android-x86\linked\Plugin.MauiMtAdmob.dll' due to Could not load file or assembly 'Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies..
Mono Ahead of Time compiler - compiling assembly C:\Users\hidden\obj\Release\net6.0-android\android-x86\linked\Plugin.MauiMtAdmob.dll
AOTID 030115F2-9CB1-3D92-0052-0036762132E1
Using profile data file 'C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\targets\dotnet.aotprofile'
Run with MONO_LOG_LEVEL=debug for more information.
AOT of image obj\Release\net6.0-android\android-x86\linked\Plugin.MauiMtAdmob.dll failed. hidden C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\targets\Microsoft.Android.Sdk.Aot.targets 91
Debug build log output:
1>Build FAILED.
1>
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.Common.targets(1388,3): error XALNS7028: System.IO.FileNotFoundException: Could not load assembly 'Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken='. Perhaps it doesn't exist in the Mono for Android profile?
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.Common.targets(1388,3): error XALNS7028: File name: 'Microsoft.Maui.dll'
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.Common.targets(1388,3): error XALNS7028: at Java.Interop.Tools.Cecil.DirectoryAssemblyResolver.Resolve(AssemblyNameReference reference, ReaderParameters parameters) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/DirectoryAssemblyResolver.cs:line 245
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.Common.targets(1388,3): error XALNS7028: at Mono.Cecil.MetadataResolver.Resolve(TypeReference type) in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil/MetadataResolver.cs:line 111
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.Common.targets(1388,3): error XALNS7028: at Mono.Cecil.TypeReference.Resolve() in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/external/cecil/Mono.Cecil/TypeReference.cs:line 278
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.Common.targets(1388,3): error XALNS7028: at Java.Interop.Tools.Cecil.TypeDefinitionCache.Resolve(TypeReference typeReference) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionCache.cs:line 20
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.Common.targets(1388,3): error XALNS7028: at Java.Interop.Tools.Cecil.TypeDefinitionRocks.<GetTypeAndBaseTypes>d__5.MoveNext() in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionRocks.cs:line 40
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.Common.targets(1388,3): error XALNS7028: at Java.Interop.Tools.Cecil.TypeDefinitionRocks.IsSubclassOf(TypeDefinition type, String typeName, IMetadataResolver resolver) in /Users/runner/work/1/s/xamarin-android/external/Java.Interop/src/Java.Interop.Tools.Cecil/Java.Interop.Tools.Cecil/TypeDefinitionRocks.cs:line 94
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.Common.targets(1388,3): error XALNS7028: at MonoDroid.Tuner.FixAbstractMethodsStep.FixAbstractMethods(AssemblyDefinition assembly)
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.Common.targets(1388,3): error XALNS7028: at Xamarin.Android.Tasks.LinkAssembliesNoShrink.RunTask()
1>C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\tools\Xamarin.Android.Common.targets(1388,3): error XALNS7028: at Microsoft.Android.Build.Tasks.AndroidTask.Execute() in /Users/runner/work/1/s/xamarin-android/external/xamarin-android-tools/src/Microsoft.Android.Build.BaseTasks/AndroidTask.cs
```:line 17
I have installed VS 2022 and tried to migrate my project from VS 2019. My VS 2019 project worked ok with the original MTAdmob, however, when building the new project I receive the following error message:
System.IO.FileNotFoundException: Could not load assembly 'Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken='.
If I remove the MauiMTAdmob nuget package and all code references from my VS 2022 project then the rest of my app builds and runs without an issue.
Steps to reproduce:
Versions: Microsoft Visual Studio Community 2022 (64-bit) Version 17.3.3 dotnet version 6.0.400
Logs
There is a build error in release mode that mentions the package:
Precompiling failed for C:\Users\hidden\obj\Release\net6.0-android\android-x86\linked\Plugin.MauiMtAdmob.dll. Failed to load method 0x6000095 from 'C:\Users\hidden\obj\Release\net6.0-android\android-x86\linked\Plugin.MauiMtAdmob.dll' due to Could not load file or assembly 'Microsoft.Maui, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies.. Mono Ahead of Time compiler - compiling assembly C:\Users\hidden\obj\Release\net6.0-android\android-x86\linked\Plugin.MauiMtAdmob.dll AOTID 030115F2-9CB1-3D92-0052-0036762132E1 Using profile data file 'C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\targets\dotnet.aotprofile' Run with MONO_LOG_LEVEL=debug for more information. AOT of image obj\Release\net6.0-android\android-x86\linked\Plugin.MauiMtAdmob.dll failed. hidden C:\Program Files\dotnet\packs\Microsoft.Android.Sdk.Windows\32.0.448\targets\Microsoft.Android.Sdk.Aot.targets 91
Debug build log output: