NullReferenceException at GetRuleDescriptions

NullReferenceException at GetRuleDescriptions

Old forum URL: forums.lhotka.net/forums/t/2303.aspx


Vaidal posted on Thursday, February 08, 2007

Hi Rocky,

I've got System.NullReferenceException in the variable "rules" in this section of code:

namespace Csla.Validation

{

/// <summary>

/// Tracks the business rules broken within a business object.

/// </summary>

[Serializable()]

public class ValidationRules

{

  [...]

  public string[] GetRuleDescriptions()

  {

List<string> result = new List<string>();

ValidationRulesManager rules = RulesToCheck;

foreach (KeyValuePair<string, RulesList> de in rules.RulesDictionary)

  foreach (IRuleMethod rule in de.Value.GetList(false))

    result.Add(rule.ToString());

return result.ToArray();

  }

}

RockfordLhotka replied on Thursday, February 08, 2007

Which version of CSLA? And under what condition?

Vaidal replied on Friday, February 09, 2007

We are using CSLA 201cs

The problem appears in a test project with a BusinessListBase (without parent) that is binded to a devexpress grid.

You must check if rules variable is null before the call to rules.RulesDictionary.

RockfordLhotka replied on Tuesday, February 20, 2007

I'm trying to address a couple issues related to a BLB root - but I can't replicate the problems you guys are seeing. Please refer to this thread, where I posted a sample app and some instructions on how you can help isolate the issue.

http://forums.lhotka.net/forums/12341/ShowThread.aspx#12341

Thanks!

Copyright (c) Marimer LLC