Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Wyverex 7 posts 27 karma points
    Feb 01, 2010 @ 20:00
    Wyverex
    0

    Weird behavior of Language.GetByCultureCode()

    Hi,

    according to the documentation, Language.GetByCultureCode() should return null when you pass in a culture code that is not set up for your site. Since my website is a 1:1 multi-lingual site and the language can be chosen by appending a simple query string parameter, I thought: "Hey, that's nice, I'll just pass the chosen culture code in and if it returns null, the user put in a wrong culture code so I use some other fallback language". So far for the theory...

    As long as I pass in a configured culture, everything works fine. But whenever I pass in a culture code that is not configured in the backend, I get an ugly exception like this:

    [ArgumentNullException: Der Wert darf nicht NULL sein. (<- The value may not be NULL)
    Parametername: value]
       System.Web.Caching.CacheEntry..ctor(String key, Object value, CacheDependency dependency, CacheItemRemovedCallback onRemovedHandler, DateTime utcAbsoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, Boolean isPublic) +11229394
       System.Web.Caching.CacheInternal.DoInsert(Boolean isPublic, String key, Object value, CacheDependency dependencies, DateTime utcAbsoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback, Boolean replace) +146
       System.Web.Caching.Cache.Add(String key, Object value, CacheDependency dependencies, DateTime absoluteExpiration, TimeSpan slidingExpiration, CacheItemPriority priority, CacheItemRemovedCallback onRemoveCallback) +126
       umbraco.cms.businesslogic.cache.Cache.GetCacheItem(String cacheKey, Object syncLock, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, CacheDependency cacheDependency, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem) +251
       umbraco.cms.businesslogic.cache.Cache.GetCacheItem(String cacheKey, Object syncLock, CacheItemPriority priority, CacheItemRemovedCallback refreshAction, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem) +129
       umbraco.cms.businesslogic.cache.Cache.GetCacheItem(String cacheKey, Object syncLock, CacheItemRemovedCallback refreshAction, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem) +115
       umbraco.cms.businesslogic.cache.Cache.GetCacheItem(String cacheKey, Object syncLock, TimeSpan timeout, GetCacheItemDelegate`1 getCacheItem) +89
       umbraco.cms.businesslogic.language.Language.GetByCultureCode(String CultureCode) +215

    I saw that some other people already had problems with this and it seems that they had wrong culture codes configured in their database. Unfortunately, that's not the case for me. I have two cultures set up in my umbracoLanguage table, each one with correct values.

    So what could be causing this?

    Or, alternatively, is there another way to determine whether a specific culture exists?

    Thanks

  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies