Search code examples
c#xamarinxamarin.formssyncfusion

How to resolve ApplicationException conflict between mscorlib and Nuget package


Problem

I am attempting to display a pdf file to the users of my Xamarin.Forms Android and iOS applications. I am trying to use the Nuget package Syncfusion.Xamarin.SfPdfViewer.

However, installing the package and recompiling results in the following error:

Error CS0433 The type 'ApplicationException' exists in both 'Syncfusion.Compression.Portable, Version=16.1451.0.37, Culture=neutral, PublicKeyToken=null' and 'mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e'

Steps Tried

I have read and heeded the note on the Nuget package:

Note: This package needs to be installed in all Xamarin.Forms projects (PCL, Android, iOS and UWP).

I have searched the web for similar cases such as:

Specs

I am using:

  • Visual Studio 2017 version 15.7.2
  • Xamarin version 4.10.0448
  • Xamarin.Forms v3.0.0.482510
  • NETStandard.Library v2.0.3


Thank you for your help.


Solution

  • Found a workaround. Since good practice is to derive meaningful exceptions from Exception, I created one and used it in place of where I was using ApplicationException. This removed the ambiguity and solution then compiled.

    public class ClaimWriterException : Exception
    {
        public ClaimWriterException()
        {
        }
    
        public ClaimWriterException(string message)
            : base(message)
        {
        }
    
        public ClaimWriterException(string message, Exception inner)
            : base(message, inner)
        {
        }
    }