Avatar of OddiC
OddiC

asked on 

CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]- NullReferenceException on 1st Run from VS 2008??

I am experiencing a strange, repeatable error.... Every time I first run my project from Visual Studio (ONLY THE FIRST TIME!!!), I get a null reference exception when trying to assign the Request.UserLanguages[0] value to the Thread CurrentCulture..

But everything works fine (it can find the reference), on all subsequent tries (until I shut down VS 2008, open back up, and run it for another first time- then the error comes back (only for the first run though..)).

Does anyone know why I would be experiencing this odd behavior? I want to make sure there is nothing in my code amiss.

Thanks!!
Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(Request.UserLanguages[0]);

Open in new window

C#ASP.NETASP

Avatar of undefined
Last Comment
OddiC
ASKER CERTIFIED SOLUTION
Avatar of pvginkel
pvginkel
Flag of Netherlands image

Blurred text
THIS SOLUTION IS ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
Avatar of OddiC
OddiC

ASKER

Fair enough- I'm surprised that UserLanguages isn't initialized as soon as aspnet_wp starts up.. I will implement the error "catch" you suggested (and just use a default Lang value in that case).

ASP.NET
ASP.NET

The successor to Active Server Pages, ASP.NET websites utilize the .NET framework to produce dynamic, data and content-driven web applications and services. ASP.NET code can be written using any .NET supported language. As of 2009, ASP.NET can also apply the Model-View-Controller (MVC) pattern to web applications

128K
Questions
--
Followers
--
Top Experts
Get a personalized solution from industry experts
Ask the experts
Read over 600 more reviews

TRUSTED BY

IBM logoIntel logoMicrosoft logoUbisoft logoSAP logo
Qualcomm logoCitrix Systems logoWorkday logoErnst & Young logo
High performer badgeUsers love us badge
LinkedIn logoFacebook logoX logoInstagram logoTikTok logoYouTube logo