Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unity3d using CreateSpecificCulture

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?

like image 884
Oksana Avatar asked Jan 19 '26 05:01

Oksana


1 Answers

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.

like image 119
Vagaus Avatar answered Jan 21 '26 09:01

Vagaus