Xamarin Android System.TypeLoadException after clearing storage on Azure DevOps app build

382 views Asked by At

Randomly, I seem to get System.TypeLoadException. This also occurs every time I clear the storage of my app on my device. This only happens for app builds that have been produced by Azure DevOps pipelines. I cannot reproduce this error on my local builds from my device no matter if it's configured for Debug or Production. Here are some errors I've had relating to this issue:

JsonSerializer.GetMatchingConverter (System.Collections.Generic.IList`1[T] converters, System.Type objectType) System.TypeLoadException: Could not resolve type with token 01000113 from typeref (expected class 'System.Data.SqlTypes.SqlBinary' in assembly 'System.Data, Version=2.0.5.0, Culture=neutral, PublicKeyToken=b77a5c561934e089')

DataSetConverter.CanConvert (System.Type valueType) System.TypeLoadException: Could not load type of field 'System.Data.DataSet:PropertyChanging' (28) due to: Could not resolve type with token 0100003c from typeref (expected class 'System.ComponentModel.PropertyChangedmzntHandler' in assembly 'System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e') assembly:System, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e type:System.ComponentModel.PropertyChangedmzntHandler member:(null)

DefaultContractResolver.CreateObjectContract (System.Type objectType) System.TypeLoadException: Could not resolve type with token 010000c4 from typeref (expected class 'System.Runtime.Serialization.DataContractAttribute' in assembly 'System.Runtime.Serialization, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e')

Why are these classes missing from the assemblies? Could it be to do with Azure DevOps not building the Android App Bundles correctly?

1

There are 1 answers

4
Leo Liu On

Xamarin Android System.TypeLoadException after clearing storage on Azure DevOps app build

Errors like this usually mean that the assemblies aren't in sync any more. This means that assemblies, gathered in your bin and obj folders in the different projects contains mixed versions and thus can cause unexpected behavior.

To resolve this issue, please try to:

  • Try a clean and rebuild on your complete solution, manually delete the bin and obj folders from each project folder if you are using private agent.
  • Check if you compile the app with Visual Studio 2019 when you build it with Azure devops.

You could check this thread and this thread for some more details.