Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsLanguage PacksLanguage PacksNullReferenceException in GetResourceNullReferenceException in GetResource
Previous
 
Next
New Post
1/14/2006 9:15 PM
 

DNN: 4.00.02

I'm periodically gettin this exception.  I finally hit it in the debugger at the following line:

If (Not GetSupportedLocales(userLanguage) Is Nothing) AndAlso (GetSupportedLocales(userLanguage).Fallback.ToLower <> "") Then

It appears that GetSupportedLocales(userLanguage) is returning Null when this happens.  As such, GetSupportedLocales(userLanguage).Fallback is generating the null reference exception.  I believe that reading this code the expectation is that if GetSupportedLocales(userLanguage) is null, then the second part of the if should not be check, but is.  Could this be a timing issue where the first time GetSupportedLocales() succeeds, but the 2nd one fails?

It seems to me the fix would be:

Dim objLocales As LocaleCollection = GetSupportedLocales(userLanguage)
If (Not objLocales Is Nothing) AndAlso (objLocales.FallbackToLower <> "") Then

Detailed exception follows:

AssemblyVersion: 04.00.02
Method: DotNetNuke.Services.Localization.Localization.GetResource
FileName:
FileLineNumber: 0
FileColumnNumber: 0
PortalID: 0
PortalName: Meadowdale High School Class of 1987
UserID: -1
UserName:
ActiveTabID: 73
ActiveTabName: Now and Then - H-J's
AbsoluteURL: /Default.aspx
AbsoluteURLReferrer:
ExceptionGUID: aecc56b8-c717-4a76-8d42-65b7ee4c3184
DefaultDataProvider: DotNetNuke.Data.SqlDataProvider, DotNetNuke.SqlDataProvider
InnerException: Object reference not set to an instance of an object.
Message: DotNetNuke.Services.Exceptions.PageLoadException: Object reference not set to an instance of an object. ---> System.NullReferenceException: Object reference not set to an instance of an object. at DotNetNuke.Services.Localization.Localization.GetResource(String ResourceFileRoot, PortalSettings objPortalSettings, String strLanguage) at DotNetNuke.Services.Localization.Localization.GetString(String name, String ResourceFileRoot, PortalSettings objPortalSettings, String strLanguage) at DotNetNuke.Services.Localization.Localization.GetString(String name) at DotNetNuke.Services.Exceptions.ErrorContainer..ctor(PortalSettings _PortalSettings, String strError, Exception exc) at DotNetNuke.UI.Skins.Skin.InjectModule(Control objPane, ModuleInfo objModule, PortalSettings PortalSettings) at DotNetNuke.UI.Skins.Skin.Page_Init(Object sender, EventArgs e) at System.Web.UI.Control.OnInit(EventArgs e) at System.Web.UI.UserControl.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Control.AddedControl(Control control, Int32 index) at System.Web.UI.ControlCollection.Add(Control child) at DotNetNuke.Framework.DefaultPage.Page_Init(Object sender, EventArgs e) in E:\inetpub\MHS87\Default.aspx.vb:line 490 at System.Web.UI.Control.OnInit(EventArgs e) at System.Web.UI.Page.OnInit(EventArgs e) at DotNetNuke.Framework.PageBase.OnInit(EventArgs e) at System.Web.UI.Control.InitRecursive(Control namingContainer) at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) --- End of inner exception stack trace ---

 
New Post
1/15/2006 1:01 PM
 

Guess I shouldn't try to code in a web browser.  Here's my actual fix:

Dim objSupportedLocale As Locale = GetSupportedLocales(userLanguage)
If (Not objSupportedLocale Is Nothing) AndAlso (objSupportedLocale.Fallback.ToLower <> "") Then
   fallbackLanguage = objSupportedLocale.Fallback.ToLower
End If

That said, I'm still hitting the NullReferenceException, now on the first line.  Guess I need to dig deeper.

 
New Post
1/16/2006 3:35 AM
 

Looking at the code again, I realized I'm an idiot.  The original code is accessing an element in the collection, but if the collection is null, then it will always throw.  The correct fix should be to revert to the original code and wrap it with a check to see if the collection is null:

If (Not GetSupportedLocales() Is Nothing) Then
   
If (Not GetSupportedLocales(userLanguage) Is Nothing) AndAlso (GetSupportedLocales(userLanguage).Fallback.ToLower <> "") Then
      
fallbackLanguage = GetSupportedLocales(userLanguage).Fallback.ToLower
   
End If
End If

I'll try out this fix to see if it works any better.

 
New Post
1/22/2006 3:48 AM
 
 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Provider and Extension ForumsProvider and Extension ForumsLanguage PacksLanguage PacksNullReferenceException in GetResourceNullReferenceException in GetResource


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out