Question

For get culture Info in Unity3d app I wrote some code:

public static System.Globalization.CultureInfo GetCultureInfo()
{
    if (cultureInfo == null)
        cultureInfo = System.Globalization.CultureInfo
                     .CreateSpecificCulture(Localization.Data.Locale);

    return cultureInfo;
}

It's works fine when i run app in Editor. If I built app as web and run then i recieve exception

at System.Security.SecurityManager.ThrowException (System.Exception ex) 
[0x00000] in <filename unknown>:0 

Why it does not work in web player?

Was it helpful?

Solution

If you look into the method CultureInfo.CreateSpecificCulture() in the mscorlib used by the WebPlayer (using ILSpy for instance) you'll see that it is marked as SecurityCritical (you can read more information about .Net security here and here)

[SecurityCritical] public static CultureInfo CreateSpecificCulture(string name)

and, AFAIK, all code from your game is considered to be "transparent" so it is not allowed to call into "security critical" code.

Also, if you check this page the method is marked as not supported on WebPlayer.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top