RegionInfo.CurrentRegion Not Working as Expected

AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

On Xamarin.Mac, RegionInfo.CurrentRegion does not reflect the Region setting in Preferences through neither an app restart nor a reboot. I always get US. I can get IT only if I set the Language to Italian and the Region to Italy.

Anybody know how to get the region setting in Preferences, independent of the language?


Best Answer


  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

    Thanks Chris.

    var locale = NSLocale.CurrentLocale.CountryCode;

    is the ticket!

  • AllanChin.6924AllanChin.6924 USUniversity ✭✭✭

    I did some additional testing of this behavior using an iOS simulator and it appears neither RegionInfo nor NSLocale return the Region setting in Preferences :o .

    === Visual Studio Community 2017 for Mac ===

    Version 7.2 (build 636)
    Installation UUID: 52841cf1-dbf0-469c-a714-a263f1d0573b
    Mono (2017-06/71277e78f6e) (64-bit)
    GTK+ 2.24.23 (Raleigh theme)

    Package version: 504000201

    === NuGet ===


    === .NET Core ===

    Runtime: Not installed
    SDK: Not installed
    MSBuild SDKs: /Library/Frameworks/Mono.framework/Versions/5.4.0/lib/mono/msbuild/15.0/bin/Sdks

    === Xamarin.Profiler ===

    Version: 1.5.6
    Location: /Applications/Xamarin Profiler

    === Apple Developer Tools ===

    Xcode 9.0.1 (13249)
    Build 9A1004

    === Xamarin.Android ===

    Version: (Visual Studio Community)
    Android SDK: /Users/allan/Library/Developer/Xamarin/android-sdk-macosx
    Supported Android versions:
    6.0 (API level 23)
    7.1 (API level 25)

    SDK Tools Version: 25.2.5
    SDK Platform Tools Version: 26.0.0
    SDK Build Tools Version: 25.0.3

    Java SDK: /usr
    java version "1.8.0_101"
    Java(TM) SE Runtime Environment (build 1.8.0_101-b13)
    Java HotSpot(TM) 64-Bit Server VM (build 25.101-b13, mixed mode)

    Android Designer EPL code available here:

    === Xamarin Inspector ===

    Not Installed

    === Xamarin.iOS ===

    Version: (Visual Studio Community)
    Hash: 2f8bbec0
    Branch: d15-4-xi
    Build date: 2017-10-05 20:56:05-0400

    === Xamarin.Mac ===

    Version: (Visual Studio Community)

    === Build Information ===

    Release ID: 702000636
    Git revision: b349c8fc0c2e1aab0179917d56eed75eb3a03337
    Build date: 2017-10-06 15:20:04-04
    Xamarin addins: a8da992c78f7eb65b3cdb3f951c34a30337cab35
    Build lane: monodevelop-lion-d15-4

    === Operating System ===

    Mac OS X 10.12.6
    Darwin 16.7.0 Darwin Kernel Version 16.7.0
    Thu Jun 15 17:36:27 PDT 2017
    root:xnu-3789.70.16~2/RELEASE_X86_64 x86_64

  • ChrisHamonsChrisHamons USForum Administrator, Xamarin Team Xamurai

    I would consider opening a thread on the iOS board, as my knowledge of the simulator is limited.

Sign In or Register to comment.