Quantcast
Channel: Xamarin.Forms — Xamarin Community Forums
Viewing all articles
Browse latest Browse all 77050

Cannot use 3rd party library Aspose, even though supports Mono

$
0
0

I'm quite new to Xamarin.Forms and using Mono - so forgive me if this query is somewhat backwards, I'll do my best to explain.

We use a 3rd party library called Aspose to manipulate Word, Excel & PDF documents. The project I'm working on involves taking our existing Windows Tablet application and creating a Xamarin.Forms one, initially for Android. Aspose claim their library works with Mono (could it be it only works with regular Mono? Not Mono.Android?).

I've got the majority of the old business layer and objects ported over - I've gone through the various pains of having to make PCLs (I have a lot of code to port over) and implemented several dependencies to do things like launch the application for a file, make use of Rijndael cryptography (needed to preserve the exact behaviour of the old implementation), etc.

What I've learned is I cannot just plug in Aspose and go. So I've created a DLL that's wrapping up my business logic around it (not a PCL). I have then added a reference to the assembly .Droid.UI, in anticipation for having to create a dependency (putting in [assembly: Xamarin.Forms.Dependency(typeof(CryptographerAndroid))] ,etc). It lets me add it, but when I try to build I get:

Exception while loading assemblies: System.IO.FileNotFoundException: Could not load assembly 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. Perhaps it doesn't exist in the Mono for Android profile?
File name: 'System.Drawing.dll'

I've done some research and understand that there simply isn't such a DLL for Mono (Windows specific, etc). So it appears I have to use Mono.Android.

However this doesn't seem to make the error go away.

I've then tried instead making an Android class library, but I get errors like this:

The type 'System.Xml.XPath.IXPathNavigable' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.

(I've have added the Mono System.Xml - I think the dependency comes from Aspose)

So I've gone back to my original DLL that's wrapping up the business logic and tried recompiling that with Mono.Android instead of System.Drawing.

I then get errors like this:

Error 8 The type 'System.Drawing.Image' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. C:\Data\TFS2012\Workbench\SLWorkbench\OfficeProvidersMono\AsposeWord.cs 532 45 OfficeProviders

Error 11 The type 'System.Drawing.Color' is defined in an assembly that is not referenced. You must add a reference to assembly 'System.Drawing, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. C:\Data\TFS2012\Workbench\SLWorkbench\OfficeProvidersMono\AsposeExcel.cs 691 13 OfficeProviders

Error 32 Argument 1: cannot convert from 'System.Drawing.Color [c:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\MonoAndroid\v5.1\Mono.Android.dll]' to 'System.Drawing.Color' C:\Data\TFS2012\Workbench\SLWorkbench\OfficeProvidersMono\AsposeExcel.cs 788 39 OfficeProviders

I got the point how System.Drawing is a problematic one be trying to use on Android as it's all native Windows - but I was expecting to be able to compile, but then get errors at runtime.

Am I missing something here? Do I have to bite the bullet and invest in something like SyncFusion?

Many thanks,
Peter


Viewing all articles
Browse latest Browse all 77050

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>