3

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);
        }
    }
  • I changed the component category to Any and installed the component in the receive pipeline of the same two-way receive port. It clearly doesn't seem to be an issue with the pipeline component because the receive pipeline was able to load the run-time properties but the send pipeline instance of the same component did not. – Mike Crummel Mar 10 '17 at 17:16
  • 1
    Can you show the code for `WritePropertyBag` and `ReadPropertyBag`? – Dan Field Mar 10 '17 at 21:18
  • As Dan mentions, this typically is an error in the propertybag code. – zurebe-pieter Mar 11 '17 at 09:17
  • 1
    Be careful debugging with the component in both the Send and Receive since you can hit Breakpoints from both threads. – Johns-305 Mar 12 '17 at 14:22
  • I added the helper method definitions, but I don't think it has anything to do with the actual property bag code. I would be suspicious of the helper methods as well if the behavior was consistent with both port types, but it appears to only affect the two-way ports. Additionally, we've been using these helper methods for years without incident. – Mike Crummel Mar 12 '17 at 17:06

0 Answers0