Search code examples
biztalkbusiness-rulesbiztalk-2013

BizTalk BRE - Method in .Net Class not working in Orchestration Call Rule Shape


I am trying to use an external class library method call AddValidationErrors to errors out the data validation errors in Business Rule Composer. I have created a FactCreator class which implements IFactCreator interface also. This is working when I try to test my policy in Business Rule Composer. But when I try in Orchestration it rule is not fired. Can anyone help me out in this. Below is my code for Validation errors

public void AddValidationError(TypedXmlDocument activeDoc, string err)
{
   XmlDocument doc = activeDoc.Document.OwnerDocument;
   XmlNode errorRoot = doc.SelectSingleNode("//ValidationErrors");
   XmlElement newError = doc.CreateElement("Error");
   newError.InnerText = err;
   errorRoot.AppendChild(newError);
}

FactCreator Class:

    private object[] objs;

    public FactCreator()
    {

    }
    public object[] CreateFacts(RuleSetInfo ruleSetInfo)
    {
        objs = new object[1];
        objs[0] = new ValidationErrors.ValidationErrors();
        return (objs);
    }

    public Type[] GetFactTypes(RuleSetInfo ruleSetInfo)
    {
        return null;
    }

Solution

  • Have you enabled BRE static support for .NET?

    To enable BRE support for static .Net methods these methods, add a REG_DWORD key named StaticSupport, with a value of 1 to the following registry path:

    32-bit Windows

    HKEY_LOCAL_MACHINE\Software\Microsoft\BusinessRules\3.0\
    

    64-bit Windows

    HKEY_LOCAL_MACHINE\Software\Wow6432Node\Microsoft\BusinessRules\3.0\
    

    This is a one-time activity.

    Above information comes from this blog.

    MSDN extract addition:

    Another option is to put StaticSupport in the BTNTsvc[64].exe.config file, as any settings here override what's in the Registry. Further, one can also make the argument that this option is preferred since it isolates the change in default behavior to BizTalk only, whereas Registry settings are global to the Operating System.