Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Encoding fails when I build Monodroid project with unshared runtime

I am trying to use the DotNetZip library in my Monodroid app. Everything seems to work fine when I enable the Shared Runtime build option. When I disable Shared Runtime, the line

static System.Text.Encoding ibm437 = System.Text.Encoding.GetEncoding("IBM437");

generates an Exception (Encoding name 'IBM437' not supported). I've checked every box in the "Additional Supported Encodings" list, but it does not seem to help. Anyone have any ideas?

like image 821
Ash Avatar asked Jun 01 '12 23:06

Ash


1 Answers

I had the exact same problem.

First, make sure that you've added the "West" encoding in the project properties:

Xamarin Internationalization

If that doesn't do the trick, the problem is that the needed dlls are not getting copied to the .apk's assemblies folder. This should happen automatically, but it doesn't. I filed a bug, so you can see if it's been fixed:

Mono for Android / Xamarin Bugzilla

If not, here is a workaround that worked for me (from Xamarin):

  1. Manually Add References to I18N.dll and I18N.West.dll
  2. Set the 'Copy Local' properties to 'true' for both dlls
  3. Add the following dummy code to get the 2 dlls added to the .apk

    var ignore = new I18N.West.CP437();

  4. Make sure that 'Linking' is set to 'None'

Hope this helps!

like image 86
Branden Barber Avatar answered Nov 14 '22 22:11

Branden Barber