how can I throw and handle InvalidCultureNameException? RRS feed

  • Question

  • User1183903743 posted

    ArrayList allCults = new ArrayList(CultureInfo.GetCultures(CultureTypes.AllCultures));

      // I know the framework will throw an exception here. 
       CultureInfo ci=new CultureInfo(badCultureName);

       if (allCults.Contains(ci)){
          //do something localized
    catch(InvalidCultureNameException e)
       // however the only InvalidCultureNameException I could find was in the MapPoint SDK.
       //nothing in System.Globalization - Am I missing something?
       HttpContext.Current.Trace.Warn("My component", "Invalid culture string passed in", e);

       //instead of
       HttpContext.Current.Trace.Warn("My component", "Invalid culture string passed in", HttpContext.Current.Server.GetLastError().GetBaseException() );


    Any tip appreciated


    Wednesday, July 27, 2005 8:38 AM

All replies

  • User-1039727602 posted
    I believe the CultureInfo constructor would throw a System.ArgumentException.
    Wednesday, December 14, 2005 11:13 AM
  • User1183903743 posted

    Wow this was months ago. Thank you.

    They took away the drop down to mark a post as resolved for the c# forum.

    Wednesday, December 14, 2005 1:54 PM