BizTalk Custom Pipeline Component doesn't load overridden properties

833 Views Asked by At

I have a custom BizTalk 2013 R2 pipeline component that has several design-time properties defined. For some reason, BizTalk will load the design-time property values set in the VS pipeline designer but it ignores run-time values set in the BizTalk Admin Console. My component implements IPersistPropertyBag and I have verified that it is not throwing any exceptions.

While debugging the pipeline (attached to Isolated Host Instance), I noticed that BizTalk is only calling the Load method when the pipeline is instantiated. This only loads the VS designer values and BizTalk is supposed to then call the Load method again before calling Execute. Unfortunately, this is not happening.

[Edit] I did some more debugging and figured out that this only seems to be happening on the send pipeline for a two-way receive port. The receive pipeline loads both the design-time and run-time properties as expected.

Here is a sample of my code:

[ComponentCategory(CategoryTypes.CATID_PipelineComponent)]
[ComponentCategory(CategoryTypes.CATID_Encoder)]
[System.Runtime.InteropServices.Guid(COMPONENT_GUID)]
public class RhapsodyMessageEncoder : BasePipelineComponent, IBaseComponent, IComponentUI, 
    IPersistPropertyBag, Microsoft.BizTalk.Component.Interop.IComponent
{
...
    public void Load(IPropertyBag propertyBag, int errorLog)
    {
        try
        {
            this.Enabled = Convert.ToBoolean(this.ReadPropertyBag(propertyBag, "Enabled"));
            this.UsernameSSOKey = this.ReadPropertyBag(propertyBag, "UsernameSSOKey") as string;
            this.PasswordSsoKey = this.ReadPropertyBag(propertyBag, "PasswordSsoKey") as string;
            this.AffiliateAppName = this.ReadPropertyBag(propertyBag, "AffiliateAppName") as string;
        }
        catch (Exception e) { this.WriteErrorLog(e); }
    }

    public void Save(IPropertyBag propertyBag, bool clearDirty, bool saveAllProperties)
    {
        try
        {
            this.WritePropertyBag(propertyBag, "Enabled", this.Enabled);
            this.WritePropertyBag(propertyBag, "UsernameSSOKey", this.UsernameSSOKey);
            this.WritePropertyBag(propertyBag, "PasswordSsoKey", this.PasswordSsoKey);
            this.WritePropertyBag(propertyBag, "AffiliateAppName", this.AffiliateAppName);
        }
        catch (Exception e) { this.WriteErrorLog(e); }
    }
...
}

Read / Write Property bag helper methods:

    protected virtual object ReadPropertyBag(IPropertyBag pb, string propName)
    {
        PropertyInfo pInfo = this.GetType().GetProperty(propName);
        object currentValue = null;
        object val = null;

        if (pInfo != null)
            currentValue = pInfo.GetValue(this, null);

        try
        {
            pb.Read(propName, out val, 0);
        }
        catch (System.ArgumentException e)
        {
            System.Diagnostics.Trace.WriteLine(
                "Argument Exception encountered: " + e.Message,
                this.Name
            );
        }
        catch (System.Exception e)
        {
            throw new System.ApplicationException("Can't read design time Properties", e);
        }

        return val ?? currentValue;
    }

    protected virtual void WritePropertyBag(IPropertyBag pb, string propName, object val)
    {
        try
        {
            object obj = val;
            pb.Write(propName, ref obj);
        }
        catch (System.Exception e)
        {
            throw new System.ApplicationException("Can't write design time properties", e);
        }
    }
0

There are 0 best solutions below