- Home /
Trouble building with Google Analytics for WP8.1
I'm getting the error "'System.Globalization.CultureInfo' does not contain a definition for 'GetCulture'" when I try to build for WP8.1. My game works fine on Android.
I would also be fine with a method of excluding the entire GA plugin from the WP8.1 build.
Would someone please help?
Answer by Anders3D · Jan 18, 2016 at 09:06 AM
I got the very similar error CS0117: 'CultureInfo' does not contain a definition for 'GetCultures'. The code causing the problem started at line 65 in the file GoogleAnalyticsV3\GoogleAnalyticsMPV3.cs :
#if !UNITY_WP8
CultureInfo[] cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures);
foreach (CultureInfo info in cultureInfos) {
if (info.EnglishName == Application.systemLanguage.ToString()) {
language = info.Name;
}
}
#endif
The problem is that you are using the Unity Windows Store .NET scripting backend, which only contains a subset (.NET Core) of the classes in the normal .NET backend used by Unity: http://docs.unity3d.com/Manual/windowsstore-dotnet.html
To remove the problematic piece of code when you are compiling for the Unity Windows Store .NET scripting backend, you can use the preprocessor directive NETFX_CORE which is true in this case. Like so:
#if !UNITY_WP8 && !NETFX_CORE // .NET Core only contains a subset of all classes.
CultureInfo[] cultureInfos = CultureInfo.GetCultures(CultureTypes.AllCultures);
foreach (CultureInfo info in cultureInfos) {
if (info.EnglishName == Application.systemLanguage.ToString()) {
language = info.Name;
}
}
#endif
That removes the Google Analytics problems for me.
However, because all your scripts now have to use .NET Core, you may end up running into all sorts of problems with missing classes if you have not compiled the project with that backend before. If you get such problems, an alternative solution is to use the currently (2016-01-15) experimental IL2CPP scripting backend in Unity. For now, it only targets the Windows 10 SDK, but it gives your scripts the same environment as in the Unity editor. Since that process is outside of the scope of your question, I'll just link to a guide on my blog regarding that in case you are interested: http://andersguide.wordpress.com/2016/01/15/how-to-build-and-emulate-for-universal-windows-platform-with-unity-5-3/
Your answer
![](https://koobas.hobune.stream/wayback/20220613200004im_/https://answers.unity.com/themes/thub/images/avi.jpg)