Reference to type 'Assembly' claims it is

2020-04-30 01:46发布

问题:

Already found the same problem here.

My error:

Severity Code Description Project File Line Suppression State Error CS7069 Reference to type 'Assembly' claims it is defined in 'System.Runtime', but it could not be found

The solution on that thread is downgrade the xamarin forms to version 2.5.1.527436 in all the projects. But I can't do that in my project, because I am using some features that are available in latest xamarin forms like android bottom tab feature, autosize property of editor and flowdirection property of listview.

I have this problem after updating xamarin forms to 3.4.0.1008975 from 2.5.0.121934. Problem is only on the UWP part. Android and IOS apps are working fine.

Error lines:

var rendererAssemblies = new List<Assembly>
   {
       typeof(ImageCircleRenderer).GetTypeInfo().Assembly
   };
rendererAssemblies.AddRange(Rg.Plugins.Popup.Popup.GetExtraAssemblies());
Rg.Plugins.Popup.Popup.Init();
Xamarin.Forms.Forms.Init(e, rendererAssemblies);

So how can I fix this issue without downgrading Xamarin.Forms?

Update

Facing the same problem again for another project. But the solution here is not fixing the error. Changed the target version of windows project to windows 10, version 1809(10.0;Build 17763) and min version to Windows 10 Fall Creators Update(10.0; Build 16299). Screenshot adding below: please suggest a solution.

Xamarin.Forms Version: 3.4.0.1008975

回答1:

As the linked thread mentions, the problem is that your app has to have min UWP version set to Fall Creators Update (16299), because this is the first release that supports .NET Standard 2.0.

In version 3.0 Xamarin.Forms dropped support for Portable Class Libraries and is now targeting .NET Standard 2.0 only. This means you must target at least Fall Creators Update (16299) in UWP to make sure it can be referenced.

To retarget your UWP project to the newer version, right-click the UWP project node in Solution Explorer, select Properties and then use the two dropdowns to select at least version 16299 in both.

Changing the Min version should be okay as long as you don't need to support Windows 10 Mobile, because absolute majority of users is already on version 1803 and Fall Creators Update is version 1709. See following usage graph (by AdDuplex)