0

I am working on a Xamarin.Forms project, for which I recently upgraded the shared projects from PCL to .NETStandard.

At that point, I encountered build issues coming from several of my UI XAML files, with the error being:

Failed to resolve assembly: ‘MyAssembly, Version 0.0.0.0, Culture=neutral, PublicKeyToken=null’

The problem files were found to be those that referenced custom XAML controls. After finding several people with similar issues online, I eventually found that I could get past this issue by setting the XamlCompilationOptions for those pages from Compile to Skip. The project now builds for iOS and Android.

The Android version works normally, however for the iOS version crashes when one of those pages tries to load, due to the presence of the custom control, with an error such as:

Xamarin.Forms.Xaml.XamlParseException … Type shared.SharedControl not found in xlmns clr-namespace: …

Has anyone encountered this issue, and if so, did you solve it? Is it a code issue or a Xamarin / Visual Studio Mac bug?

Ideally I would like to not have to set the XamlCompilationOptions for those pages to Skip, but either way I don't see why it should affect iOS but not Android.

  • I bet if you use proguard for android, that will link as good as ios linker does, you will start crashing on android too. Skip is a workaround not a solution. You better solve your primarily problem appeared after migration. Don't have enough info on it in your question anyway. – Nick Kovalsky Sep 04 '18 at 06:24
  • Thanks, I migrated it by following the link https://xamarinhelp.com/upgrade-pcl-net-standard-class-library/. This has not had any problems on the Android side, only for iOS. – HelplessDev Sep 04 '18 at 08:11

2 Answers2

0

Firstly, XamlCompilationOptions.Compile means Compile the XAML for the class or project when the application is built.While XamlCompilationOptions.Skip do the same thing when the application is run on the device.

In addition ,I suggest that you can do following steps:

  1. Delete and Re-generate all share files
  2. Remove ;assembly:xxx from App.xaml
  3. Clean and build again.

Here is a similar thread for you referring toXamarin.Forms.Xaml.XamlParseException has been thrown

PS:There is a link about how to Upgrade PCL to .NET Standard Class Library

Lucas Zhang
  • 18,630
  • 3
  • 12
  • 22
  • Thanks, that link is the guide I used to upgrade to .NET Standard – HelplessDev Sep 04 '18 at 07:26
  • https://stackoverflow.com/questions/42386406/xamarin-forms-xaml-xamlparseexception you can access the link for more information – Lucas Zhang Sep 04 '18 at 08:09
  • Step 2 seems to have solved it for me. I removed ;assembly=xxx from all the XAML view files that were referencing shared controls, and it worked. Thanks! – HelplessDev Sep 04 '18 at 11:06
0

You need to load that assembly before using it. On Xaml it does not load, just try to reach, and crashes if its not loaded. Before using it you need to load assembly by calling a method, or creating an object belong MyAssembly.

There should be a Init method for the assembly to init things. you should call it.

eakgul
  • 3,658
  • 21
  • 33
  • Thanks, I think the Init() method would be InitializeComponent(), and that is the first method called within the page constructor. – HelplessDev Sep 04 '18 at 08:09
  • After further reading I added a static Init() method to the shared control classes, and called it from AppDelegate.cs, however in my case this did not solve the problem. – HelplessDev Sep 04 '18 at 11:07