Error MSB4185: "System.Globalization.CultureInfo" has not been enabled for execution

3.5k views Asked by At

When trying to build in MonoDevelop with Mono for Android I get this error. According to the debug it is not located in my code so im left clueless. Any idea?

Error MSB4185: The function "CurrentUICulture" on type "System.Globalization.CultureInfo" has not been enabled for execution. (MSB4185)

3

There are 3 answers

0
Ebrahim Byagowi On

The working solution for me is this:

Open a CMD and run this command on it: setx MSBUILDENABLEALLPROPERTYFUNCTIONS 1

Another solution I think is available is installing Mono Runtime and set it as your default CLR runtime from Tools -> Options -> .NET Runtimes.

0
Dominique On

After uninstalling .NET Framework 4.5 RC from my Windows 7 machine, this error disappeared. Of course make sure you have valid .NET runtime after you uninstall 4.5.

10
dan On

I own MSBuild (and this code). It's an error originating in the file microsoft.csharp.targets, as the error message probably says. In there is a property function:

$([System.Globalization.CultureInfo]::CurrentUICulture.Name)

What the error means is that it thinks that this function isn't in MSBuild's "safe list". These are selected functions that have no side effects. (If you want to use any function, you must have an environment variable MSBUILDENABLEALLPROPERTYFUNCTIONS=1).

I really don't know why this would appear unless somehow you're using the 4.5 microsoft.csharp.targets with the 4.0 microsoft.build.dll (which didn't have it in the safe list). I haven't received reports of this except in connection with Monodevelop.

Excuse my naivety, but I'm assuming Monodevelop is using the Microsoft .NET Framework with the Microsoft MSBuild and not a reimplementation of that.

Dan