Geeks With Blogs
Paul's Petrov Whiteboard [BizTalk, Enterprise Application Integration, Business Process Automation, SOA, .NET]

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 .Net , BizTalk | Back to top


Comments on this post: COM error in custom pipeline component

# re: COM error in custom pipeline component
Requesting Gravatar...
Just went through the same problem today. Your workaround did worked for me also.

Thanks.

bouchaet
Left by bouchaet on Jan 15, 2008 4:10 PM

# re: COM error in custom pipeline component
Requesting Gravatar...
You're welcome, glad it helped.
Left by Paul Petrov on Jan 17, 2008 12:05 PM

Your comment:
 (will show your gravatar)


Copyright © Paul Petrov | Powered by: GeeksWithBlogs.net