Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

.NET 4.0 - CultureNotFoundException

Tags:

.net-4.0

I have migrated my ASP.NET MVC 2 project to VS 2010 + .NET 4.0. Now when i start the application i get a lot of "CultureNotFoundException" in IntelliTrace and Output/Gebug window :

A first chance exception of type 'System.Globalization.CultureNotFoundException' occurred in mscorlib.dll

I know what "A first chance exception" means, but when i try to debug(added "CultureNotFoundException" into Bebug/Exceptions[Thrown]) why ex. is thrown i got this detailed exception text:

System.Globalization.CultureNotFoundException occurred Message=Culture is not supported. Parameter name: name designer is an invalid culture identifier. Source=mscorlib ParamName=name InvalidCultureName=designer StackTrace: at System.Globalization.CultureInfo..ctor(String name, Boolean useUserOverride) InnerException:

I wonder why .NET is trying to create CultureInfo with name "designer"?

Isn't it bug?

like image 702
Feryt Avatar asked Jan 22 '10 11:01

Feryt


3 Answers

I had a similar issue with the CultureName "UserCache". To resolve this I deleted all the folders from in here:

C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files
like image 70
DaveShaw Avatar answered Nov 09 '22 03:11

DaveShaw


For other people that have this problem, this is usually an exception that is ignored.

Go to the Debug menu -> Exceptions... and ensure that you have everything unchecked for the Exception list.

like image 26
Brian R. Bondy Avatar answered Nov 09 '22 04:11

Brian R. Bondy


This is actually by design in System.Web (at least up until .NET Framework v4.0), not necessarily the best approach, but it works.

You can find a more detailed description here, but it basically happens because ASP.NET checks every single folder to see if it contains satellite assemblies, and throws an exception otherwise.

Given that satellite assemblies live in folders with predictable names, one would wonder why they would decide to do this rather than only check folders that match the pattern, particularly since handling exceptions is rather expensive computationally compared to a simple conditional check.

like image 20
Stefan Z Camilleri Avatar answered Nov 09 '22 02:11

Stefan Z Camilleri