'Uno.dll :: Could not load file or assembly 'Uno, Version=255.255.255.255'

Trying to reference Windows.Devices.Geolocation to use the Geolocator class from a .NET 6 core WinUI desktop head. I suspect - I am not sure - maybe the NetStandard flavor of Uno.dll intending to load here and that is why FileNotFoundException ?

FileNotFoundException: Could not load file or assembly 'Uno, Version=255.255.255.255, Culture=neutral, PublicKeyToken=null'. The system cannot find the file specified.

<PackageReference Include="Uno.WinUI" Version="4.2.6" />

enter image description here

Perhaps a little bit of WinDBG helps anything ? For me nothing.

The specified module could not be found.

What is more, it is not just a run time issue, even Visual Studio can't locate the assembly in source :

enter image description here

Procmon reveils, the assembly is found in the right nuget folder but the respective application process log not found:

enter image description here



Solution 1:[1]

I made a PR to your GitHub repro, but the steps needed were as follows.

First, the library had to be switched to multi-targeted by changing to <TargetFrameworks> in the .csproj:

<PropertyGroup>
    <TargetFrameworks>net6.0;net6.0-windows10.0.19041.0</TargetFrameworks>
</PropertyGroup>

Now the net6.0 target is for all Uno targets and the net6.0-windows10.0.19041.0 is specifically for WinAppSDK on Windows desktop.

Secondly, the Uno.WinUI needs to be referenced only on Uno targets, so:

<ItemGroup Condition="'$(TargetFramework)' != 'net6.0-windows10.0.19041.0'">
    <PackageReference Include="Uno.WinUI" Version="4.2.6" />
</ItemGroup>

After these changes, the Windows project will no longer try to access the Geolocator type from Uno.dll and will use the proper Windows SDK Geolocator:

Windows Geolocator type

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Martin Zikmund