Paul's Petrov Whiteboard

[BizTalk, Enterprise Application Integration, Business Process Automation, SOA, .NET]

  Home  |   Contact  |   Syndication    |   Login
  56 Posts | 1 Stories | 80 Comments | 30 Trackbacks

News

Archives

Post Categories

Image Galleries

BizTalk

Other

If you receive error:

COM object that has been separated from its underlying RCW cannot be used.
The possible cause is invalid or malformed per instance configuration data.

You most likely ran into bug (or undocumented feature) of BizTalk SDK. The problem won't show up until you edit value of component custom properties during deployment configuration. The reason is described below.

When you create custom pipeline component with properties you will override ReadPropertyBag(Microsoft.BizTalk.Component.Interop.IPropertyBag pb, string propName) method of base component class (for example FFDasmComp). In your implementation you must call base.Load(IPropertyBag propertyBag, in errLog) method. The problem stems from implementation this method. It uses DisposableObjectWrapper declared in using{} scope to keep reference of IPropertyBag object. DisposableObjectWrapper is a simple wrapper to handle objects that have to be disposed. In it's own Dispose() method it will call Dispose() of it's member or if the member is a COM object it will call Marshal.ReleaseComObject(object obj). Look what happens if you implemented your ReadPropertyBag method like this:

private object ReadPropertyBag(IPropertyBag pb, string propName)
{  
  base.Load(pb, 0); //<- when this method returns reference to COM object will be lost
  object val = null;
  try
  {
    pb.Read(propName, out val, 0);//<- this line will throw COM Interop exception
  }
  catch (System.ArgumentException)
  {
    return val;
  }
}

To work around this issue just call base.Load() after all your calls to IPropertyBag. This will work fine:

pb.Read(propName, out val, 0);
base.Load(pb, 0)
posted on Tuesday, December 18, 2007 6:58 PM

Feedback

# re: COM error in custom pipeline component 1/15/2008 4:10 PM bouchaet
Just went through the same problem today. Your workaround did worked for me also.

Thanks.

bouchaet

# re: COM error in custom pipeline component 1/17/2008 12:05 PM Paul Petrov
You're welcome, glad it helped.

Post A Comment
Title:
Name:
Email:
Website:
Comment:
Verification: