xamarin / Xamarin.Forms

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

[Bug] XAML compilation faills with compiled bindings on UWP #6547

Open mavriski opened 5 years ago

mavriski commented 5 years ago

Description

UWP project fails to build if it contains any kind of Xamarin.Forms compiled bindings. Build output:

CompiledColorSelectorPage.xaml : error : Value cannot be null.
CompiledColorSelectorPage.xaml : error : Parameter name: type

Possibly related to #5416

Affected Setups:

Bug appears only if .xaml is in UWP project or a shared project linked to one. Data bindings demos and other projects with bindings as a part of .NET Standard library aren't affected. Android projects aren't affected.

Steps to Reproduce

Create a blank Xamarin.Forms + UWP project, move Xamarin.Forms files to UWP project, add a page with compiled bindings, build.

Basic Information

Reproduction Link

CompiledBindings.zip — a blank project with a page from data binding demos.

mmurfinsimmons commented 4 years ago

See my MS developercommunity link for more recent project and version info from my environment. And there is no 'solution' or workaround to this as yet. Fails in recent preview versions also.

meee1 commented 4 years ago

ive been tracing this a little. and ill just leave this here ` Mono.Cecil.dll!Mono.Cecil.Mixin.CheckType(object type) Line 397 at C:\Users\michael\AppData\Local\JetBrains\Shared\vAny\DecompilerCache\decompiler\02CD44F9-4EBD-4355-B3BE-9E1DBD9D77A1\dc\c528d527\Mixin.cs(397) Mono.Cecil.dll!Mono.Cecil.ModuleDefinition.ImportReference(Mono.Cecil.TypeReference type = null, Mono.Cecil.IGenericParameterProvider context = null) Line 686 at C:\Users\michael\AppData\Local\JetBrains\Shared\vAny\DecompilerCache\decompiler\02CD44F9-4EBD-4355-B3BE-9E1DBD9D77A1\af\db5f1eb9\ModuleDefinition.cs(686) Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.ModuleDefinitionExtensions.ImportCtorReference(Mono.Cecil.ModuleDefinition module = {Mono.Cecil.ModuleDefinition}, Mono.Cecil.TypeReference type = null, Mono.Cecil.TypeReference[] classArguments = null, System.Func<Mono.Cecil.MethodDefinition, bool> predicate) Line 63 at C:\Users\michael\AppData\Local\JetBrains\Shared\vAny\DecompilerCache\decompiler\0DE2AE98-FE42-42A1-A037-B97B89A95AC6\d4\38556398\ModuleDefinitionExtensions.cs(63) Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.ModuleDefinitionExtensions.ImportCtorReference(Mono.Cecil.ModuleDefinition module, (string assemblyName, string clrNamespace, string typeName) type, int paramCount) Line 111 at C:\Users\michael\AppData\Local\JetBrains\Shared\vAny\DecompilerCache\decompiler\0DE2AE98-FE42-42A1-A037-B97B89A95AC6\d4\38556398\ModuleDefinitionExtensions.cs(111) Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.XamlCTask.TryCoreCompile(Mono.Cecil.MethodDefinition initComp = {Mono.Cecil.MethodDefinition}, Mono.Cecil.MethodDefinition initCompRuntime = {Mono.Cecil.MethodDefinition}, Xamarin.Forms.Build.Tasks.ILRootNode rootnode = "ContentPage", out System.Exception exception = {"Value cannot be null.\r\nParameter name: type"}) Line 332 at C:\Users\michael\AppData\Local\JetBrains\Shared\vAny\DecompilerCache\decompiler\0DE2AE98-FE42-42A1-A037-B97B89A95AC6\c6\8d231357\XamlCTask.cs(332) Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.XamlCTask.Execute(out System.Collections.Generic.IList thrownExceptions) Line 217 at C:\Users\michael\AppData\Local\JetBrains\Shared\vAny\DecompilerCache\decompiler\0DE2AE98-FE42-42A1-A037-B97B89A95AC6\c6\8d231357\XamlCTask.cs(217) Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.XamlTask.Execute() Line 50 at C:\Users\michael\AppData\Local\JetBrains\Shared\vAny\DecompilerCache\decompiler\0DE2AE98-FE42-42A1-A037-B97B89A95AC6\e8\0f1e5234\XamlTask.cs(50)

ilProcessor.Emit(OpCodes.Newobj, module.ImportCtorReference(("Xamarin.Forms.Core", "Xamarin.Forms.Internals", "ResourceLoader/ResourceLoadingQuery"), 0));

    public static TypeDefinition GetTypeDefinition(
      this ModuleDefinition module,
      (string assemblyName, string clrNamespace, string typeName) type)
    {
      TypeDefinition typeDefinition1;
      if (ModuleDefinitionExtensions.typeDefCache.TryGetValue((module, type), out typeDefinition1))
        return typeDefinition1;

Key = ({Xamarin.dll}, ("Xamarin.Forms.Core", "Xamarin.Forms.Xaml", "XamlResourceIdAttribute"))
Value = {Xamarin.Forms.Xaml.XamlResourceIdAttribute}

at this point in time

      TypeDefinition typeDefinition1;
      if (ModuleDefinitionExtensions.typeDefCache.TryGetValue((module, type), out typeDefinition1))
        return typeDefinition1;

typeDefinition1 is being returned as null

meee1 commented 4 years ago

cleaner version

    Mono.Cecil.dll!Mono.Cecil.ModuleDefinition.ImportReference(Mono.Cecil.TypeReference type = null, Mono.Cecil.IGenericParameterProvider context = null) Line 686  C#  Symbols loaded.
    Mono.Cecil.dll!Mono.Cecil.ModuleDefinition.ImportReference(Mono.Cecil.TypeReference type) Line 678  C#  Symbols loaded.
>   Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.ModuleDefinitionExtensions.ImportCtorReference(Mono.Cecil.ModuleDefinition module = {Mono.Cecil.ModuleDefinition}, Mono.Cecil.TypeReference type = null, Mono.Cecil.TypeReference[] classArguments = null, System.Func<Mono.Cecil.MethodDefinition, bool> predicate = {Method = Inspecting the state of an object in the debuggee of type System.Delegate is not supported in this context.}) Line 39   C#  Symbols loaded.
    Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.ModuleDefinitionExtensions.ImportCtorReference(Mono.Cecil.ModuleDefinition module = {Mono.Cecil.ModuleDefinition}, (string assemblyName, string clrNamespace, string typeName) type = ("Xamarin.Forms.Core", "Xamarin.Forms.Internals", "ResourceLoader/ResourceLoadingQuery"), int paramCount = 0) Line 69 C#  Symbols loaded.
    Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.XamlCTask.TryCoreCompile(Mono.Cecil.MethodDefinition initComp = {Mono.Cecil.MethodDefinition}, Mono.Cecil.MethodDefinition initCompRuntime = {Mono.Cecil.MethodDefinition}, Xamarin.Forms.Build.Tasks.ILRootNode rootnode = "Application", out System.Exception exception = null) Line 270  C#  Symbols loaded.
    Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.XamlCTask.Execute(out System.Collections.Generic.IList<System.Exception> thrownExceptions = null) Line 182  C#  Symbols loaded.
    Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.XamlTask.Execute() Line 46  C#  Symbols loaded.

and

    at C:\Users\michael\Downloads\Xamarin.Forms-4.0.0\Xamarin.Forms.Build.Tasks\ModuleDefinitionExtensions.cs(294)
Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.ModuleDefinitionExtensions.ImportCtorReference(Mono.Cecil.ModuleDefinition module = {Mono.Cecil.ModuleDefinition}, (string assemblyName, string clrNamespace, string typeName) type = ("Xamarin.Forms.Core", "Xamarin.Forms.Internals", "ResourceLoader/ResourceLoadingQuery"), int paramCount = 0) Line 69
    at C:\Users\michael\Downloads\Xamarin.Forms-4.0.0\Xamarin.Forms.Build.Tasks\ModuleDefinitionExtensions.cs(69)
Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.XamlCTask.TryCoreCompile(Mono.Cecil.MethodDefinition initComp = {Mono.Cecil.MethodDefinition}, Mono.Cecil.MethodDefinition initCompRuntime = {Mono.Cecil.MethodDefinition}, Xamarin.Forms.Build.Tasks.ILRootNode rootnode = "ContentPage", out System.Exception exception = {"Value cannot be null.\r\nParameter name: type"}) Line 270
    at C:\Users\michael\Downloads\Xamarin.Forms-4.0.0\Xamarin.Forms.Build.Tasks\XamlCTask.cs(270)
Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.XamlCTask.Execute(out System.Collections.Generic.IList<System.Exception> thrownExceptions = Count = 1) Line 182
    at C:\Users\michael\Downloads\Xamarin.Forms-4.0.0\Xamarin.Forms.Build.Tasks\XamlCTask.cs(182)
Xamarin.Forms.Build.Tasks.dll!Xamarin.Forms.Build.Tasks.XamlTask.Execute() Line 46
    at C:\Users\michael\Downloads\Xamarin.Forms-4.0.0\Xamarin.Forms.Build.Tasks\XamlTask.cs(46)

this returns null

meee1 commented 4 years ago
 module.Assembly.Name.Name == type.assemblyName                             ? module.Assembly                           : module.AssemblyResolver.Resolve(AssemblyNameReference.Parse(type.assemblyName));
{Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null}
    CustomAttributes: {Mono.Collections.Generic.Collection<Mono.Cecil.CustomAttribute>}
    EntryPoint: null
    FullName: "Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null"
    HasCustomAttributes: true
    HasSecurityDeclarations: false
    MainModule: {Xamarin.Forms.Core.dll}
    MetadataToken: {[Assembly:0x0001]}
    Modules: {Mono.Collections.Generic.Collection<Mono.Cecil.ModuleDefinition>}
    Name: {Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null}
    SecurityDeclarations: {Mono.Collections.Generic.Collection<Mono.Cecil.SecurityDeclaration>}
    custom_attributes: {Mono.Collections.Generic.Collection<Mono.Cecil.CustomAttribute>}
    main_module: {Xamarin.Forms.Core.dll}
    modules: {Mono.Collections.Generic.Collection<Mono.Cecil.ModuleDefinition>}
    name: {Xamarin.Forms.Core, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null}
    security_declarations: {Mono.Collections.Generic.Collection<Mono.Cecil.SecurityDeclaration>}
asm.MainModule.GetType($"{type.clrNamespace}.{type.typeName}")
null
type
("Xamarin.Forms.Core", "Xamarin.Forms.Internals", "ResourceLoader/ResourceLoadingQuery")
    assemblyName: "Xamarin.Forms.Core"
    clrNamespace: "Xamarin.Forms.Internals"
    typeName: "ResourceLoader/ResourceLoadingQuery"
    Raw View: ("Xamarin.Forms.Core", "Xamarin.Forms.Internals", "ResourceLoader/ResourceLoadingQuery")

so the issue is that the C:\Users\michael\Source\Repos\MissionPlanner\bin\Debug\net461\Xamarin.Forms.Core.dll path its finding is not the correct one, and Xamarin.Forms.Internals.ResourceLoader at that location does not have a "ResourceLoadingQuery" subclass. the one in the nuget packages directory does contain it. so module.AssemblyResolver.Resolve(AssemblyNameReference.Parse(type.assemblyName)); is failing to find the correct assembly based on the search path order

in my case this is

Using "XamlCTask" task from assembly "C:\Users\michael\.nuget\packages\xamarin.forms\4.0.0.540366\build\net46\Xamarin.Forms.Build.Tasks.dll".
Task "XamlCTask"
  Compiling Xaml, assembly: obj\Debug\netstandard2.0\Xamarin.dll
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\7zip\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\mono\mcs\class\lib\net_4_x-win32\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\acr.userdialogs\7.0.35\lib\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\alglibnet\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\bitmiracle.libtiff.net\2.4.584.1\lib\netstandard1.3
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\BouncyCastle\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\carouselview.formsplugin\5.0.0\lib\netstandard1.4
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\Core\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\csmatio\1.0.20\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\dotnetzip\1.13.7\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\exiflibnet\1.2.21\lib\netstandard1.3
    Adding searchpath C:\Users\michael\.nuget\packages\flurl\2.8.0\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\flurl.http\2.3.2\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\geoapi.coordinatesystems\1.7.5\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\geoapi.core\1.7.5\lib\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\GeoUtility\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\GMap.NET.Core\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\ICSharpCode.SharpZipLib\bin\Debug\netstandard2
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\Interfaces\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\KMLib\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\LibVLC.NET\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\log4net\2.0.8\lib\netstandard1.3
    Adding searchpath C:\Users\michael\.nuget\packages\mathparser.org-mxparser\4.3.3\lib\netstandard20
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\Mavlink\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\MetaDataExtractorCSharp240d\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\microsoft.codeanalysis.csharp\3.6.0\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\microsoft.codeanalysis.common\3.6.0\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\microsoft.win32.registry\4.7.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\ArduPilot\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\Comms\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\MissionPlanner.Drawing.Common\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\bin\Debug\net461
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\Strings\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\Utilities\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\netDxf\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\newtonsoft.json\12.0.3\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\nlog\4.7.2\lib\netstandard2.0
    Adding searchpath C:\Program Files (x86)\Microsoft Visual Studio\2019\Preview\Common7\IDE\ReferenceAssemblies\Microsoft\Framework\MonoAndroid\v4.4
    Adding searchpath C:\Users\michael\.nuget\packages\xamarin.plugin.filepicker\2.1.34\lib\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\ProjNet\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\px4uploader\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\sharpdx.directinput\4.1.0\lib\netstandard1.3
    Adding searchpath C:\Users\michael\.nuget\packages\sharpdx\4.1.0\lib\netstandard1.1
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\SharpKml\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\sixlabors.core\1.0.0-beta0008\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\sixlabors.fonts\1.0.0-beta0009\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\sixlabors.imagesharp\1.0.0-beta0007\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\sixlabors.imagesharp.drawing\1.0.0-beta0007\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\sixlabors.shapes\1.0.0-beta0009\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\skiasharp\1.68.1.1\lib\netstandard1.3
    Adding searchpath C:\Users\michael\.nuget\packages\skiasharp.views.forms\1.68.1.1\ref\netstandard1.3
    Adding searchpath C:\Users\michael\.nuget\packages\socketioclient\2.0.2.1\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.buffers\4.5.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\system.codedom\4.7.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.collections.immutable\1.5.0\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.configuration.configurationmanager\4.5.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\MissionPlanner.Drawing\bin\Debug\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\bezier\0.9.3.5\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\font\0.3.0.3\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.io.ports\4.7.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.memory\4.5.3\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.numerics.vectors\4.5.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.reactive\4.0.0\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.reflection.emit\4.7.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\system.reflection.emit.ilgeneration\4.7.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\system.reflection.emit.lightweight\4.7.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.reflection.metadata\1.6.0\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.reflection.typeextensions\4.4.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\system.resources.extensions\4.6.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.runtime.compilerservices.unsafe\4.7.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.runtime.interopservices.windowsruntime\4.3.0\ref\netstandard1.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\mono\mcs\class\lib\net_4_x-win32\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.security.accesscontrol\4.7.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.security.permissions\4.7.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.security.principal.windows\4.7.0\ref\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.text.encoding.codepages\4.7.0\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\system.threading.tasks.extensions\4.5.3\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\mono\mcs\class\lib\net_4_x-win32\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\netstandard.library\2.0.3\build\netstandard2.0\ref
    Adding searchpath C:\Users\michael\.nuget\packages\xam.plugin.tabview\1.0.4\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\xamarin.forms\4.0.0.540366\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\xamarin.forms.datagrid\3.1.0\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\xamarin.forms\4.0.0.540366\lib\netstandard2.0
    Adding searchpath C:\Users\michael\.nuget\packages\xamarin.forms\4.0.0.540366\lib\netstandard2.0
    Adding searchpath C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\Zeroconf\Zeroconf\bin\Debug\netstandard2.0
    Module: Xamarin.dll
      Resource: MissionPlanner.Controls.AGauge.resources
        skipped.
      Resource: MissionPlanner.Controls.HUDT.resources
        skipped.
      Resource: MissionPlanner.Properties.Resources.resources
        skipped.
      Resource: MissionPlanner.GCSViews.MavlinkCheckBoxBitMask.resources
        skipped.
      Resource: MissionPlanner.GCSViews.paramcompare.resources
        skipped.
      Resource: MissionPlanner.GCSViews.ConfigurationView.ConfigRawParams.resources
        skipped.
      Resource: MissionPlanner.App.xaml
        Creating empty App.__InitComponentRuntime
          done.
        Copying body of InitializeComponent to __InitComponentRuntime
          done.
        Parsing Xaml
          done.
        Replacing 0.InitializeComponent ()
          failed.
App.xaml : error : Value cannot be null. [C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\Xamarin\Xamarin\Xamarin.csproj]
App.xaml : error : Parameter name: type [C:\Users\michael\Source\Repos\MissionPlanner\ExtLibs\Xamarin\Xamarin\Xamarin.csproj]
     at Mono.Cecil.Mixin.CheckType(Object type)
     at Mono.Cecil.ModuleDefinition.ImportReference(TypeReference type, IGenericParameterProvider context)
     at Mono.Cecil.ModuleDefinition.ImportReference(TypeReference type)
     at Xamarin.Forms.Build.Tasks.ModuleDefinitionExtensions.ImportCtorReference(ModuleDefinition module, TypeReference type, TypeReference[] classArguments, Func`2 predicate) in C:\Users\michael\Downloads\
  Xamarin.Forms-4.0.0\Xamarin.Forms.Build.Tasks\ModuleDefinitionExtensions.cs:line 39
     at Xamarin.Forms.Build.Tasks.ModuleDefinitionExtensions.ImportCtorReference(ModuleDefinition module, ValueTuple`3 type, Int32 paramCount) in C:\Users\michael\Downloads\Xamarin.Forms-4.0.0\Xamarin.Forms
  .Build.Tasks\ModuleDefinitionExtensions.cs:line 69
     at Xamarin.Forms.Build.Tasks.XamlCTask.TryCoreCompile(MethodDefinition initComp, MethodDefinition initCompRuntime, ILRootNode rootnode, Exception& exception) in C:\Users\michael\Downloads\Xamarin.Forms
  -4.0.0\Xamarin.Forms.Build.Tasks\XamlCTask.cs:line 270
mnxamdev commented 3 years ago

We're running into this issue as well. We've added compiled bindings to our project to improve performance on Android but now UWP won't compile. Any word on if/when this will get fixed?

mooola commented 3 years ago

Why hasn't this been resolved yet? Any workarounds? So what is being said here (implicitly by Microsoft) is XamlCompilation is basically worthless because of this bug?

rheesbeen commented 2 years ago

Also having this issue. It's so clear that Xamarin Forms is a dead horse. And MAUI will probably go down the same route pretty fast, why would that be any different...

nisewonder commented 2 years ago

Same issue for me. Is there a workaround to set x:DataType="viewmodel:CloudLoginViewModel" on iOS and Android, but not for UWP?

jamesmontemagno commented 2 years ago

I can't seem to reproduce this at all with all my code/logic in a .NET standard project -> https://github.com/jamesmontemagno/XFDataTypeSample

nisewonder commented 2 years ago

@jamesmontemagno Switch your Xamarin.Forms project to a shared project and you should see the issue on UWP. Android and iOS do not have this issue.

jamesmontemagno commented 2 years ago

Ahhh gotcha! Yeah I would not recommend using shared project types at all anymore as we haven’t recommended them for some time. I would recommend using .NET Standard projects instead. This probably has something to do specifically with the UWP build system most likely.

rheesbeen commented 2 years ago

Shared projects are a part of the eco system. But I was not expecting this to be fixed as a lot of bugs have never been fixed. It's most likely also not working on MAUI or ever going to be fixed there. I already see a lot of bug reports for MAUI that also will never be fixed.

I would recommend not using Forms or MAUI. It's just not stable and something you can count on to work or be fixed.