I ran in to this problem recently while developing a solution for a client.  For me it took a little while to figure out what was happening and the error was reported to be coming from a send shape that sent a message of type System.Xml.XmlDocument.

While this is the correct place for the error to be raised, it was not strictly related to them message that I was trying to send.

The actual cause of the problem is that I have a class that is used to return information back from a series of helper methods in a library that I have built.  The class has 3 public properties:

  • Result: An inumeration indicatign the level of success
  • Document: when successful, this is an XML document otherwise, it is null.
  • Exception: this is null if the call was successful, otherwise it contains all relevant information to describe the failure.

Document is a System.Xml.XmlDocument and it is this that is causing the error.  Essentially, BizTalk Server seems to be trying to serialize this class, either for dehydration, analyst reporting or some other reason.  All we need to do to avoid this error is simply mark the property as nonserializable, I.e:

/// <summary>
/// Contains the result of a receipt processing attempt.
/// </summary>
[Serializable()]
public class ReceiptResult
{
    private ReceiptSuccessResult _result;
    [NonSerialized()]
    private XmlDocument _document;
    private ReceiptException _exception;

    /// <summary>
    /// Gets the overall result of the validation attempt.
    /// </summary>
    public ReceiptSuccessResult Result
    {
        get { return this._result; }
    }

    /// <summary>
    /// Gets any XML document that may have been returned from the validation attempt.
    /// </summary>
    [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1059:MembersShouldNotExposeCertainConcreteTypes", MessageId = "System.Xml.XmlNode")]
    public XmlDocument Document
    {
        get { return this._document; }
    }

    /// <summary>
    /// Gets any exception that was returned from the validation attempt.
    /// </summary>
    public ReceiptException Exception
    {
        get { return this._exception; }
    }

    public ReceiptResult(ReceiptSuccessResult result)
    {
        this._result = result;
    }

    public ReceiptResult(ReceiptSuccessResult result, XmlDocument document)
    {
        this._result = result;
        this._document = document;
    }

    public ReceiptResult(ReceiptSuccessResult result, ReceiptException exception)
    {
        this._result = result;
        this._exception = exception;
    }
}

After that (for me at least) the error goes away.


Bookmark with :
Digg It! DZone StumbleUpon Technorati Reddit Del.icio.us Newsvine Furl Blinklist
posted @ Tuesday, May 27, 2008 11:44 AM | in BizTalk Server .Net Framework

Comments

No comments posted yet.

Post Comment

Title *
Name *
Email
Url
Comment *  


Please add 8 and 6 and type the answer here: