To see how to run the full server side trace and view the output, please see this article.

In my specific case, I was calling a WCF service that used LINQ to retrieve data from a database and return as a LIST of LINQ objects. When I ran 85 records, it would run, but when I ran 90 it would not, so I knew the issue was size related.

it turns out that the server side trace gave me the more specific error:
System.Runtime.Serialization.SerializationException: Maximum number of items that can be serialized or deserialized in an object graph is ‘65536’.

Note: this is after I already bumped up all the timeouts and the maxBufferPoolSize and the maxReceivedMessage size.

<behavior name=”NewBehavior”>
<dataContractSerializer maxItemsInObjectGraph=”500000″ />
<endpoint address=”” behaviorConfiguration=”NewBehavior”
binding=”basicHttpBinding” contract=”ITest” name=”foo” />

WCF Tracing

Sometimes, you might need to run a full WCF trace (on both the IIS web service, and the client).
The XML in this article will do that and discuss how to view it.

            &lt;source name="System.ServiceModel"
                    switchValue="Information, ActivityTracing"
               &lt;add name="traceListener"
                   initializeData= "c:logTraces.svclog" /&gt;

You can view the file in XML, but it can be a little ugly.

Microsoft has provided a free utility called SVCTraceViewer.exe.
To get this utility, unfortunatley you have to download the Windows developers toolkit.
After you install, it can be found in this directory:
“c:Program FilesMicrosoft SDKsWindowsv6.0ABinSvcTraceViewer.exe”

How to download SvcTraceViewer.exe
Unfortunately, you can not just download the utility standalone.
No, the only way (as far that I know of) to have it, is to install the .NET SDK. The latest version of this SDK is 6.1 and is called ‘Windows SDK for Windows Server 2008 and .NET Framework 3.5’.

This is a huge install. First you have to download a 1,29 GB .ISO on After burning it to DVD or mounting it with a ISO mounting tool (like or running UltraIso or something to turn it into regulary disk files, you can start the setup. To have SvcTraceViewer.exe you only need to select Developer Tools .NET Development Tools.

You can double click to run it, and it opens a Windows program.
You simply open the trace log file you captured above, and it formats it beautifully, with errors in red, and warnings in yellow. You can still see the full XML if you want (for example to copy it to clipboard, a MSDN Forum Post, or an email).

Rules (with static C# routines, such as PolicyChaining, or C# code that adds nodes to the XML), are working fine on XP but not on 2003 (or working on machine and not another). For example, we have a condition of 1=1, which should always fire, but if a static C# routine is found in the actions, then the rules does not fire.

See Richard Seroter’s blog. There is a registry setting that must be set to allow business rules to call a static C# method.

Also note, if you change a C# program, and even re-GAC it, to get the Business Rule Composer to “see” the changes, you have to close and re-open the Business Rule Composer if you are using the test policy feature.

If you download the Policy-Chaining sample for BizTalk, it has an automated way of updating the registry setting. In it’s setup.bat.

@ECHO Setting the StaticSupport registry key to ONE
@REGEDIT /s AddStaticSupport.reg

The AddStaticSupport.reg include the following statements:


System.Net.WebException: Unable to connect to remote server No connection could be made because the target machine actively refused it

For me, this was an easy one, IIS was down.

Other ideas:
1) Check app.exe.config and make sure URL is corect
2) Make sure machine name is correct http://xxxxxxxx or http://localhost

BizTalk Server 2006 is not available or configured. Verify BizTalk Server 2006 on server xxxxx using management database BizTalkMgmtDb is accessible and configured with a compatible version.

This frequently occurs in the company I’m working. All development is done on VMWare virtual machines, when the systems guys do a backup of VMWare “LabManager”, the virtual machine are shutdown and then restarted. For some odd reason, after the restart, SQL frequently does not start (even though it is set as “automatic start”.

To solve the problem, go to System Services, and if SQL is not started, then start it.

How to use TextWriter to file.

            string strOutFileName = @"c:YourDirYourFile.xml";
   ... assumes you have an xmlDoc somewhere
            System.Xml.XmlTextWriter tw = new XmlTextWriter(strOutFileName, System.Text.Encoding.ASCII);

How to initialize an array of objects in C#. Often, we write C# test harnesses to populate some test data based on an object structure (which was ultimately created from an xml structure).

            svcref1.WiringLoanReq req =
                new TMAC.Wiring.UnitTest.CallPublishedOrch.svcref1.WiringLoanReq();
            svcref1.WiringLoanResp resp =
                new TMAC.Wiring.UnitTest.CallPublishedOrch.svcref1.WiringLoanResp();
            svcref1.WiringLoan loan1 =
                new TMAC.Wiring.UnitTest.CallPublishedOrch.svcref1.WiringLoan();
            svcref1.WiringLoan loan2 =
                new TMAC.Wiring.UnitTest.CallPublishedOrch.svcref1.WiringLoan();

            loan1.CadenceLoanId = "0012341234";
            loan1.CadenceLoanId = "0012341235";

            req.WiringLoans = new TMAC.Wiring.UnitTest.CallPublishedOrch.svcref1.WiringLoan[2];
            req.WiringLoans[0] = loan1;
            req.WiringLoans[1] = loan2;

// call the web service
 resp = client.getWiringRequest(req);

How to add an node to an XML Document (via a C# helper that can be called in an expression shape from an orchestration).

First example (uses AppendChild):

        public static XmlDocument AddExceptionNodeToTMXML(XmlDocument TMXMLDocIn, Exception ex)
            // three import fields in System.Exception are ex.Message, ex.StackTrace, ex.Source
            // then there is an Ex.InnerException

            XmlDocument xmlDocNewTMXML = new XmlDocument();
            xmlDocNewTMXML.LoadXml(TMXMLDocIn.OuterXml);  // make sure we don't update the original TMXMLDocIn

            string errMessage = "";
            string errSource = "";
            string errStackTrace = "";
            string xml;

            if (ex.InnerException == null)
                // if not nested exceptions, do not number them.
                errMessage = ex.Message;
                errStackTrace = ex.StackTrace;
                errSource = ex.Source;
                // loop through all the nested exceptions and concatenate them into single long string variables
                System.Exception innerEx = ex;
                int loopCounter = 0;
                while (innerEx != null)
                    // number the nested exceptions
                    string separator = "";
                    if (loopCounter &gt; 1)
                        separator = ";";

                    errMessage = errMessage + separator + "n     Ex:" + loopCounter + ") " + innerEx.Message;
                    errStackTrace = errStackTrace + separator + "n     Ex:" + loopCounter + ") " + innerEx.StackTrace;
                    errSource = errSource + separator + "n     Ex:" + loopCounter + ") " + innerEx.Source;
                    innerEx = innerEx.InnerException;



            // Added CDATA clauses below, because the err fields may have
            // ampersand, less-than, greater than, or other problem characters that cause the xmlDoc.Load to  fail. 
            xml =
                    @"&lt;exs:Exceptions xmlns:exs='http://YourSchemaNamespace.Exceptions'&gt;" +
                    "&lt;ex:Exception index='1' id='1' type='' xmlns:ex='http://YourSchemaNamespace.Exception'&gt;" +
                    "  &lt;messageText&gt;&lt;![CDATA[" + errMessage + "]]&gt;&lt;/messageText&gt;" +
                    "  &lt;source&gt;&lt;![CDATA[" + errSource + "]]&gt;&lt;/source&gt;" +
                    "  &lt;stackTrace&gt;&lt;![CDATA[" + errStackTrace + "]]&gt;&lt;/stackTrace&gt;" +
                    "&lt;/ex:Exception&gt;" +

            XmlDocument exceptionXML = new XmlDocument();

            string strXPathRoot = "/*[local-name()='TMXML' and namespace-uri()='http://YourSchemaNamespace.MainSchema']";
            XmlNode nodeTMXML = xmlDocNewTMXML.SelectSingleNode(strXPathRoot);

            string strExXPathRoot = "/*[local-name()='Exceptions' and namespace-uri()='http://YourSchemaNamespace.Exceptions']";
            XmlNode nodeExceptions = exceptionXML.SelectSingleNode(strExXPathRoot);

            nodeTMXML.AppendChild(xmlDocNewTMXML.ImportNode(nodeExceptions, true));

            return xmlDocNewTMXML;



Second example (uses CreateElement)


	// This can be called from a BusinessRule which passes a TypedXmlDocument
	// instead of a normal XmlDocument
	public static void AddItineraryStep(TypedXmlDocument txd, string stepName, string activityPolicy)

                  // can we find the XPath  indicate d?
                  string strXPathRoot = "//*[local-name()='ItinerarySteps']";
                  XmlNode node = LocateXPath(txd, strXPathRoot);
                  if (null == node)
                      throw new Exception("AddItineraryStep: XPath did not return a valid node, XPath=" +
                          strXPathRoot + "  XML=" + txd.Document.OuterXml);

                  // determine the root node for the document
                  // if the XPath selects the TXD, it will have no root if it is an XmlDocument
                  // in that case, simply use the document from the TXD
                  XmlDocument root = node.OwnerDocument;
                  if (null == root)
                        // if the XPath selects the TXD, it may
                        // so fix accordingly
                        root = txd.Document as XmlDocument;
                        if (null == root) return;

                  // create a new node and add it in
                  string nodeName = "ItineraryStep";
                  XmlElement newNode = root.CreateElement(nodeName);

                  // Not sure why ImportNode not available. Seems like it would be easier
                  //node.AppendChild(txd.Document.ImportNode(nodeItineraryStep, true));

                  //strXPathRoot = "/*[local-name()='Header']/*[local-name()='Itinerary']/*[local-name()='ItineraryStep']";
                  strXPathRoot = "//*[local-name()='ItineraryStep']";
                  node = LocateXPath(txd, strXPathRoot);
                  if (null == node)
                      throw new Exception("AddItineraryItem: XPath did not return a valid node, XPath=" +
                          strXPathRoot + "  XML=" + txd.Document.OuterXml);

                  XmlElement newSubNode;

                  nodeName = "name";
                  newSubNode = root.CreateElement(nodeName);
                  newSubNode.InnerText = stepName;

                  nodeName = "status";
                  newSubNode = root.CreateElement(nodeName);
                  newSubNode.InnerText = "PENDING";

                  nodeName = "errorType";
                  newSubNode = root.CreateElement(nodeName);
                  // leave value to empty-string (no need to set InnerText)

                  nodeName = "activityPolicy";
                  newSubNode = root.CreateElement(nodeName);
                  newSubNode.InnerText = activityPolicy;


        internal static XmlNode LocateXPath(TypedXmlDocument txd, string xPath)
            // does the TXD contain a node?
            XmlNode parent = txd.Document;
            if (null == parent) return null;

            // is there an XPath specified? if not, return the parent
            if ((xPath == null) || (xPath == string.Empty)) return parent;

            // return the first node that the XPath points to
            return parent.SelectSingleNode(xPath, txd.NamespaceManager);


Get 404 page not found when browsing a web service you know is there.
For example, from IIS you right-click and select “Browse” on the .svc file (so you know it is really there). NOTE: the 404 is a “red herring” an outright lie – a bad error given to us by Microsoft to confuse us.

Try checking to see if you have ASP.NET 1.1 instead of 2.0 set.
Right click your “virtual directory”, then click the “ASP.NET” tab.
.NET 2.0 and 3.5 use the same “CLR”, therefore you will see 2.0.50727 in the
ASP.NET version on this tab. If you see 1.x, then change it to 2.0.50727.

From IIS Admin, right-click the project, …

If and when you get this error on Windows 2003, there is an additional setup required.
Click “Web Service Extensions” at the bottom of IIS, and check the “ASP.NET V2.0.50727” and see if is is “allowed” instead of “prohibited”.

If you get “service unavailable”, then make sure the userid that is running your application pool (Win 2003/IIS 6) is a member of the “IIS_WPG” (IIS worker process group) and that the password is correct.

Bug Scenario: You are using C# variable in Mapping Functoids.
You run a map through “Test Map” and it works fine each time.

You run a file through a receive location, running the same map. Works great first time, but second time it maps nothing (or behaves differently). When you restart BizTalk Host Instance, it works fine first time, but not second time.

Why are we using a variable in the first place? The ideas was to map a field just one time (in a loop). So once the field is mapped, we need to set a flag not to map it again.

What is the bug in the following code?

public static bool gotCoborrowerLastname = false;

public static string CoborrowerLastname (string param1)
     string result = "false";
     if (param1.ToUpper() == "TRUE" && !gotCoborrowerLastname)
                gotCoborrowerLastname = true;
            	result = "true";

      return result;

The “static” keyword must be removed from the global variable. By making it static, only one copy of the variable is held in memory. Thus, the variable stays set to the last value, even when you run a new map. The variable does not get reset until you restart the BizTalk Host instance.

public bool gotCoborrowerLastname = false;