<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pingback="http://madskills.com/public/xml/rss/module/pingback/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:georss="http://www.georss.org/georss" xmlns:dc="http://purl.org/dc/elements/1.1/" version="2.0">
  <channel>
    <title>Scott Klueppel's Blog - C#</title>
    <link>http://offroadcoder.com/</link>
    <description>making the hard line look easy</description>
    <language>en-us</language>
    <copyright>Scott Klueppel</copyright>
    <lastBuildDate>Tue, 27 Jul 2010 03:32:07 GMT</lastBuildDate>
    <generator>newtelligence dasBlog 2.1.8102.813</generator>
    <managingEditor>me@offroadcoder.com</managingEditor>
    <webMaster>me@offroadcoder.com</webMaster>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=fb59ebf8-4230-43f8-9226-b02389165fc1</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,fb59ebf8-4230-43f8-9226-b02389165fc1.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,fb59ebf8-4230-43f8-9226-b02389165fc1.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=fb59ebf8-4230-43f8-9226-b02389165fc1</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In .NET 1.1, I tried the original MS Data Access Application Block’s SqlHelper (you
can still download it <a href="http://download.microsoft.com/download/VisualStudioNET/daabref/RTM/NT5/EN-US/DataAccessApplicationBlock.msi">here</a>).
It was great for most of the common uses, but was lacking in some areas. The consuming
code looked sloppy and encouraged blind faith that database objects never changed.
It also didn’t support transactions as I would have liked, and didn’t support my obsession
with custom entities. I started out writing an extension library that wrapped SqlHelper,
but that felt very wrong… wrapping the ADO.NET wrapper (SqlHelper). I ended up writing
my own version of SqlHelper called SqlHelper (nice name, eh?). You see, at this time
I was getting over a bad relationship with a series of ORM products that had a negative
effect on my productivity. I decided to revolt with good ol’ fashion data access methods
that have never let us down.
</p>
        <p>
The only thing worse than my ORM experience was the disgusting over-use of DataSet
and DataTable. For my dollar, DataReader is where it’s at. I agree that using the
reader is slightly more dangerous in the hands of an inexperienced or inattentive
developer (did you know you have to close the reader when you’re done with it??).
Nothing can compare with the speed and flexibility of the reader, which is why DataSet
and DataAdapter use it at their core. If you are working with custom entities, instead
of DataSets and DataTables, you would be crazy to not use the DataReader.
</p>
        <p>
My SqlHelper worked in conjunction with my DataAccessLayer class that defined a few
delegates that made reader-to-object-mapping a simple task.  Once the mapping
methods were written to be used with the delegates, which returned object or System.Collections.CollectionBase
because we did not yet have generics (can you imagine??), you simply called the SqlHelper
to do all of the hard work. SqlHelper did not implement all of the craziness that
the original version contained. It was a short 450 lines of code that did nothing
but access data in a safe and reliable way. In the example below, we have the GenerateDocumentFromReader
method that is used by the GenerateObjectFromReader delegate. When SqlHelper.ExecuteReaderCmd
is called, the delegate is passed in to map the reader results to my object… in this
case a Document.
</p>
        <pre class="brush: c#;">// Object generation method 
private static object GenerateDocumentFromReader(IDataReader returnData) 
{
     Document document = new Document();
     if (returnData.Read())
     {
         document = new Document(
             (int)returnData["DocumentId"],
             (byte[])returnData["DocumentBinary"],
             returnData["FileName"].ToString(),
             returnData["Description"].ToString(),
             returnData["ContentType"].ToString(),
             (int)returnData["FileSize"],
             returnData["MD5Sum"].ToString(),
             (bool) returnData["EnabledInd"],
             (int)returnData["CreatorEmpId"],
             Convert.ToDateTime(returnData["CreateDt"]),
             (int)returnData["LastUpdateEmpId"],
             Convert.ToDateTime(returnData["LastUpdateDt"]));
     }     return document;
} 
public static Document GetDocumentByDocumentId(int documentId)
{
     SqlCommand sqlCmd = new SqlCommand();
     SqlHelper.SetCommandArguments(sqlCmd, CommandType.StoredProcedure, "usp_Document_GetDocumentByDocumentId");
     SqlHelper.AddParameterToSqlCommand(sqlCmd, "@DocumentId", SqlDbType.Int, 0, ParameterDirection.Input, documentId);
     DataAccessLayer.GenerateObjectFromReader gofr = new DataAccessLayer.GenerateObjectFromReader(GenerateDocumentFromReader);
     Document document = SqlHelper.ExecuteReaderCmd(sqlCmd, gofr) as Document;
     return document;
}
</pre>
        <p>
This worked wonderfully for years. After converting, I couldn’t imagine a project
that used ORM, DataSets, or DataTables again. I’ve been on many 1.1 projects since
writing my SqlHelper in 2004, and I have successfully converted them all. In early
2006, MS graced us with .NET 2.0. Generics, System.Transactions, and partial classes
changed my life. In my first few exposures to generics, like Vinay “the Generic Guy”
Ahuja’s 2005 Jax Code Camp presentation and Juval “My Hero” Lowy’s <a href="http://msdn.microsoft.com/en-us/library/ms379564">MSDN
article “An Introduction to Generics”</a>, I listened/read and pondered the millions
of uses of generics. I adapted my SqlHelper heavily to use these new technologies
and morphed it into something else that closely represented the newest version of
the DAAB, Enterprise Library 3.
</p>
        <p>
By this point, I wanted to convert to Enterprise Library. It was far better than the
simple SqlHelper. It had better transaction support, though I don’t know if that included
System.Transactions. I could have put my object generation extensions on top of it
and it would have worked well for years. On home projects I had already converted
to use EntLib. At work I was not so lucky. The deep stack trace when something went
wrong scared everyone, and that is still a fear for those starting out in EntLib today.
To ease the fears, I just created my replacement to SqlHelper… the Database class. 
</p>
        <p>
I used a lot of the same naming conventions as Enterprise Library. In fact, much of
the consuming code was nearly identical (except for the fact that it did not implement
the provider pattern and worked only with SQL Server). This was in anticipation of
a quick adoption of Enterprise Library 3 in the workplace. Kind of a “see… not so
bad” move on my part. Just like EntLib, you created a Database class using the DatabaseFactory
that used your default connection string key. Commands and parameters were created
and added with methods off of the Database class. Aside from the SqlCommand/DbCommand,
everything looked and felt the same, but came in a small file with only 490 lines
of code instead of 5 or more projects with 490 files. Using it felt the same, too.
Only my object/collection generation extensions looked different from the standard
reader, scalar, dataset routines. Below is the same code from above using the Database
class and related classes to create a Document from a reader.
</p>
        <pre class="brush: c#;">// Object generation method
private static Document GenerateDocumentFromReader(IDataReader returnData)
{
     Document document = new Document();
     if (returnData.Read())
     {
         document = new Document(
             GetIntFromReader(returnData, "DocumentId"),
             GetIntFromReader(returnData, "DocumentTypeId"),
             GetStringFromReader(returnData, "DocumentTypeName"),
             GetByteArrayFromReader(returnData, "DocumentBinary"),
             GetStringFromReader(returnData, "FileName"),
             GetStringFromReader(returnData, "Description"),
             GetStringFromReader(returnData, "ContentType"),
             GetIntFromReader(returnData, "FileSize"),
             GetStringFromReader(returnData, "MD5Sum"),
             GetStringFromReader(returnData, "CreatorEmpID"),
             GetDateTimeFromReader(returnData, "CreateDt"),
             GetStringFromReader(returnData, "LastUpdateEmpID"),
             GetDateTimeFromReader(returnData, "LastUpdateDt"));
     }
     return document;
} 
public static Document GetDocumentByDocumentId(int documentId)
{
     Database db = DatabaseFactory.CreateDatabase(AppSettings.ConnectionStringKey);
     SqlCommand sqlCmd = db.GetStoredProcCommand("usp_Document_GetDocumentByDocumentId");
     db.AddInParameter(sqlCmd, "DocumentId", SqlDbType.Int, documentId);
     GenerateObjectFromReader&lt;Document&gt; gofr = new GenerateObjectFromReader&lt;Document&gt;(GenerateDocumentFromReader);
     Document document = CreateObjectFromDatabase&lt;Document&gt;(db, sqlCmd, gofr);
     return document;
}
</pre>
        <p>
This, too, worked great for years. Other than a brief period in 2007 when I tried
to wrap all of my data access code with WCF services, .NET 3.0 came and went with
no changes to my data access methodology. In late 2007, I had lost all love of my
SqlHelper and my Database/DataAccessLayer classes. With .NET 3.5 and Enterprise Library
4.0, I no longer felt the need to roll my own. .NET now had extension methods for
me to extend Enterprise Library however I pleased. Enterprise Library supported System.Transactions
making its use a dream if behind a WCF service that allowed transaction flow. With
a succinct 190 lines of extension code, I had it made in the shade with Enterprise
Library 4.0. In fact, I haven’t used anything since.
</p>
        <p>
The consuming code was almost exactly the same. You’ll notice the SqlCommand has changed
to DbCommand. The SqlDbType has changed to DbType. Other than that, it feels and works
the same. 
</p>
        <pre class="brush: c#;">// Object generation method
private static Document GenerateDocumentFromReader(IDataReader returnData)
{
     Document document = new Document();
     if (returnData.Read())
     {
         document = new Document(
             returnData.GetInt32("DocumentId"),
             returnData.GetInt32("DocumentTypeId"),
             returnData.GetString("DocumentTypeName"),
             returnData.GetByteArray("DocumentBinary"),
             returnData.GetString("FileName"),
             returnData.GetString("Description"),
             returnData.GetString("ContentType"),
             returnData.GetInt32("FileSize"),
             returnData.GetString("MD5Sum"),
             returnData.GetString("CreatorEmpID"),
             returnData.GetDateTime("CreateDt"),
             returnData.GetString("LastUpdateEmpID"),
             returnData.GetDateTime("LastUpdateDt"));
     }
     return document;
}
public static Document GetDocumentByDocumentID(int documentId)
{
     Database db = DatabaseFactory.CreateDatabase();
     DbCommand cmd = db.GetStoredProcCommand("usp_Document_GetDocumentByDocumentId");
     db.AddInParameter(cmd, "DocumentID", DbType.Int32, documentId);
     GenerateObjectFromReader&lt;Document&gt; gofr = new GenerateObjectFromReader&lt;Document&gt;(GenerateDocumentFromReader);
     Document document = db.CreateObject&lt;Document&gt;(cmd, gofr);
     return document;
}
</pre>
        <p>
With a full suite of unit test projects available for download with the Enterprise
Library source files, the fear should be abated for the remaining holdouts. Getting
started is as easy as including two DLL references, and adding 5 lines of config.
You can’t beat that!
</p>
        <p>
I downloaded Enterprise Library 5 last week. I’ve been making use of new features
such as result set mapping (eliminating the need for my object generation extensions),
parameter mapping, and accessors that bring them all together. There’s a bunch of
inversion of control features in place as well. I think I’ll be quite comfortable
in my new EntLib5 home.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=fb59ebf8-4230-43f8-9226-b02389165fc1" />
      </body>
      <title>My data access story before Enterprise Library 5</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,fb59ebf8-4230-43f8-9226-b02389165fc1.aspx</guid>
      <link>http://offroadcoder.com/2010/07/27/MyDataAccessStoryBeforeEnterpriseLibrary5.aspx</link>
      <pubDate>Tue, 27 Jul 2010 03:32:07 GMT</pubDate>
      <description>&lt;p&gt;
In .NET 1.1, I tried the original MS Data Access Application Block’s SqlHelper (you
can still download it &lt;a href="http://download.microsoft.com/download/VisualStudioNET/daabref/RTM/NT5/EN-US/DataAccessApplicationBlock.msi"&gt;here&lt;/a&gt;).
It was great for most of the common uses, but was lacking in some areas. The consuming
code looked sloppy and encouraged blind faith that database objects never changed.
It also didn’t support transactions as I would have liked, and didn’t support my obsession
with custom entities. I started out writing an extension library that wrapped SqlHelper,
but that felt very wrong… wrapping the ADO.NET wrapper (SqlHelper). I ended up writing
my own version of SqlHelper called SqlHelper (nice name, eh?). You see, at this time
I was getting over a bad relationship with a series of ORM products that had a negative
effect on my productivity. I decided to revolt with good ol’ fashion data access methods
that have never let us down.
&lt;/p&gt;
&lt;p&gt;
The only thing worse than my ORM experience was the disgusting over-use of DataSet
and DataTable. For my dollar, DataReader is where it’s at. I agree that using the
reader is slightly more dangerous in the hands of an inexperienced or inattentive
developer (did you know you have to close the reader when you’re done with it??).
Nothing can compare with the speed and flexibility of the reader, which is why DataSet
and DataAdapter use it at their core. If you are working with custom entities, instead
of DataSets and DataTables, you would be crazy to not use the DataReader.
&lt;/p&gt;
&lt;p&gt;
My SqlHelper worked in conjunction with my DataAccessLayer class that defined a few
delegates that made reader-to-object-mapping a simple task.&amp;nbsp; Once the mapping
methods were written to be used with the delegates, which returned object or System.Collections.CollectionBase
because we did not yet have generics (can you imagine??), you simply called the SqlHelper
to do all of the hard work. SqlHelper did not implement all of the craziness that
the original version contained. It was a short 450 lines of code that did nothing
but access data in a safe and reliable way. In the example below, we have the GenerateDocumentFromReader
method that is used by the GenerateObjectFromReader delegate. When SqlHelper.ExecuteReaderCmd
is called, the delegate is passed in to map the reader results to my object… in this
case a Document.
&lt;/p&gt;
&lt;pre class="brush: c#;"&gt;// Object generation method 
private static object GenerateDocumentFromReader(IDataReader returnData) 
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Document document = new Document();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (returnData.Read())
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; document = new Document(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (int)returnData["DocumentId"],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (byte[])returnData["DocumentBinary"],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData["FileName"].ToString(),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData["Description"].ToString(),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData["ContentType"].ToString(),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (int)returnData["FileSize"],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData["MD5Sum"].ToString(),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (bool) returnData["EnabledInd"],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (int)returnData["CreatorEmpId"],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Convert.ToDateTime(returnData["CreateDt"]),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (int)returnData["LastUpdateEmpId"],
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Convert.ToDateTime(returnData["LastUpdateDt"]));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return document;
} 
public static Document GetDocumentByDocumentId(int documentId)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SqlCommand sqlCmd = new SqlCommand();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SqlHelper.SetCommandArguments(sqlCmd, CommandType.StoredProcedure, "usp_Document_GetDocumentByDocumentId");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SqlHelper.AddParameterToSqlCommand(sqlCmd, "@DocumentId", SqlDbType.Int, 0, ParameterDirection.Input, documentId);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DataAccessLayer.GenerateObjectFromReader gofr = new DataAccessLayer.GenerateObjectFromReader(GenerateDocumentFromReader);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Document document = SqlHelper.ExecuteReaderCmd(sqlCmd, gofr) as Document;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return document;
}
&lt;/pre&gt;
&lt;p&gt;
This worked wonderfully for years. After converting, I couldn’t imagine a project
that used ORM, DataSets, or DataTables again. I’ve been on many 1.1 projects since
writing my SqlHelper in 2004, and I have successfully converted them all. In early
2006, MS graced us with .NET 2.0. Generics, System.Transactions, and partial classes
changed my life. In my first few exposures to generics, like Vinay “the Generic Guy”
Ahuja’s 2005 Jax Code Camp presentation and Juval “My Hero” Lowy’s &lt;a href="http://msdn.microsoft.com/en-us/library/ms379564"&gt;MSDN
article “An Introduction to Generics”&lt;/a&gt;, I listened/read and pondered the millions
of uses of generics. I adapted my SqlHelper heavily to use these new technologies
and morphed it into something else that closely represented the newest version of
the DAAB, Enterprise Library 3.
&lt;/p&gt;
&lt;p&gt;
By this point, I wanted to convert to Enterprise Library. It was far better than the
simple SqlHelper. It had better transaction support, though I don’t know if that included
System.Transactions. I could have put my object generation extensions on top of it
and it would have worked well for years. On home projects I had already converted
to use EntLib. At work I was not so lucky. The deep stack trace when something went
wrong scared everyone, and that is still a fear for those starting out in EntLib today.
To ease the fears, I just created my replacement to SqlHelper… the Database class. 
&lt;/p&gt;
&lt;p&gt;
I used a lot of the same naming conventions as Enterprise Library. In fact, much of
the consuming code was nearly identical (except for the fact that it did not implement
the provider pattern and worked only with SQL Server). This was in anticipation of
a quick adoption of Enterprise Library 3 in the workplace. Kind of a “see… not so
bad” move on my part. Just like EntLib, you created a Database class using the DatabaseFactory
that used your default connection string key. Commands and parameters were created
and added with methods off of the Database class. Aside from the SqlCommand/DbCommand,
everything looked and felt the same, but came in a small file with only 490 lines
of code instead of 5 or more projects with 490 files. Using it felt the same, too.
Only my object/collection generation extensions looked different from the standard
reader, scalar, dataset routines. Below is the same code from above using the Database
class and related classes to create a Document from a reader.
&lt;/p&gt;
&lt;pre class="brush: c#;"&gt;// Object generation method
private static Document GenerateDocumentFromReader(IDataReader returnData)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Document document = new Document();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (returnData.Read())
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; document = new Document(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetIntFromReader(returnData, "DocumentId"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetIntFromReader(returnData, "DocumentTypeId"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetStringFromReader(returnData, "DocumentTypeName"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetByteArrayFromReader(returnData, "DocumentBinary"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetStringFromReader(returnData, "FileName"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetStringFromReader(returnData, "Description"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetStringFromReader(returnData, "ContentType"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetIntFromReader(returnData, "FileSize"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetStringFromReader(returnData, "MD5Sum"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetStringFromReader(returnData, "CreatorEmpID"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetDateTimeFromReader(returnData, "CreateDt"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetStringFromReader(returnData, "LastUpdateEmpID"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GetDateTimeFromReader(returnData, "LastUpdateDt"));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return document;
} 
public static Document GetDocumentByDocumentId(int documentId)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Database db = DatabaseFactory.CreateDatabase(AppSettings.ConnectionStringKey);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; SqlCommand sqlCmd = db.GetStoredProcCommand("usp_Document_GetDocumentByDocumentId");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; db.AddInParameter(sqlCmd, "DocumentId", SqlDbType.Int, documentId);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GenerateObjectFromReader&amp;lt;Document&amp;gt; gofr = new GenerateObjectFromReader&amp;lt;Document&amp;gt;(GenerateDocumentFromReader);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Document document = CreateObjectFromDatabase&amp;lt;Document&amp;gt;(db, sqlCmd, gofr);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return document;
}
&lt;/pre&gt;
&lt;p&gt;
This, too, worked great for years. Other than a brief period in 2007 when I tried
to wrap all of my data access code with WCF services, .NET 3.0 came and went with
no changes to my data access methodology. In late 2007, I had lost all love of my
SqlHelper and my Database/DataAccessLayer classes. With .NET 3.5 and Enterprise Library
4.0, I no longer felt the need to roll my own. .NET now had extension methods for
me to extend Enterprise Library however I pleased. Enterprise Library supported System.Transactions
making its use a dream if behind a WCF service that allowed transaction flow. With
a succinct 190 lines of extension code, I had it made in the shade with Enterprise
Library 4.0. In fact, I haven’t used anything since.
&lt;/p&gt;
&lt;p&gt;
The consuming code was almost exactly the same. You’ll notice the SqlCommand has changed
to DbCommand. The SqlDbType has changed to DbType. Other than that, it feels and works
the same. 
&lt;/p&gt;
&lt;pre class="brush: c#;"&gt;// Object generation method
private static Document GenerateDocumentFromReader(IDataReader returnData)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Document document = new Document();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if (returnData.Read())
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; document = new Document(
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetInt32("DocumentId"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetInt32("DocumentTypeId"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetString("DocumentTypeName"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetByteArray("DocumentBinary"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetString("FileName"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetString("Description"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetString("ContentType"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetInt32("FileSize"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetString("MD5Sum"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetString("CreatorEmpID"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetDateTime("CreateDt"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetString("LastUpdateEmpID"),
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; returnData.GetDateTime("LastUpdateDt"));
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return document;
}
public static Document GetDocumentByDocumentID(int documentId)
{
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Database db = DatabaseFactory.CreateDatabase();
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DbCommand cmd = db.GetStoredProcCommand("usp_Document_GetDocumentByDocumentId");
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; db.AddInParameter(cmd, "DocumentID", DbType.Int32, documentId);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; GenerateObjectFromReader&amp;lt;Document&amp;gt; gofr = new GenerateObjectFromReader&amp;lt;Document&amp;gt;(GenerateDocumentFromReader);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Document document = db.CreateObject&amp;lt;Document&amp;gt;(cmd, gofr);
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; return document;
}
&lt;/pre&gt;
&lt;p&gt;
With a full suite of unit test projects available for download with the Enterprise
Library source files, the fear should be abated for the remaining holdouts. Getting
started is as easy as including two DLL references, and adding 5 lines of config.
You can’t beat that!
&lt;/p&gt;
&lt;p&gt;
I downloaded Enterprise Library 5 last week. I’ve been making use of new features
such as result set mapping (eliminating the need for my object generation extensions),
parameter mapping, and accessors that bring them all together. There’s a bunch of
inversion of control features in place as well. I think I’ll be quite comfortable
in my new EntLib5 home.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=fb59ebf8-4230-43f8-9226-b02389165fc1" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,fb59ebf8-4230-43f8-9226-b02389165fc1.aspx</comments>
      <category>C#</category>
      <category>Database</category>
      <category>Enterprise Library</category>
      <category>Extensions</category>
      <category>SQL</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=88ec2d3e-12d8-4fa0-b1d4-e82f7d6c677e</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,88ec2d3e-12d8-4fa0-b1d4-e82f7d6c677e.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,88ec2d3e-12d8-4fa0-b1d4-e82f7d6c677e.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=88ec2d3e-12d8-4fa0-b1d4-e82f7d6c677e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Despite its pitiful adoption in the developer community, I am implementing Transactional
NTFS (TxF) transactions using the Microsoft.KtmIntegration.TransactedFile class. This
allows me to reap the benefits of TransactionScope and distributed transactions for
file operations (e.g. creates, updates, deletes). This is the only missing piece for
typical transactional business applications. With the “KTM” and “KtmRm for Distributed
Transactions” services, available only on Vista, Windows 7, and Windows Server 2008,
file operations will roll back if the TransactionScope is not completed. 
</p>
        <p>
There’s just one problem… Transactional NTFS does not work with file shares. I can’t
remember the last time I put a “C:\FileStore” reference in a config file. A friendly
share like “\\server\FileStore” is always preferred, especially since DFS came about.
Attempting to use a share results in the following error message: 
</p>
        <blockquote>
          <p>
            <font color="#000080" size="2" face="Consolas">The remote server or share does not
support transacted file operations</font>
          </p>
        </blockquote>
        <p>
Don’t read this as “your remote server” or “your remote share”, but rather “all remote
servers and shares”. As mentioned in <a href="      http://msdn.microsoft.com/en-us/library/aa365738(v=VS.85).aspx" target="_blank">this
MSDN article</a>, TxF is not supported by the CIFS/SMB protocols. The error was probably
written with the expectation that one day some remote servers and shares would support
TxF. I emailed Microsoft about it and received a response fairly quickly. The response
was simply: 
</p>
        <blockquote>
          <p>
“We understand the need and have plans to eventually support TxF over SMB2, but we’re
not there yet and are not ready to announce if or when this will be supported. When
it is the documentation will be updated.”
</p>
        </blockquote>
        <p>
I’m not getting my hopes up, but Windows Server 2011 looks to be our only hope before
.NET changes beyond recognition and TxF is a distant memory. Until then, I wrapped
up all of my TxF code in a WCF service and install that service on the server with
the <em>FileStore</em> folder. 
</p>
        <p>
MSDN article – When to Use Transactional NTFS 
</p>
        <p>
      <a href="http://msdn.microsoft.com/en-us/library/aa365738(v=VS.85).aspx">http://msdn.microsoft.com/en-us/library/aa365738(v=VS.85).aspx</a></p>
        <p>
TxF Sandbox – Sample Projects (including Microsoft.KtmIntegration.TransactedFile) 
</p>
        <p>
      <a href="http://offroadcoder.com/content/binary/TxFSandbox.zip">TxFSandbox.zip</a></p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=88ec2d3e-12d8-4fa0-b1d4-e82f7d6c677e" />
      </body>
      <title>The remote server or share does not support transacted file operations</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,88ec2d3e-12d8-4fa0-b1d4-e82f7d6c677e.aspx</guid>
      <link>http://offroadcoder.com/2010/05/08/TheRemoteServerOrShareDoesNotSupportTransactedFileOperations.aspx</link>
      <pubDate>Sat, 08 May 2010 15:32:25 GMT</pubDate>
      <description>&lt;p&gt;
Despite its pitiful adoption in the developer community, I am implementing Transactional
NTFS (TxF) transactions using the Microsoft.KtmIntegration.TransactedFile class. This
allows me to reap the benefits of TransactionScope and distributed transactions for
file operations (e.g. creates, updates, deletes). This is the only missing piece for
typical transactional business applications. With the “KTM” and “KtmRm for Distributed
Transactions” services, available only on Vista, Windows 7, and Windows Server 2008,
file operations will roll back if the TransactionScope is not completed. 
&lt;p&gt;
There’s just one problem… Transactional NTFS does not work with file shares. I can’t
remember the last time I put a “C:\FileStore” reference in a config file. A friendly
share like “\\server\FileStore” is always preferred, especially since DFS came about.
Attempting to use a share results in the following error message: &lt;blockquote&gt; 
&lt;p&gt;
&lt;font color="#000080" size="2" face="Consolas"&gt;The remote server or share does not
support transacted file operations&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Don’t read this as “your remote server” or “your remote share”, but rather “all remote
servers and shares”. As mentioned in &lt;a href="      http://msdn.microsoft.com/en-us/library/aa365738(v=VS.85).aspx" target="_blank"&gt;this
MSDN article&lt;/a&gt;, TxF is not supported by the CIFS/SMB protocols. The error was probably
written with the expectation that one day some remote servers and shares would support
TxF. I emailed Microsoft about it and received a response fairly quickly. The response
was simply: &lt;blockquote&gt; 
&lt;p&gt;
“We understand the need and have plans to eventually support TxF over SMB2, but we’re
not there yet and are not ready to announce if or when this will be supported. When
it is the documentation will be updated.”
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I’m not getting my hopes up, but Windows Server 2011 looks to be our only hope before
.NET changes beyond recognition and TxF is a distant memory. Until then, I wrapped
up all of my TxF code in a WCF service and install that service on the server with
the &lt;em&gt;FileStore&lt;/em&gt; folder. 
&lt;p&gt;
MSDN article – When to Use Transactional NTFS 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="http://msdn.microsoft.com/en-us/library/aa365738(v=VS.85).aspx"&gt;http://msdn.microsoft.com/en-us/library/aa365738(v=VS.85).aspx&lt;/a&gt; 
&lt;p&gt;
TxF Sandbox – Sample Projects (including Microsoft.KtmIntegration.TransactedFile) 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="http://offroadcoder.com/content/binary/TxFSandbox.zip"&gt;TxFSandbox.zip&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=88ec2d3e-12d8-4fa0-b1d4-e82f7d6c677e" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,88ec2d3e-12d8-4fa0-b1d4-e82f7d6c677e.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>MSDTC</category>
      <category>Transactions</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=d2a49ef9-af36-4689-965a-2989e57a7a17</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,d2a49ef9-af36-4689-965a-2989e57a7a17.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,d2a49ef9-af36-4689-965a-2989e57a7a17.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d2a49ef9-af36-4689-965a-2989e57a7a17</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
The sole 2010 offering in the USA of <a href="http://idesign.net/" target="_blank">IDesign</a>’s
Architect’s Master Class conducted by the man himself, Juval Lowy, is only a few weeks
away. I checked in at the <a href="http://idesign.net/" target="_blank">IDesign web
site</a>, and found some updates the world needs to see.
</p>
        <ul>
          <li>
            <a href="http://idesign.net/idesign/download/IDesign%20CSharp%20Coding%20Standard.zip" target="_blank">The
IDesign C# Coding Standard</a> – updated for .NET 4.0</li>
          <li>
            <a href="http://idesign.net/idesign/download/IDesign%20WCF%20Coding%20Standard.zip" target="_blank">The
IDesign WCF Coding Standard</a> – updated for .NET 4.0</li>
          <li>
            <a href="http://idesign.net/idesign/DesktopDefault.aspx?tabindex=5&amp;tabid=11" target="_blank">The
IDesign Code Library</a> - updated for .NET 4.0, including Azure AppFabric Service
Bus extensions and the Service Bus Explorer (priceless)</li>
        </ul>
        <p>
If you want to learn something new every day, start at the top of the IDesign Code
Library and step through one example each day. Be careful, you might need to re-write
every line of code you’ve ever written.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=d2a49ef9-af36-4689-965a-2989e57a7a17" />
      </body>
      <title>Gearing up for Juval Lowy’s Architect’s Master Class</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,d2a49ef9-af36-4689-965a-2989e57a7a17.aspx</guid>
      <link>http://offroadcoder.com/2010/04/22/GearingUpForJuvalLowysArchitectsMasterClass.aspx</link>
      <pubDate>Thu, 22 Apr 2010 00:56:04 GMT</pubDate>
      <description>&lt;p&gt;
The sole 2010 offering in the USA of &lt;a href="http://idesign.net/" target="_blank"&gt;IDesign&lt;/a&gt;’s
Architect’s Master Class conducted by the man himself, Juval Lowy, is only a few weeks
away. I checked in at the &lt;a href="http://idesign.net/" target="_blank"&gt;IDesign web
site&lt;/a&gt;, and found some updates the world needs to see.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://idesign.net/idesign/download/IDesign%20CSharp%20Coding%20Standard.zip" target="_blank"&gt;The
IDesign C# Coding Standard&lt;/a&gt; – updated for .NET 4.0&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://idesign.net/idesign/download/IDesign%20WCF%20Coding%20Standard.zip" target="_blank"&gt;The
IDesign WCF Coding Standard&lt;/a&gt; – updated for .NET 4.0&lt;/li&gt;
&lt;li&gt;
&lt;a href="http://idesign.net/idesign/DesktopDefault.aspx?tabindex=5&amp;amp;tabid=11" target="_blank"&gt;The
IDesign Code Library&lt;/a&gt; - updated for .NET 4.0, including Azure AppFabric Service
Bus extensions and the Service Bus Explorer (priceless)&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
If you want to learn something new every day, start at the top of the IDesign Code
Library and step through one example each day. Be careful, you might need to re-write
every line of code you’ve ever written.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=d2a49ef9-af36-4689-965a-2989e57a7a17" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,d2a49ef9-af36-4689-965a-2989e57a7a17.aspx</comments>
      <category>.NET Framework</category>
      <category>Azure</category>
      <category>C#</category>
      <category>Cloud</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=5d833e28-847b-41a8-905f-549b0f6c1f84</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,5d833e28-847b-41a8-905f-549b0f6c1f84.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,5d833e28-847b-41a8-905f-549b0f6c1f84.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=5d833e28-847b-41a8-905f-549b0f6c1f84</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’m not sure if what I’m doing is actually the right way to create a “user control”
in ASP.NET MVC, but it’s worth sharing this tidbit either way. Instead of using a <em>MVC
View User Control</em> to create a hidden field, a text box, two anchors, and three
JavaScript functions, I chose to put it all in a <em>HtmlHelper</em> in which I write
out the HTML and JavaScript myself. Everything worked fine except the almost magical
auto-repopulating of the hidden and text fields after a post that didn’t work as expected
as in a typical <em>MVC View Page</em>.
</p>
        <p>
          <strong>The situation:</strong> I have a page that needs to be called as a popup from
many pages in my MVC application. The page allows single or multiple selection of
“items” driven by an XML file. In the event that one day, almost always immediately,
I have two or more of these “controls” on one view page, I need the two fields and
the three JavaScript functions to have unique names so they don’t cross paths and
cause unexpected behavior. I had an <em>ASP.NET User Control</em> to do this in plain
old ASP.NET (POAN) since v1.1, and I can’t live without it. 
</p>
        <p>
          <strong>The confusion:</strong> If I were to place the hidden, textbox, anchors, and
JavaScript functions directly in the calling page, something magical happens after
a post. If the controls had values before the post, they appear to magically retain
there values after the post. It wasn’t until a colleague of mine, Sat, and I dug into
Reflector for a while did we realize what was happening. Html.TextBox, Html.Hidden,
and others all do something similar to auto-magically re-populate their values after
the post. Since I’m writing out my fields as &lt;input type=”hidden”/&gt; and &lt;input
type=”text”/&gt;, the magic doesn’t happen.
</p>
        <p>
          <em>      NOTE: The magic will also not happen if you just
write &lt;input type=”text”/&gt; on the page. It only happens if you use Html.TextBox.</em>
        </p>
        <p>
          <strong>The solution:</strong> I am still new to MVC and still trying to wrap my head
around the “right way” to do things. Reflector showed that the <em>HtmlHelpers</em> all
looked at the ModelState in the ViewData before rendering their HTML. They looked
for their value by key (key being the control/tag name), and, if present, used that
as the control/tag’s value. Bing! Maybe I should do the same thing. So just before
I go to town with TagBuilder to assemble my controls/tags, I look in the ViewData’s
ModelState for my value. If it is there, it must have been posted there by me (my
control).
</p>
        <div style="width: 650px; font-family: consolas; background: #3f3f3f; color: #dcdccc; font-size: 9pt">
          <p style="margin: 0px">
            <span style="color: #85ac8d">   48</span>         <span style="color: #2b91af">UrlHelper</span><span style="color: #dfdfbf">urlHelper</span> = <span style="color: #e1e18a; font-weight: bold">new</span><span style="color: #2b91af">UrlHelper</span>(<span style="color: #dfdfbf">helper</span>.<span style="color: #dfdfbf">ViewContext</span>.<span style="color: #dfdfbf">RequestContext</span>);
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   49</span>         <span style="color: #e1e18a; font-weight: bold">string</span><span style="color: #dfdfbf">textValue</span> = <span style="color: #e1e18a; font-weight: bold">null</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   50</span>         <span style="color: #2b91af">ModelState</span><span style="color: #dfdfbf">state</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   51</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   52</span>         <span style="color: #e1e18a; font-weight: bold">if</span> (<span style="color: #dfdfbf">helper</span>.<span style="color: #dfdfbf">ViewData</span>.<span style="color: #dfdfbf">ModelState</span>.<span style="color: #dfdfbf">TryGetValue</span>(<span style="color: #dfdfbf">textFieldName</span>, <span style="color: #e1e18a; font-weight: bold">out</span><span style="color: #dfdfbf">state</span>))
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   53</span>        
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   54</span>             <span style="color: #dfdfbf">textValue</span> = <span style="color: #dfdfbf">state</span>.<span style="color: #dfdfbf">Value</span>.<span style="color: #dfdfbf">AttemptedValue</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   55</span>        
}
</p>
        </div>
        <br />
        <p>
Works like a charm! Now my hidden, textbox, two anchors, and three JavaScript functions
are bundled nicely inside of an <em>HtmlHelper</em> class that looks and feels like
I’m using a built-in ASP.NET MVC <em>HtmlHelper</em> class. Most importantly, I have
the pleasure of typing only this on all my consuming pages.
</p>
        <div style="width: 650px; font-family: consolas; background: #3f3f3f; color: #dcdccc; font-size: 9pt">
          <p style="margin: 0px">
            <span style="color: #85ac8d">   40</span>     <span style="background: #ffee62; color: #000">&lt;%</span><span style="color: #efef8f">=</span><span style="color: #dfdfbf">Html</span>.<span style="color: #dfdfbf">MySelector</span>(<span style="color: #c89191">"selectedIDs"</span>, <span style="color: #c89191">"selectedNames"</span>, <span style="color: #c89191">"State"</span>)<span style="background: #ffee62; color: #000">%&gt;</span></p>
        </div>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=5d833e28-847b-41a8-905f-549b0f6c1f84" />
      </body>
      <title>Auto-populating ASP.NET MVC “controls” after a post</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,5d833e28-847b-41a8-905f-549b0f6c1f84.aspx</guid>
      <link>http://offroadcoder.com/2010/02/01/AutopopulatingASPNETMVCControlsAfterAPost.aspx</link>
      <pubDate>Mon, 01 Feb 2010 02:50:19 GMT</pubDate>
      <description>&lt;p&gt;
I’m not sure if what I’m doing is actually the right way to create a “user control”
in ASP.NET MVC, but it’s worth sharing this tidbit either way. Instead of using a &lt;em&gt;MVC
View User Control&lt;/em&gt; to create a hidden field, a text box, two anchors, and three
JavaScript functions, I chose to put it all in a &lt;em&gt;HtmlHelper&lt;/em&gt; in which I write
out the HTML and JavaScript myself. Everything worked fine except the almost magical
auto-repopulating of the hidden and text fields after a post that didn’t work as expected
as in a typical &lt;em&gt;MVC View Page&lt;/em&gt;.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;The situation:&lt;/strong&gt; I have a page that needs to be called as a popup from
many pages in my MVC application. The page allows single or multiple selection of
“items” driven by an XML file. In the event that one day, almost always immediately,
I have two or more of these “controls” on one view page, I need the two fields and
the three JavaScript functions to have unique names so they don’t cross paths and
cause unexpected behavior. I had an &lt;em&gt;ASP.NET User Control&lt;/em&gt; to do this in plain
old ASP.NET (POAN) since v1.1, and I can’t live without it. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;The confusion:&lt;/strong&gt; If I were to place the hidden, textbox, anchors, and
JavaScript functions directly in the calling page, something magical happens after
a post. If the controls had values before the post, they appear to magically retain
there values after the post. It wasn’t until a colleague of mine, Sat, and I dug into
Reflector for a while did we realize what was happening. Html.TextBox, Html.Hidden,
and others all do something similar to auto-magically re-populate their values after
the post. Since I’m writing out my fields as &amp;lt;input type=”hidden”/&amp;gt; and &amp;lt;input
type=”text”/&amp;gt;, the magic doesn’t happen.
&lt;/p&gt;
&lt;p&gt;
&lt;em&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; NOTE: The magic will also not happen if you just
write &amp;lt;input type=”text”/&amp;gt; on the page. It only happens if you use Html.TextBox.&lt;/em&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;The solution:&lt;/strong&gt; I am still new to MVC and still trying to wrap my head
around the “right way” to do things. Reflector showed that the &lt;em&gt;HtmlHelpers&lt;/em&gt; all
looked at the ModelState in the ViewData before rendering their HTML. They looked
for their value by key (key being the control/tag name), and, if present, used that
as the control/tag’s value. Bing! Maybe I should do the same thing. So just before
I go to town with TagBuilder to assemble my controls/tags, I look in the ViewData’s
ModelState for my value. If it is there, it must have been posted there by me (my
control).
&lt;/p&gt;
&lt;div style="width: 650px; font-family: consolas; background: #3f3f3f; color: #dcdccc; font-size: 9pt"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 48&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af"&gt;UrlHelper&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;urlHelper&lt;/span&gt; = &lt;span style="color: #e1e18a; font-weight: bold"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;UrlHelper&lt;/span&gt;(&lt;span style="color: #dfdfbf"&gt;helper&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;ViewContext&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;RequestContext&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 49&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #e1e18a; font-weight: bold"&gt;string&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;textValue&lt;/span&gt; = &lt;span style="color: #e1e18a; font-weight: bold"&gt;null&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 50&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af"&gt;ModelState&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;state&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 51&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 52&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #e1e18a; font-weight: bold"&gt;if&lt;/span&gt; (&lt;span style="color: #dfdfbf"&gt;helper&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;ViewData&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;ModelState&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;TryGetValue&lt;/span&gt;(&lt;span style="color: #dfdfbf"&gt;textFieldName&lt;/span&gt;, &lt;span style="color: #e1e18a; font-weight: bold"&gt;out&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;state&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 53&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 54&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #dfdfbf"&gt;textValue&lt;/span&gt; = &lt;span style="color: #dfdfbf"&gt;state&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;Value&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;AttemptedValue&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 55&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;p&gt;
Works like a charm! Now my hidden, textbox, two anchors, and three JavaScript functions
are bundled nicely inside of an &lt;em&gt;HtmlHelper&lt;/em&gt; class that looks and feels like
I’m using a built-in ASP.NET MVC &lt;em&gt;HtmlHelper&lt;/em&gt; class. Most importantly, I have
the pleasure of typing only this on all my consuming pages.
&lt;/p&gt;
&lt;div style="width: 650px; font-family: consolas; background: #3f3f3f; color: #dcdccc; font-size: 9pt"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 40&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="background: #ffee62; color: #000"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;Html&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;MySelector&lt;/span&gt;(&lt;span style="color: #c89191"&gt;"selectedIDs"&lt;/span&gt;, &lt;span style="color: #c89191"&gt;"selectedNames"&lt;/span&gt;, &lt;span style="color: #c89191"&gt;"State"&lt;/span&gt;)&lt;span style="background: #ffee62; color: #000"&gt;%&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=5d833e28-847b-41a8-905f-549b0f6c1f84" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,5d833e28-847b-41a8-905f-549b0f6c1f84.aspx</comments>
      <category>ASP.NET</category>
      <category>ASP.NET MVC</category>
      <category>C#</category>
      <category>Javascript</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=3331f559-3440-430f-a4c0-f18f5e90346f</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,3331f559-3440-430f-a4c0-f18f5e90346f.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,3331f559-3440-430f-a4c0-f18f5e90346f.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=3331f559-3440-430f-a4c0-f18f5e90346f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I’ve been talking about Geneva for a long time. I got the basics down earlier in the
year. I tried to come up with my own set of sample apps, but failed to get anywhere.
With the official release, and renaming to <em>Windows Identity Foundation (WIF)</em>,
I have renewed inspiration.
</p>
        <p>
I read Michele Leroux Bustamante’s MSDN magazine article, <a href="http://msdn.microsoft.com/en-us/magazine/ee335707.aspx" target="_blank">Claim-Based
Authorization with WIF</a>, last night. After reading the article, I was confident
that I could get a claims-aware WCF service stood up with a custom STS in a matter
of hours. Today I downloaded and installed WIF. I also installed the WIF SDK and all
of the prerequisite hotfixes. I perused the readme files and looked through some of
the samples code. Everything is layed out sensibly, the samples are commented sufficiently,
and the samples include setup and cleanup batch scripts when necessary.
</p>
        <p>
The samples include:
</p>
        <blockquote>
          <p>
Quick Start
</p>
          <ol>
            <li>
Simple Claims Aware Web Application 
</li>
            <li>
Simple Claims Aware Web Service 
</li>
            <li>
Simple Web Application With Information Card SignIn 
</li>
            <li>
Simple Web Application With Managed STS 
</li>
            <li>
Claims Aware Web Application in a Web Farm 
</li>
            <li>
Using Claims In IsInRole 
</li>
          </ol>
          <p>
End-to-end Scenario
</p>
          <ol>
            <li>
Authentication Assurance 
</li>
            <li>
Federation For Web Services 
</li>
            <li>
Federation For Web Applications 
</li>
            <li>
Identity Delegation 
</li>
            <li>
Web Application With Multiple SignIn Methods 
</li>
            <li>
Federation Metadata</li>
          </ol>
          <p>
Extensibility
</p>
          <ol>
            <li>
Claims Aware AJAX Application 
</li>
            <li>
Convert Claims To NT Token 
</li>
            <li>
Customizing Request Security Token 
</li>
            <li>
Customizing Token 
</li>
            <li>
WSTrustChannel 
</li>
            <li>
Claims-based Authorization</li>
          </ol>
        </blockquote>
        <p>
All of the samples I’ve run through so far are great. The only thing that I’m not
in love with is all the XML required to wire this stuff up. Maybe some Juval-style
extensions would make it less painful.
</p>
        <p>
One more thing… it looks like all of the XP users will finally have to upgrade. WIF
only works with Vista, Win7, and Win2008. I heard that Win2003 compatibility will
arrive in December.
</p>
        <p>
          <a href="http://msdn.microsoft.com/en-us/evalcenter/dd440951.aspx" target="_blank">Download
Windows Identity Foundation</a>
        </p>
        <p>
          <a href="http://www.microsoft.com/downloads/info.aspx?na=47&amp;p=1&amp;SrcDisplayLang=en&amp;SrcCategoryId=&amp;SrcFamilyId=eb9c345f-e830-40b8-a5fe-ae7a864c4d76&amp;u=details.aspx%3ffamilyid%3dC148B2DF-C7AF-46BB-9162-2C9422208504%26displaylang%3den" target="_blank">Download
Windows Identity Foundation SDK</a>
        </p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=3331f559-3440-430f-a4c0-f18f5e90346f" />
      </body>
      <title>WIF FTW</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,3331f559-3440-430f-a4c0-f18f5e90346f.aspx</guid>
      <link>http://offroadcoder.com/2009/11/27/WIFFTW.aspx</link>
      <pubDate>Fri, 27 Nov 2009 04:44:24 GMT</pubDate>
      <description>&lt;p&gt;
I’ve been talking about Geneva for a long time. I got the basics down earlier in the
year. I tried to come up with my own set of sample apps, but failed to get anywhere.
With the official release, and renaming to &lt;em&gt;Windows Identity Foundation (WIF)&lt;/em&gt;,
I have renewed inspiration.
&lt;/p&gt;
&lt;p&gt;
I read Michele Leroux Bustamante’s MSDN magazine article, &lt;a href="http://msdn.microsoft.com/en-us/magazine/ee335707.aspx" target="_blank"&gt;Claim-Based
Authorization with WIF&lt;/a&gt;, last night. After reading the article, I was confident
that I could get a claims-aware WCF service stood up with a custom STS in a matter
of hours. Today I downloaded and installed WIF. I also installed the WIF SDK and all
of the prerequisite hotfixes. I perused the readme files and looked through some of
the samples code. Everything is layed out sensibly, the samples are commented sufficiently,
and the samples include setup and cleanup batch scripts when necessary.
&lt;/p&gt;
&lt;p&gt;
The samples include:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Quick Start
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Simple Claims Aware Web Application 
&lt;li&gt;
Simple Claims Aware Web Service 
&lt;li&gt;
Simple Web Application With Information Card SignIn 
&lt;li&gt;
Simple Web Application With Managed STS 
&lt;li&gt;
Claims Aware Web Application in a Web Farm 
&lt;li&gt;
Using Claims In IsInRole 
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
End-to-end Scenario
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Authentication Assurance 
&lt;li&gt;
Federation For Web Services 
&lt;li&gt;
Federation For Web Applications 
&lt;li&gt;
Identity Delegation 
&lt;li&gt;
Web Application With Multiple SignIn Methods 
&lt;li&gt;
Federation Metadata&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
Extensibility
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Claims Aware AJAX Application 
&lt;li&gt;
Convert Claims To NT Token 
&lt;li&gt;
Customizing Request Security Token 
&lt;li&gt;
Customizing Token 
&lt;li&gt;
WSTrustChannel 
&lt;li&gt;
Claims-based Authorization&lt;/li&gt;
&lt;/ol&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
All of the samples I’ve run through so far are great. The only thing that I’m not
in love with is all the XML required to wire this stuff up. Maybe some Juval-style
extensions would make it less painful.
&lt;/p&gt;
&lt;p&gt;
One more thing… it looks like all of the XP users will finally have to upgrade. WIF
only works with Vista, Win7, and Win2008. I heard that Win2003 compatibility will
arrive in December.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://msdn.microsoft.com/en-us/evalcenter/dd440951.aspx" target="_blank"&gt;Download
Windows Identity Foundation&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.microsoft.com/downloads/info.aspx?na=47&amp;amp;p=1&amp;amp;SrcDisplayLang=en&amp;amp;SrcCategoryId=&amp;amp;SrcFamilyId=eb9c345f-e830-40b8-a5fe-ae7a864c4d76&amp;amp;u=details.aspx%3ffamilyid%3dC148B2DF-C7AF-46BB-9162-2C9422208504%26displaylang%3den" target="_blank"&gt;Download
Windows Identity Foundation SDK&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=3331f559-3440-430f-a4c0-f18f5e90346f" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,3331f559-3440-430f-a4c0-f18f5e90346f.aspx</comments>
      <category>.NET Framework</category>
      <category>AJAX</category>
      <category>ASP.NET</category>
      <category>C#</category>
      <category>WCF</category>
      <category>WIF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=ee03112d-9150-43fa-81a5-a9ad49b49640</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,ee03112d-9150-43fa-81a5-a9ad49b49640.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,ee03112d-9150-43fa-81a5-a9ad49b49640.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=ee03112d-9150-43fa-81a5-a9ad49b49640</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Using the NetTcpBinding on a WCF service is secure by default. Unless you override
the default settings, you will enjoy Transport Security using Windows authentication
and the EncrpytAndSign protection level. When you create a new WCF service library,
Visual Studio creates a config file with the following <em>identity</em> block:
</p>
        <div style="font-size: 9pt; background: #3f3f3f; width: 400px; color: #dcdccc; font-family: consolas">
          <p style="margin: 0px">
            <span style="color: #85ac8d">   24</span> <span style="color: #efef8f">         
&lt;</span><span style="color: #e3c66a">identity</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   25</span> <span style="color: #efef8f">           
&lt;</span><span style="color: #e3c66a">dns</span><span style="color: #efef8f"></span><span style="color: white">value</span><span style="color: #efef8f">="</span><span style="color: #cc9393">localhost</span><span style="color: #efef8f">"/&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   26</span> <span style="color: #efef8f">         
&lt;/</span><span style="color: #e3c66a">identity</span><span style="color: #efef8f">&gt;</span></p>
        </div>
        <p>
 
</p>
        <p>
If you wipe this config file clean like me to write a much cleaner and shorter config
file, this <em>identity</em> block is the first thing to go. Sadly, most people also
add a binding configuration with &lt;security mode=”None”/&gt;. I have done this too
in an Intranet environment. The samples and book examples out there don’t show how
to write an actual production environment service that cares for different machines
in the same domain. While the default settings work when testing on your local machine,
they don’t work in a simple Intranet environment.
</p>
        <p>
Most of the difficulty I experienced when starting to work with WCF was getting security
to work with the TCP binding. Everything worked so easily during development, but
everything broke down once deployed to the development server. It didn’t help that
the only errors I saw were timeout exceptions. If I had known about the Service Trace
Viewer, I could have easily determine the cause and Googled (Bing wasn’t around then)
for a solution. Instead, I chose the easier (and much less secure) way out… rely on
my firewall and turn security off.
</p>
        <p>
As mentioned before, the NetTcpBinding is secure by default with transport security
using Windows authentication. The problem most experience when moving the service
to a different machine is caused by NT authentication failing. If you use svcutil
to generate your client config file and your host doesn’t have the <em>identity </em>block
mentioned above, svcutil will not add a key piece of information to the client config
file. The missing element is, you guessed it, the <em>identity</em> block. Without
it, you will likely get an exception and see a stack trace similar to this:
</p>
        <p>
[System.ServiceModel.Security.SecurityNegotiationException: A call to SSPI failed,
see inner exception.]<br />
...<br />
[System.Security.Authentication.AuthenticationException: A call to SSPI failed, see
inner exception.]<br />
...<br />
[System.ComponentModel.Win32Exception: The target principal name is incorrect.]<br />
...
</p>
        <p>
If you add tracing to your client, you will see that without specifying an <em>identity</em> block
WCF will make the call with a DNS identity set to the name of the host. Notice the
blue arrows.
</p>
        <p>
          <a href="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image.png">
            <img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="171" alt="image" src="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_thumb.png" width="330" border="0" />
          </a>
        </p>
        <p>
You can see that the EndpointReference does not have an &lt;Identity&gt; block. Without
that <em>identity</em> block, WCF cannot create a valid ServicePrincipalName. You
can find this in Reflector, following this path:
</p>
        <ul>
          <li>
System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider+WindowsStreamSecurityUpgradeInitiator.OnInitiateUpgrade()
– This is where the SecurityNegociationException is being thrown. 
</li>
          <li>
System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider+WindowsStreamSecurityUpgradeInitiator.InitiateUpgradePrepare()
– This method populates an EndpointIdentity and ServicePrincipalName to be used immediately
after for NT authentication.</li>
        </ul>
        <p>
          <a href="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_3.png">
            <img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="144" alt="image" src="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_thumb_3.png" width="538" border="0" />
          </a>
        </p>
        <p>
When the identity is not specified, it falls back to trying to create an SPN from
the host address. I have seen this work on a machine that has two DNS names, using
the DNS name that does not match the NETBIOS or AD name for the machine. I’m not exactly
sure why that works.
</p>
        <p>
Having any of the following <em>identity</em> blocks in your client config file will
cause WCF to take the first path that successfully creates an SPN needed to perform
NT authentication in the AuthenticateAsClient method called from OnInitiateUpgrade():
</p>
        <ul>
          <li>
&lt;dns value=”serviceHostName”/&gt; 
</li>
          <li>
&lt;dns/&gt; 
</li>
          <li>
&lt;servicePrincipalName value=”domain\hostServiceUserAccount”/&gt; 
</li>
          <li>
&lt;servicePrincipalName/&gt;</li>
        </ul>
        <p>
        </p>
        <p>
        </p>
        <p>
Having these &lt;Identity&gt; settings in your client config file adds the appropriate
&lt;Identity&gt; settings in the &lt;EndpointReference&gt; used when opening the channel.
</p>
        <p>
          <a href="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_4.png">
            <img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="197" alt="image" src="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_thumb_4.png" width="333" border="0" />
          </a>
        </p>
        <p>
Security seems more mysterious when going rogue and writing your own config files.
If you go rogue, make sure you use the appropriate &lt;Identity&gt; blocks. With this
mystery solved, &lt;security mode=”None”/&gt; is a thing of the past. Now we can keep
our services secure in an Intranet environment.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=ee03112d-9150-43fa-81a5-a9ad49b49640" />
      </body>
      <title>NetTcpBinding and SecurityNegotiationException "A call to SSPI failed"</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,ee03112d-9150-43fa-81a5-a9ad49b49640.aspx</guid>
      <link>http://offroadcoder.com/2009/10/29/NetTcpBindingAndSecurityNegotiationExceptionACallToSSPIFailed.aspx</link>
      <pubDate>Thu, 29 Oct 2009 01:30:22 GMT</pubDate>
      <description>&lt;p&gt;
Using the NetTcpBinding on a WCF service is secure by default. Unless you override
the default settings, you will enjoy Transport Security using Windows authentication
and the EncrpytAndSign protection level. When you create a new WCF service library,
Visual Studio creates a config file with the following &lt;em&gt;identity&lt;/em&gt; block:
&lt;/p&gt;
&lt;div style="font-size: 9pt; background: #3f3f3f; width: 400px; color: #dcdccc; font-family: consolas"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 24&lt;/span&gt;&amp;nbsp;&lt;span style="color: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;identity&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 25&lt;/span&gt;&amp;nbsp;&lt;span style="color: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;dns&lt;/span&gt;&lt;span style="color: #efef8f"&gt; &lt;/span&gt;&lt;span style="color: white"&gt;value&lt;/span&gt;&lt;span style="color: #efef8f"&gt;="&lt;/span&gt;&lt;span style="color: #cc9393"&gt;localhost&lt;/span&gt;&lt;span style="color: #efef8f"&gt;"/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 26&lt;/span&gt;&amp;nbsp;&lt;span style="color: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;identity&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
If you wipe this config file clean like me to write a much cleaner and shorter config
file, this &lt;em&gt;identity&lt;/em&gt; block is the first thing to go. Sadly, most people also
add a binding configuration with &amp;lt;security mode=”None”/&amp;gt;. I have done this too
in an Intranet environment. The samples and book examples out there don’t show how
to write an actual production environment service that cares for different machines
in the same domain. While the default settings work when testing on your local machine,
they don’t work in a simple Intranet environment.
&lt;/p&gt;
&lt;p&gt;
Most of the difficulty I experienced when starting to work with WCF was getting security
to work with the TCP binding. Everything worked so easily during development, but
everything broke down once deployed to the development server. It didn’t help that
the only errors I saw were timeout exceptions. If I had known about the Service Trace
Viewer, I could have easily determine the cause and Googled (Bing wasn’t around then)
for a solution. Instead, I chose the easier (and much less secure) way out… rely on
my firewall and turn security off.
&lt;/p&gt;
&lt;p&gt;
As mentioned before, the NetTcpBinding is secure by default with transport security
using Windows authentication. The problem most experience when moving the service
to a different machine is caused by NT authentication failing. If you use svcutil
to generate your client config file and your host doesn’t have the &lt;em&gt;identity &lt;/em&gt;block
mentioned above, svcutil will not add a key piece of information to the client config
file. The missing element is, you guessed it, the &lt;em&gt;identity&lt;/em&gt; block. Without
it, you will likely get an exception and see a stack trace similar to this:
&lt;/p&gt;
&lt;p&gt;
[System.ServiceModel.Security.SecurityNegotiationException: A call to SSPI failed,
see inner exception.]&lt;br&gt;
...&lt;br&gt;
[System.Security.Authentication.AuthenticationException: A call to SSPI failed, see
inner exception.]&lt;br&gt;
...&lt;br&gt;
[System.ComponentModel.Win32Exception: The target principal name is incorrect.]&lt;br&gt;
...
&lt;/p&gt;
&lt;p&gt;
If you add tracing to your client, you will see that without specifying an &lt;em&gt;identity&lt;/em&gt; block
WCF will make the call with a DNS identity set to the name of the host. Notice the
blue arrows.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="171" alt="image" src="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_thumb.png" width="330" border="0"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
You can see that the EndpointReference does not have an &amp;lt;Identity&amp;gt; block. Without
that &lt;em&gt;identity&lt;/em&gt; block, WCF cannot create a valid ServicePrincipalName. You
can find this in Reflector, following this path:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider+WindowsStreamSecurityUpgradeInitiator.OnInitiateUpgrade()
– This is where the SecurityNegociationException is being thrown. 
&lt;li&gt;
System.ServiceModel.Channels.WindowsStreamSecurityUpgradeProvider+WindowsStreamSecurityUpgradeInitiator.InitiateUpgradePrepare()
– This method populates an EndpointIdentity and ServicePrincipalName to be used immediately
after for NT authentication.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;a href="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_3.png"&gt;&lt;img title="image" style="border-top-width: 0px; display: inline; border-left-width: 0px; border-bottom-width: 0px; border-right-width: 0px" height="144" alt="image" src="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_thumb_3.png" width="538" border="0"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
When the identity is not specified, it falls back to trying to create an SPN from
the host address. I have seen this work on a machine that has two DNS names, using
the DNS name that does not match the NETBIOS or AD name for the machine. I’m not exactly
sure why that works.
&lt;/p&gt;
&lt;p&gt;
Having any of the following &lt;em&gt;identity&lt;/em&gt; blocks in your client config file will
cause WCF to take the first path that successfully creates an SPN needed to perform
NT authentication in the AuthenticateAsClient method called from OnInitiateUpgrade():
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&amp;lt;dns value=”serviceHostName”/&amp;gt; 
&lt;li&gt;
&amp;lt;dns/&amp;gt; 
&lt;li&gt;
&amp;lt;servicePrincipalName value=”domain\hostServiceUserAccount”/&amp;gt; 
&lt;li&gt;
&amp;lt;servicePrincipalName/&amp;gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Having these &amp;lt;Identity&amp;gt; settings in your client config file adds the appropriate
&amp;lt;Identity&amp;gt; settings in the &amp;lt;EndpointReference&amp;gt; used when opening the channel.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_4.png"&gt;&lt;img title="image" style="border-right: 0px; border-top: 0px; display: inline; border-left: 0px; border-bottom: 0px" height="197" alt="image" src="http://offroadcoder.com/content/binary/NetTcpBindingwithDefaultSecuritySettings_91BB/image_thumb_4.png" width="333" border="0"&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Security seems more mysterious when going rogue and writing your own config files.
If you go rogue, make sure you use the appropriate &amp;lt;Identity&amp;gt; blocks. With this
mystery solved, &amp;lt;security mode=”None”/&amp;gt; is a thing of the past. Now we can keep
our services secure in an Intranet environment.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=ee03112d-9150-43fa-81a5-a9ad49b49640" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,ee03112d-9150-43fa-81a5-a9ad49b49640.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>Dev Tools</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=6e3243b2-3b8a-44e0-b080-00cab2d08587</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,6e3243b2-3b8a-44e0-b080-00cab2d08587.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,6e3243b2-3b8a-44e0-b080-00cab2d08587.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=6e3243b2-3b8a-44e0-b080-00cab2d08587</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://offroadcoder.com/content/binary/TheWCFMasterClass_1346E/iceberg2.jpg">
            <img title="Web services are just the tip of the iceberg in WCF" style="border-right: 0px; border-top: 0px; display: inline; margin: 0px 10px 0px 0px; border-left: 0px; border-bottom: 0px" height="247" alt="Web services are just the tip of the iceberg in WCF" src="http://offroadcoder.com/content/binary/TheWCFMasterClass_1346E/iceberg2_thumb.jpg" width="371" align="left" border="0" />
          </a>I
was privileged to attend the IDesign WCF Master Class last week. It only comes to
the USA one time each year, and is presented by the one and only Juval Lowy. The class
is held at the training center on the Microsoft Silicon Valley campus in Mountain
View, CA. Five very intense days of WCF covering all aspects of WCF from essentials
like the ABCs to the most intricate details about advanced topics like concurrency,
security, transactions, and the service bus.
</p>
        <p>
What we’ve been <strike>told</strike> sold about WCF from Microsoft is truly just
the tip of the iceberg. Juval presents countless examples that prove WCF is not just
about web services. WCF is the evolution of .NET, providing world-class features that
no class should ever be without. 
</p>
        <p>
Demos, samples, and labs are presented using .NET 3.5 and 4.0 with an emphasis on
the new features and functionality in 4.0. Discovery and announcements are the most
underrated and unknown new features of WCF 4.0. After seeing Juval’s demos on discovery
and announcement, I can’t imagine creating services without them.
</p>
        <p>
More than all of the WCF content, the class gives you a lot to think about regarding
architecture, the framework, and engineering principles. Juval’s mastery of .NET is
evident in his ServiceModelEx library that extends almost all aspects of WCF and the
service bus. His “one line of code” motto makes it possible for all of us to configure
our WCF services with ease. The ServiceModelEx library is a good example for all developers
to know and understand how to “do .NET” the right way. It exemplifies the best of
what .NET and WCF have to offer.
</p>
        <p>
Check out the <a href="http://www.idesign.net" target="_blank">IDesign website</a> to
get the WCF Resource CD (containing many of the examples and demos from the class).
Also note the next class dates and sign up for the IDesign newsletter.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=6e3243b2-3b8a-44e0-b080-00cab2d08587" />
      </body>
      <title>The WCF Master Class</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,6e3243b2-3b8a-44e0-b080-00cab2d08587.aspx</guid>
      <link>http://offroadcoder.com/2009/10/14/TheWCFMasterClass.aspx</link>
      <pubDate>Wed, 14 Oct 2009 01:59:33 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://offroadcoder.com/content/binary/TheWCFMasterClass_1346E/iceberg2.jpg"&gt;&lt;img title="Web services are just the tip of the iceberg in WCF" style="border-right: 0px; border-top: 0px; display: inline; margin: 0px 10px 0px 0px; border-left: 0px; border-bottom: 0px" height="247" alt="Web services are just the tip of the iceberg in WCF" src="http://offroadcoder.com/content/binary/TheWCFMasterClass_1346E/iceberg2_thumb.jpg" width="371" align="left" border="0"&gt;&lt;/a&gt;I
was privileged to attend the IDesign WCF Master Class last week. It only comes to
the USA one time each year, and is presented by the one and only Juval Lowy. The class
is held at the training center on the Microsoft Silicon Valley campus in Mountain
View, CA. Five very intense days of WCF covering all aspects of WCF from essentials
like the ABCs to the most intricate details about advanced topics like concurrency,
security, transactions, and the service bus.
&lt;/p&gt;
&lt;p&gt;
What we’ve been &lt;strike&gt;told&lt;/strike&gt; sold about WCF from Microsoft is truly just
the tip of the iceberg. Juval presents countless examples that prove WCF is not just
about web services. WCF is the evolution of .NET, providing world-class features that
no class should ever be without. 
&lt;/p&gt;
&lt;p&gt;
Demos, samples, and labs are presented using .NET 3.5 and 4.0 with an emphasis on
the new features and functionality in 4.0. Discovery and announcements are the most
underrated and unknown new features of WCF 4.0. After seeing Juval’s demos on discovery
and announcement, I can’t imagine creating services without them.
&lt;/p&gt;
&lt;p&gt;
More than all of the WCF content, the class gives you a lot to think about regarding
architecture, the framework, and engineering principles. Juval’s mastery of .NET is
evident in his ServiceModelEx library that extends almost all aspects of WCF and the
service bus. His “one line of code” motto makes it possible for all of us to configure
our WCF services with ease. The ServiceModelEx library is a good example for all developers
to know and understand how to “do .NET” the right way. It exemplifies the best of
what .NET and WCF have to offer.
&lt;/p&gt;
&lt;p&gt;
Check out the &lt;a href="http://www.idesign.net" target="_blank"&gt;IDesign website&lt;/a&gt; to
get the WCF Resource CD (containing many of the examples and demos from the class).
Also note the next class dates and sign up for the IDesign newsletter.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=6e3243b2-3b8a-44e0-b080-00cab2d08587" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,6e3243b2-3b8a-44e0-b080-00cab2d08587.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>Cloud</category>
      <category>Dev Tools</category>
      <category>Futures</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=c6b29bd9-3388-43b7-b52b-4944aee7e848</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,c6b29bd9-3388-43b7-b52b-4944aee7e848.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,c6b29bd9-3388-43b7-b52b-4944aee7e848.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=c6b29bd9-3388-43b7-b52b-4944aee7e848</wfw:commentRss>
      <slash:comments>1</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">The <a href="http://www.jaxcodecamp.com">2009
Jacksonville Code Camp</a> was a great success. Many thanks to Bayer, Brandy, and
everyone else that made it happen. The bar has been set really high for future Jacksonville
code camps, and for the rest of Florida too. 
<br /><br />
My session on Transactional WCF Services went well. Many great questions and compliments
after the session. If you attended and have any unanswered questions, please email
me. 
<br /><br />
You can download the session files below. It contains staged versions of all of the
transaction modes we discussed. It also contains a tracing solution and tracing result
files to view the client and host tracing files in Client/Service mode. Also see my
previous post on using the <a href="http://offroadcoder.com/2008/06/19/ServiceTraceViewer.aspx">Service
Trace Viewer</a>. It also contains a few demo projects that we didn't get to in the
one-hour session. 
<br /><br />
Files/Solutions included in Session Archive: 
<ul><li>
PowerPoint slides 
</li><li>
Transaction Promotion Code Snippet 
</li><li>
Testing database backup 
</li><li>
Testing SQL script (query and cleanup between tests) 
</li><li>
IDesign ServiceModelEx Project (used by all included Solutions) 
</li><li>
Code Demo Solutions</li></ul><p>
Code Demos include:
</p><table border="0" cellspacing="0" cellpadding="3"><tbody><tr><td valign="top" width="20">
1.</td><td valign="top">
TransactionScope - Shows how single/multiple resource managers affect which Transaction
Manager is chosen to handle the scoped transaction. Also gives first look at transaction
promotion detection. 
</td></tr><tr><td valign="top" width="20">
2a.</td><td valign="top">
Mode None - WCF transaction mode with which no transactions are created or flowed
from the calling client. 
</td></tr><tr><td valign="top" width="20">
2b.</td><td valign="top">
Mode Service - WCF transaction mode with which no transactions are flowed from the
calling client, but a transaction is created for your service operation. 
</td></tr><tr><td valign="top" width="20">
2c.</td><td valign="top">
Mode Client - WCF transaction mode with which a transaction is required to be flowed,
and the service will only use the client transaction.</td></tr><tr><td valign="top" width="20">
2d.</td><td valign="top">
Mode Client/Service - WCF transaction mode with which a client transaction will be
flowed and used by the service, if available. If no client transaction is flowed,
a transaction will be provided automatically for the service operation.</td></tr><tr><td valign="top" width="20">
3.</td><td valign="top">
Explicit Voting - Shows how explicit voting with a session-mode service is performed
using OperationContext.Current.SetTransactionComplete(). 
</td></tr><tr><td valign="top" width="20">
4a.</td><td valign="top">
Testing Various Resource Managers - Shows how a client can use a single TransactionScope
to call several services (some transactional, some non-transactional), a database
stored procedure, and an IDesign volatile resource manager Transactional&lt;int&gt;<int>
.
</int></td></tr><tr><td valign="top" width="20">
4b.</td><td valign="top">
Testing Services - Provides a host project for a transactional service and a non-transactional
service used in 4a. 
</td></tr><tr><td valign="top" width="20">
5a.</td><td valign="top">
Tracing - Same as 2d. modified with the additional app.config settings in the client
and host projects to allow for service tracing to .svclog files. 
</td></tr><tr><td valign="top" width="20">
5b.</td><td valign="top">
Tracing Results - Stored results from executing 5a. in case you don't want to load
the database and actually run the projects. The .stvproj file can be opened directly
in the Service Trace Viewer. On the "Activity" table, click on the activity "Process
action 'http://services/gotjeep.net/GpsTrackServiceContract/SubmitTrack'" then click
on the "Graph" tab. You will see that the client and host activities where the arrow
moves from client to host (send and receive message, respectively) show the OleTxTransaction
in "Headers." The next activity in the host reads "The transaction '5bd25b08-848c-409d-9163-6303b9138382:1'
was flowed to operation 'SubmitTrack'."</td></tr></tbody></table><p>
 
</p><p>
Download the session files: 
<br /><a href="content/binary/TransactionalWCF.zip">TransactionalWCF.zip (854 KB)</a></p><img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=c6b29bd9-3388-43b7-b52b-4944aee7e848" /></body>
      <title>Code Camp Session Files</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,c6b29bd9-3388-43b7-b52b-4944aee7e848.aspx</guid>
      <link>http://offroadcoder.com/2009/09/03/CodeCampSessionFiles.aspx</link>
      <pubDate>Thu, 03 Sep 2009 03:34:34 GMT</pubDate>
      <description>The &lt;a href="http://www.jaxcodecamp.com"&gt;2009 Jacksonville Code Camp&lt;/a&gt; was a great
success. Many thanks to Bayer, Brandy, and everyone else that made it happen. The
bar has been set really high for future Jacksonville code camps, and for the rest
of Florida too. 
&lt;br&gt;
&lt;br&gt;
My session on Transactional WCF Services went well. Many great questions and compliments
after the session. If you attended and have any unanswered questions, please email
me. 
&lt;br&gt;
&lt;br&gt;
You can download the session files below. It contains staged versions of all of the
transaction modes we discussed. It also contains a tracing solution and tracing result
files to view the client and host tracing files in Client/Service mode. Also see my
previous post on using the &lt;a href="http://offroadcoder.com/2008/06/19/ServiceTraceViewer.aspx"&gt;Service
Trace Viewer&lt;/a&gt;. It also contains a few demo projects that we didn't get to in the
one-hour session. 
&lt;br&gt;
&lt;br&gt;
Files/Solutions included in Session Archive: 
&lt;ul&gt;
&lt;li&gt;
PowerPoint slides 
&lt;li&gt;
Transaction Promotion Code Snippet 
&lt;li&gt;
Testing database backup 
&lt;li&gt;
Testing SQL script (query and cleanup between tests) 
&lt;li&gt;
IDesign ServiceModelEx Project (used by all included Solutions) 
&lt;li&gt;
Code Demo Solutions&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;
Code Demos include:
&lt;/p&gt;
&lt;table border="0" cellspacing="0" cellpadding="3"&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td valign="top" width="20"&gt;
1.&lt;/td&gt;
&lt;td valign="top"&gt;
TransactionScope - Shows how single/multiple resource managers affect which Transaction
Manager is chosen to handle the scoped transaction. Also gives first look at transaction
promotion detection. 
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="20"&gt;
2a.&lt;/td&gt;
&lt;td valign="top"&gt;
Mode None - WCF transaction mode with which no transactions are created or flowed
from the calling client. 
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="20"&gt;
2b.&lt;/td&gt;
&lt;td valign="top"&gt;
Mode Service - WCF transaction mode with which no transactions are flowed from the
calling client, but a transaction is created for your service operation. 
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="20"&gt;
2c.&lt;/td&gt;
&lt;td valign="top"&gt;
Mode Client - WCF transaction mode with which a transaction is required to be flowed,
and the service will only use the client transaction.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="20"&gt;
2d.&lt;/td&gt;
&lt;td valign="top"&gt;
Mode Client/Service - WCF transaction mode with which a client transaction will be
flowed and used by the service, if available. If no client transaction is flowed,
a transaction will be provided automatically for the service operation.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="20"&gt;
3.&lt;/td&gt;
&lt;td valign="top"&gt;
Explicit Voting - Shows how explicit voting with a session-mode service is performed
using OperationContext.Current.SetTransactionComplete(). 
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="20"&gt;
4a.&lt;/td&gt;
&lt;td valign="top"&gt;
Testing Various Resource Managers - Shows how a client can use a single TransactionScope
to call several services (some transactional, some non-transactional), a database
stored procedure, and an IDesign volatile resource manager Transactional&amp;lt;int&amp;gt;&lt;int&gt;
.
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="20"&gt;
4b.&lt;/td&gt;
&lt;td valign="top"&gt;
Testing Services - Provides a host project for a transactional service and a non-transactional
service used in 4a. 
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="20"&gt;
5a.&lt;/td&gt;
&lt;td valign="top"&gt;
Tracing - Same as 2d. modified with the additional app.config settings in the client
and host projects to allow for service tracing to .svclog files. 
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td valign="top" width="20"&gt;
5b.&lt;/td&gt;
&lt;td valign="top"&gt;
Tracing Results - Stored results from executing 5a. in case you don't want to load
the database and actually run the projects. The .stvproj file can be opened directly
in the Service Trace Viewer. On the "Activity" table, click on the activity "Process
action 'http://services/gotjeep.net/GpsTrackServiceContract/SubmitTrack'" then click
on the "Graph" tab. You will see that the client and host activities where the arrow
moves from client to host (send and receive message, respectively) show the OleTxTransaction
in "Headers." The next activity in the host reads "The transaction '5bd25b08-848c-409d-9163-6303b9138382:1'
was flowed to operation 'SubmitTrack'."&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Download the session files: 
&lt;br&gt;
&lt;a href="content/binary/TransactionalWCF.zip"&gt;TransactionalWCF.zip (854 KB)&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=c6b29bd9-3388-43b7-b52b-4944aee7e848" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,c6b29bd9-3388-43b7-b52b-4944aee7e848.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>Dev Community</category>
      <category>Dev Tools</category>
      <category>MSDTC</category>
      <category>Transactions</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=34796dd3-0878-431f-ba53-35e82627bce7</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,34796dd3-0878-431f-ba53-35e82627bce7.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,34796dd3-0878-431f-ba53-35e82627bce7.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=34796dd3-0878-431f-ba53-35e82627bce7</wfw:commentRss>
      <slash:comments>6</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It's so easy! Start downloading <a href="http://www.microsoft.com/downloads/details.aspx?familyid=1643758B-2986-47F7-B529-3E41584B6CE5&amp;displaylang=en">Enterprise
Library 4.1</a> now while you read this. The data application block syntax has not
changed much since the first version. The most notable change was allowing us to use
System.Data.Common.DbCommand when version 3.0 was released. I understand the uneasy
feeling some developers have using Enterprise Library. My team at my previous employer
decided not to use it, thinking it would add increased complexity and would not give
us the flexibility we needed if we had to change something. This is typical of groups
that do not have an established Data Access Library. 
</p>
        <p>
Your Data Access Library should be one of the most highly tested libraries in your
application. If there is a problem there, you will have issues everywhere. Enterprise
Library not only comes with the source code, but also includes the full suite of unit
tests for each of the application blocks. You should feel at ease when you decide
to migrate to Enterprise Library. Run it through your full battery of tests before
you commit the team to it. If you find any problems, check the forums, request changes/enhancements
from the MS Patterns &amp; Practices team, or fix it yourself.
</p>
        <p>
The steps to achieve EntLib goodness:
</p>
        <ol>
          <li>
Download Enterprise Library 
</li>
          <li>
Add reference to "Enterprise Library Data Access Application Block" and "Enterprise
Library Shared Library" 
</li>
          <li>
Change your app.config or web.config 
</li>
          <li>
Write some much more readable data access code</li>
        </ol>
        <p>
I'll start at step 3 as steps 1 and 2 are self-explanatory. Your connection string
needs to be in you app's config file, the machine.config file, or in a connectionStrings.config
file referenced in those config files. You can start using it just by adding the &lt;configSections&gt;
clock and the &lt;dataConfiguration&gt; node. This will allow you to have one default
database for all commands you will execute.
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red239\green239\blue143;\red63\green63\blue63;\red227\green198\blue106;\red255\green255\blue255;\red204\green147\blue147;}??\fs18 \cf1\cb2\highlight2 &lt;?\cf3 xml\cf1  \cf4 version\cf1 ="\cf5 1.0\cf1 " \cf4 encoding\cf1 ="\cf5 utf-8\cf1 "?&gt;\par ??&lt;\cf3 configuration\cf1 &gt;\par ??    &lt;\cf3 configSections\cf1 &gt;\par ??        &lt;\cf3 section\cf1  \cf4 name\cf1 ="\cf5 dataConfiguration\cf1 " \cf4 type\cf1 ="\cf5 Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\cf1 " /&gt;\par ??    &lt;/\cf3 configSections\cf1 &gt;\par ??    &lt;\cf3 dataConfiguration\cf1  \cf4 defaultDatabase\cf1 ="\cf5 Testing\cf1 " /&gt;\par ??    &lt;\cf3 connectionStrings\cf1 &gt;\par ??        &lt;\cf3 add\cf1  \cf4 name\cf1 ="\cf5 Testing\cf1 " \cf4 connectionString\cf1 ="\cf5 server=scorpion;database=ApplicationLog;Integrated Security=true;\cf1 "\par ??                  \cf4 providerName\cf1 ="\cf5 System.Data.SqlClient\cf1 " /&gt;\par ??        &lt;\cf3 add\cf1  \cf4 name\cf1 ="\cf5 Testing1\cf1 " \cf4 connectionString\cf1 ="\cf5 server=scorpion;database=ApplicationLog;Integrated Security=true;\cf1 "\par ??                  \cf4 providerName\cf1 ="\cf5 System.Data.SqlClient\cf1 " /&gt;\par ??    &lt;/\cf3 connectionStrings\cf1 &gt;\par ??&lt;/\cf3 configuration\cf1 &gt;}
-->
        </p>
        <p>
        </p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red239\green239\blue143;\red63\green63\blue63;\red227\green198\blue106;\red255\green255\blue255;\red204\green147\blue147;}??\fs18 \cf1\cb2\highlight2 &lt;?\cf3 xml\cf1  \cf4 version\cf1 ="\cf5 1.0\cf1 " \cf4 encoding\cf1 ="\cf5 utf-8\cf1 "?&gt;\par ??&lt;\cf3 configuration\cf1 &gt;\par ??    &lt;\cf3 configSections\cf1 &gt;\par ??        &lt;\cf3 section\cf1  \cf4 name\cf1 ="\cf5 dataConfiguration\cf1 " \cf4 type\cf1 ="\cf5 Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\cf1 " /&gt;\par ??    &lt;/\cf3 configSections\cf1 &gt;\par ??    &lt;\cf3 dataConfiguration\cf1  \cf4 defaultDatabase\cf1 ="\cf5 Testing\cf1 " /&gt;\par ??    &lt;\cf3 connectionStrings\cf1 &gt;\par ??        &lt;\cf3 add\cf1  \cf4 name\cf1 ="\cf5 Testing\cf1 " \cf4 connectionString\cf1 ="\cf5 server=scorpion;database=ApplicationLog;Integrated Security=true;\cf1 "\par ??                  \cf4 providerName\cf1 ="\cf5 System.Data.SqlClient\cf1 " /&gt;\par ??        &lt;\cf3 add\cf1  \cf4 name\cf1 ="\cf5 Testing1\cf1 " \cf4 connectionString\cf1 ="\cf5 server=scorpion;database=ApplicationLog;Integrated Security=true;\cf1 "\par ??                  \cf4 providerName\cf1 ="\cf5 System.Data.SqlClient\cf1 " /&gt;\par ??    &lt;/\cf3 connectionStrings\cf1 &gt;\par ??&lt;/\cf3 configuration\cf1 &gt;}
-->
        </p>
        <div style="overflow-y: auto; font-size: 9pt; background: #3f3f3f; width: 865px; color: #dcdccc; font-family: consolas; height: 177px">
          <p style="margin: 0px">
            <span style="color: #efef8f">&lt;?</span>
            <span style="color: #e3c66a">xml</span>
            <span style="color: #efef8f">
            </span>
            <span style="color: white">version</span>
            <span style="color: #efef8f">="</span>
            <span style="color: #cc9393">1.0</span>
            <span style="color: #efef8f">" </span>
            <span style="color: white">encoding</span>
            <span style="color: #efef8f">="</span>
            <span style="color: #cc9393">utf-8</span>
            <span style="color: #efef8f">"?&gt;</span>
          </p>
          <p style="margin: 0px">
            <span style="color: #efef8f">&lt;</span>
            <span style="color: #e3c66a">configuration</span>
            <span style="color: #efef8f">&gt;</span>
          </p>
          <p style="margin: 0px">
            <span style="color: #efef8f">    &lt;</span>
            <span style="color: #e3c66a">configSections</span>
            <span style="color: #efef8f">&gt;</span>
          </p>
          <p style="margin: 0px">
            <span style="color: #efef8f">        &lt;</span>
            <span style="color: #e3c66a">section</span>
            <span style="color: #efef8f">
            </span>
            <span style="color: white">name</span>
            <span style="color: #efef8f">="</span>
            <span style="color: #cc9393">dataConfiguration</span>
            <span style="color: #efef8f">" </span>
            <span style="color: white">type</span>
            <span style="color: #efef8f">="</span>
            <span style="color: #cc9393">Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35</span>
            <span style="color: #efef8f">"
/&gt;</span>
          </p>
          <p style="margin: 0px">
            <span style="color: #efef8f">    &lt;/</span>
            <span style="color: #e3c66a">configSections</span>
            <span style="color: #efef8f">&gt;</span>
          </p>
          <p style="margin: 0px">
            <span style="color: #efef8f">    &lt;</span>
            <span style="color: #e3c66a">dataConfiguration</span>
            <span style="color: #efef8f">
            </span>
            <span style="color: white">defaultDatabase</span>
            <span style="color: #efef8f">="</span>
            <span style="color: #cc9393">Testing</span>
            <span style="color: #efef8f">"
/&gt;</span>
          </p>
          <p style="margin: 0px">
            <span style="color: #efef8f">    &lt;</span>
            <span style="color: #e3c66a">connectionStrings</span>
            <span style="color: #efef8f">&gt;</span>
          </p>
          <p style="margin: 0px">
            <span style="color: #efef8f">        &lt;</span>
            <span style="color: #e3c66a">add</span>
            <span style="color: #efef8f">
            </span>
            <span style="color: white">name</span>
            <span style="color: #efef8f">="</span>
            <span style="color: #cc9393">Testing</span>
            <span style="color: #efef8f">" </span>
            <span style="color: white">connectionString</span>
            <span style="color: #efef8f">="</span>
            <span style="color: #cc9393">server=Server_Name;database=DB_Name;Integrated
Security=true;</span>
            <span style="color: #efef8f">"</span>
          </p>
          <p style="margin: 0px">
            <span style="color: #efef8f">                  </span>
            <span style="color: white">providerName</span>
            <span style="color: #efef8f">="</span>
            <span style="color: #cc9393">System.Data.SqlClient</span>
            <span style="color: #efef8f">"
/&gt;</span>
          </p>
          <p style="margin: 0px">
          </p>
          <p style="margin: 0px">
            <span style="color: #efef8f">
            </span>
          </p>
          <p>
            <span style="color: #efef8f">    &lt;/</span>
            <span style="color: #e3c66a">connectionStrings</span>
            <span style="color: #efef8f">&gt;</span>
            <br />
            <span style="color: #efef8f">&lt;/</span>
            <span style="color: #e3c66a">configuration</span>
            <span style="color: #efef8f">&gt;</span>
          </p>
        </div>
        <p>
 
</p>
        <p>
By the time you get to step 4, you have all of the infrastructure in place. Painless
so far, let's see how steep the learning curve is.
</p>
        <p>
With ADO.NET, you would write:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b string}\cf3  \cf4 connectionString\cf3  = \cf5 ConfigurationManager\cf3 .\cf4 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf4 ConnectionString\cf3 ;\par ??\cf1 {\b using}\cf3  (\cf5 SqlConnection\cf3  \cf4 con\cf3  = \cf1 {\b new}\cf3  \cf5 SqlConnection\cf3 (\cf4 connectionString\cf3 ))\par ??\cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??\{\par ??    \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??    \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 1"\cf3 );\par ??    \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??    \cf1 {\b try}\par ??\cf3     \{\par ??        \cf4 con\cf3 .\cf4 Open\cf3 ();\par ??        \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??    \}\par ??    \cf1 {\b finally}\par ??\cf3     \{\par ??        \cf4 con\cf3 .\cf4 Close\cf3 ();\par ??    \}\par ??\}}
-->
        </p>
        <div style="overflow-y: auto; font-size: 9pt; background: #3f3f3f; width: 700px; color: #dcdccc; font-family: consolas; height: 248px">
          <p style="margin: 0px">
            <span style="color: #85ac8d">  116</span> <span style="font-weight: bold; color: #e1e18a">string</span><span style="color: #dfdfbf">connectionString</span> = <span style="color: #2b91af">ConfigurationManager</span>.<span style="color: #dfdfbf">ConnectionStrings</span>[<span style="color: #c89191">"Testing"</span>].<span style="color: #dfdfbf">ConnectionString</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  117</span> <span style="font-weight: bold; color: #e1e18a">using</span> (<span style="color: #2b91af">SqlConnection</span><span style="color: #dfdfbf">con</span> = <span style="font-weight: bold; color: #e1e18a">new</span><span style="color: #2b91af">SqlConnection</span>(<span style="color: #dfdfbf">connectionString</span>))
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  118</span> <span style="font-weight: bold; color: #e1e18a">using</span> (<span style="color: #2b91af">SqlCommand</span><span style="color: #dfdfbf">cmd</span> = <span style="font-weight: bold; color: #e1e18a">new</span><span style="color: #2b91af">SqlCommand</span>(<span style="color: #c89191">"usp_ErrorLog_Insert"</span>, <span style="color: #dfdfbf">con</span>))
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  119</span> {
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  120</span>     <span style="color: #dfdfbf">cmd</span>.<span style="color: #dfdfbf">CommandType</span> = <span style="color: #dfdfbf">System</span>.<span style="color: #dfdfbf">Data</span>.<span style="color: #2b91af">CommandType</span>.<span style="color: #dfdfbf">StoredProcedure</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  121</span>     <span style="color: #dfdfbf">cmd</span>.<span style="color: #dfdfbf">Parameters</span>.<span style="color: #dfdfbf">AddWithValue</span>(<span style="color: #c89191">"Message"</span>, <span style="color: #c89191">"Testing
1"</span>);
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  122</span>     <span style="color: #dfdfbf">cmd</span>.<span style="color: #dfdfbf">Parameters</span>.<span style="color: #dfdfbf">AddWithValue</span>(<span style="color: #c89191">"UserID"</span>, <span style="color: #8acccf">5150</span>);
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  123</span>     <span style="font-weight: bold; color: #e1e18a">try</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  124</span>     {
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  125</span>         <span style="color: #dfdfbf">con</span>.<span style="color: #dfdfbf">Open</span>();
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  126</span>         <span style="color: #dfdfbf">cmd</span>.<span style="color: #dfdfbf">ExecuteNonQuery</span>();
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  127</span>     }
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  128</span>     <span style="font-weight: bold; color: #e1e18a">finally</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  129</span>     {
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  130</span>         <span style="color: #dfdfbf">con</span>.<span style="color: #dfdfbf">Close</span>();
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  131</span>     }
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  132</span> }
</p>
        </div>
        <p>
        </p>
        <p>
With Enterprise Library, you write:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red43\green145\blue175;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 Database\cf3  \cf4 db\cf3  = \cf1 DatabaseFactory\cf3 .\cf4 CreateDatabase\cf3 (\cf5 "Testing"\cf3 );\par ??\cf1 DbCommand\cf3  \cf4 cmd\cf3  = \cf4 db\cf3 .\cf4 GetStoredProcCommand\cf3 (\cf5 "usp_ErrorLog_Insert"\cf3 );\par ??\cf4 db\cf3 .\cf4 AddInParameter\cf3 (\cf4 cmd\cf3 , \cf5 "Message"\cf3 , \cf4 System\cf3 .\cf4 Data\cf3 .\cf1 DbType\cf3 .\cf4 String\cf3 , \cf5 "Testing 1"\cf3 );\par ??\cf4 db\cf3 .\cf4 AddInParameter\cf3 (\cf4 cmd\cf3 , \cf5 "UserID"\cf3 , \cf4 System\cf3 .\cf4 Data\cf3 .\cf1 DbType\cf3 .\cf4 Int32\cf3 , \cf6 5150\cf3 );\par ??\cf4 db\cf3 .\cf4 ExecuteNonQuery\cf3 (\cf4 cmd\cf3 );}
-->
        </p>
        <div style="overflow-y: auto; font-size: 9pt; background: #3f3f3f; width: 699px; color: #dcdccc; font-family: consolas; height: 82px">
          <p style="margin: 0px">
            <span style="color: #85ac8d">  170</span> <span style="color: #2b91af">Database</span><span style="color: #dfdfbf">db</span> = <span style="color: #2b91af">DatabaseFactory</span>.<span style="color: #dfdfbf">CreateDatabase</span>();
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  171</span> <span style="color: #2b91af">DbCommand</span><span style="color: #dfdfbf">cmd</span> = <span style="color: #dfdfbf">db</span>.<span style="color: #dfdfbf">GetStoredProcCommand</span>(<span style="color: #c89191">"usp_ErrorLog_Insert"</span>);
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  172</span> <span style="color: #dfdfbf">db</span>.<span style="color: #dfdfbf">AddInParameter</span>(<span style="color: #dfdfbf">cmd</span>, <span style="color: #c89191">"Message"</span>, <span style="color: #dfdfbf">System</span>.<span style="color: #dfdfbf">Data</span>.<span style="color: #2b91af">DbType</span>.<span style="color: #dfdfbf">String</span>, <span style="color: #c89191">"Testing
1"</span>);
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  173</span> <span style="color: #dfdfbf">db</span>.<span style="color: #dfdfbf">AddInParameter</span>(<span style="color: #dfdfbf">cmd</span>, <span style="color: #c89191">"UserID"</span>, <span style="color: #dfdfbf">System</span>.<span style="color: #dfdfbf">Data</span>.<span style="color: #2b91af">DbType</span>.<span style="color: #dfdfbf">Int32</span>, <span style="color: #8acccf">5150</span>);
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">  174</span> <span style="color: #dfdfbf">db</span>.<span style="color: #dfdfbf">ExecuteNonQuery</span>(<span style="color: #dfdfbf">cmd</span>);
</p>
        </div>
        <p>
 
</p>
        <p>
Line 170 creates the database object. This is the hardest thing to get used to. You
call everything related to the Database object. In ADO.NET, we are used to creating
a connection, adding the connection to a command, using the command in an adapter.
Here you'll always be using the Database object to create a command, add parameters
to the command, execute the command, fill a DataSet, etc. It is definitely less code
to write, but it is also more readable and elegant.
</p>
        <p>
If you have a database to execute commands against other than the defaultDatabase
specified in the config file, then the first line changes to:
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red43\green145\blue175;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red200\green145\blue145;}??\fs18 \cf1\cb2\highlight2 Database\cf3  \cf4 db\cf3  = \cf1 DatabaseFactory\cf3 .\cf4 CreateDatabase\cf3 (\cf5 "Testing"\cf3 );}
-->
        </p>
        <div style="overflow-y: auto; font-size: 9pt; background: #3f3f3f; width: 698px; color: #dcdccc; font-family: consolas; height: 24px">
          <p style="margin: 0px">
            <span style="color: #85ac8d">  170</span> <span style="color: #2b91af">Database</span><span style="color: #dfdfbf">db</span> = <span style="color: #2b91af">DatabaseFactory</span>.<span style="color: #dfdfbf">CreateDatabase</span>(<span style="color: #c89191">"OtherConnectionStringKey"</span>);
</p>
        </div>
        <p>
 
</p>
        <p>
That's it. The patterns &amp; practices team has really done a nice job making it
painless to use Enterprise Library. Take the time to try it out again if you reviewed
a previous version. I reviewed 2.0, and chose not to use it. When 3.0 came out, I
was hooked.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=34796dd3-0878-431f-ba53-35e82627bce7" />
      </body>
      <title>How to get started with Enterprise Library Data Application Block</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,34796dd3-0878-431f-ba53-35e82627bce7.aspx</guid>
      <link>http://offroadcoder.com/2008/12/07/HowToGetStartedWithEnterpriseLibraryDataApplicationBlock.aspx</link>
      <pubDate>Sun, 07 Dec 2008 04:09:10 GMT</pubDate>
      <description>&lt;p&gt;
It's so easy! Start downloading &lt;a href="http://www.microsoft.com/downloads/details.aspx?familyid=1643758B-2986-47F7-B529-3E41584B6CE5&amp;amp;displaylang=en"&gt;Enterprise
Library 4.1&lt;/a&gt; now while you read this. The data application block syntax has not
changed much since the first version. The most notable change was allowing us to use
System.Data.Common.DbCommand when version 3.0 was released. I understand the uneasy
feeling some developers have using Enterprise Library. My team at my previous employer
decided not to use it, thinking it would add increased complexity and would not give
us the flexibility we needed if we had to change something. This is typical of groups
that do not have an established Data Access Library. 
&lt;/p&gt;
&lt;p&gt;
Your Data Access Library should be one of the most highly tested libraries in your
application. If there is a problem there, you will have issues everywhere. Enterprise
Library not only comes with the source code, but also includes the full suite of unit
tests for each of the application blocks. You should feel at ease when you decide
to migrate to Enterprise Library. Run it through your full battery of tests before
you commit the team to it. If you find any problems, check the forums, request changes/enhancements
from the MS Patterns &amp;amp; Practices team, or fix it yourself.
&lt;/p&gt;
&lt;p&gt;
The steps to achieve EntLib goodness:
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
Download Enterprise Library 
&lt;li&gt;
Add reference to "Enterprise Library Data Access Application Block" and "Enterprise
Library Shared Library" 
&lt;li&gt;
Change your app.config or web.config 
&lt;li&gt;
Write some much more readable data access code&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
I'll start at step 3 as steps 1 and 2 are self-explanatory. Your connection string
needs to be in you app's config file, the machine.config file, or in a connectionStrings.config
file referenced in those config files. You can start using it just by adding the &amp;lt;configSections&amp;gt;
clock and the &amp;lt;dataConfiguration&amp;gt; node. This will allow you to have one default
database for all commands you will execute.
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red239\green239\blue143;\red63\green63\blue63;\red227\green198\blue106;\red255\green255\blue255;\red204\green147\blue147;}??\fs18 \cf1\cb2\highlight2 &amp;lt;?\cf3 xml\cf1  \cf4 version\cf1 ="\cf5 1.0\cf1 " \cf4 encoding\cf1 ="\cf5 utf-8\cf1 "?&amp;gt;\par ??&amp;lt;\cf3 configuration\cf1 &amp;gt;\par ??    &amp;lt;\cf3 configSections\cf1 &amp;gt;\par ??        &amp;lt;\cf3 section\cf1  \cf4 name\cf1 ="\cf5 dataConfiguration\cf1 " \cf4 type\cf1 ="\cf5 Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\cf1 " /&amp;gt;\par ??    &amp;lt;/\cf3 configSections\cf1 &amp;gt;\par ??    &amp;lt;\cf3 dataConfiguration\cf1  \cf4 defaultDatabase\cf1 ="\cf5 Testing\cf1 " /&amp;gt;\par ??    &amp;lt;\cf3 connectionStrings\cf1 &amp;gt;\par ??        &amp;lt;\cf3 add\cf1  \cf4 name\cf1 ="\cf5 Testing\cf1 " \cf4 connectionString\cf1 ="\cf5 server=scorpion;database=ApplicationLog;Integrated Security=true;\cf1 "\par ??                  \cf4 providerName\cf1 ="\cf5 System.Data.SqlClient\cf1 " /&amp;gt;\par ??        &amp;lt;\cf3 add\cf1  \cf4 name\cf1 ="\cf5 Testing1\cf1 " \cf4 connectionString\cf1 ="\cf5 server=scorpion;database=ApplicationLog;Integrated Security=true;\cf1 "\par ??                  \cf4 providerName\cf1 ="\cf5 System.Data.SqlClient\cf1 " /&amp;gt;\par ??    &amp;lt;/\cf3 connectionStrings\cf1 &amp;gt;\par ??&amp;lt;/\cf3 configuration\cf1 &amp;gt;}
--&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red239\green239\blue143;\red63\green63\blue63;\red227\green198\blue106;\red255\green255\blue255;\red204\green147\blue147;}??\fs18 \cf1\cb2\highlight2 &amp;lt;?\cf3 xml\cf1  \cf4 version\cf1 ="\cf5 1.0\cf1 " \cf4 encoding\cf1 ="\cf5 utf-8\cf1 "?&amp;gt;\par ??&amp;lt;\cf3 configuration\cf1 &amp;gt;\par ??    &amp;lt;\cf3 configSections\cf1 &amp;gt;\par ??        &amp;lt;\cf3 section\cf1  \cf4 name\cf1 ="\cf5 dataConfiguration\cf1 " \cf4 type\cf1 ="\cf5 Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35\cf1 " /&amp;gt;\par ??    &amp;lt;/\cf3 configSections\cf1 &amp;gt;\par ??    &amp;lt;\cf3 dataConfiguration\cf1  \cf4 defaultDatabase\cf1 ="\cf5 Testing\cf1 " /&amp;gt;\par ??    &amp;lt;\cf3 connectionStrings\cf1 &amp;gt;\par ??        &amp;lt;\cf3 add\cf1  \cf4 name\cf1 ="\cf5 Testing\cf1 " \cf4 connectionString\cf1 ="\cf5 server=scorpion;database=ApplicationLog;Integrated Security=true;\cf1 "\par ??                  \cf4 providerName\cf1 ="\cf5 System.Data.SqlClient\cf1 " /&amp;gt;\par ??        &amp;lt;\cf3 add\cf1  \cf4 name\cf1 ="\cf5 Testing1\cf1 " \cf4 connectionString\cf1 ="\cf5 server=scorpion;database=ApplicationLog;Integrated Security=true;\cf1 "\par ??                  \cf4 providerName\cf1 ="\cf5 System.Data.SqlClient\cf1 " /&amp;gt;\par ??    &amp;lt;/\cf3 connectionStrings\cf1 &amp;gt;\par ??&amp;lt;/\cf3 configuration\cf1 &amp;gt;}
--&gt;
&lt;/p&gt;
&lt;div style="overflow-y: auto; font-size: 9pt; background: #3f3f3f; width: 865px; color: #dcdccc; font-family: consolas; height: 177px"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #efef8f"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;xml&lt;/span&gt;&lt;span style="color: #efef8f"&gt; &lt;/span&gt;&lt;span style="color: white"&gt;version&lt;/span&gt;&lt;span style="color: #efef8f"&gt;="&lt;/span&gt;&lt;span style="color: #cc9393"&gt;1.0&lt;/span&gt;&lt;span style="color: #efef8f"&gt;" &lt;/span&gt;&lt;span style="color: white"&gt;encoding&lt;/span&gt;&lt;span style="color: #efef8f"&gt;="&lt;/span&gt;&lt;span style="color: #cc9393"&gt;utf-8&lt;/span&gt;&lt;span style="color: #efef8f"&gt;"?&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;configuration&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;configSections&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;section&lt;/span&gt;&lt;span style="color: #efef8f"&gt; &lt;/span&gt;&lt;span style="color: white"&gt;name&lt;/span&gt;&lt;span style="color: #efef8f"&gt;="&lt;/span&gt;&lt;span style="color: #cc9393"&gt;dataConfiguration&lt;/span&gt;&lt;span style="color: #efef8f"&gt;" &lt;/span&gt;&lt;span style="color: white"&gt;type&lt;/span&gt;&lt;span style="color: #efef8f"&gt;="&lt;/span&gt;&lt;span style="color: #cc9393"&gt;Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings,
Microsoft.Practices.EnterpriseLibrary.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35&lt;/span&gt;&lt;span style="color: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;configSections&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;dataConfiguration&lt;/span&gt;&lt;span style="color: #efef8f"&gt; &lt;/span&gt;&lt;span style="color: white"&gt;defaultDatabase&lt;/span&gt;&lt;span style="color: #efef8f"&gt;="&lt;/span&gt;&lt;span style="color: #cc9393"&gt;Testing&lt;/span&gt;&lt;span style="color: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;connectionStrings&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;add&lt;/span&gt;&lt;span style="color: #efef8f"&gt; &lt;/span&gt;&lt;span style="color: white"&gt;name&lt;/span&gt;&lt;span style="color: #efef8f"&gt;="&lt;/span&gt;&lt;span style="color: #cc9393"&gt;Testing&lt;/span&gt;&lt;span style="color: #efef8f"&gt;" &lt;/span&gt;&lt;span style="color: white"&gt;connectionString&lt;/span&gt;&lt;span style="color: #efef8f"&gt;="&lt;/span&gt;&lt;span style="color: #cc9393"&gt;server=Server_Name;database=DB_Name;Integrated
Security=true;&lt;/span&gt;&lt;span style="color: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: white"&gt;providerName&lt;/span&gt;&lt;span style="color: #efef8f"&gt;="&lt;/span&gt;&lt;span style="color: #cc9393"&gt;System.Data.SqlClient&lt;/span&gt;&lt;span style="color: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #efef8f"&gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="color: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;connectionStrings&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;br&gt;
&lt;span style="color: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #e3c66a"&gt;configuration&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
By the time you get to step 4, you have all of the infrastructure in place. Painless
so far, let's see how steep the learning curve is.
&lt;/p&gt;
&lt;p&gt;
With ADO.NET, you would write:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b string}\cf3  \cf4 connectionString\cf3  = \cf5 ConfigurationManager\cf3 .\cf4 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf4 ConnectionString\cf3 ;\par ??\cf1 {\b using}\cf3  (\cf5 SqlConnection\cf3  \cf4 con\cf3  = \cf1 {\b new}\cf3  \cf5 SqlConnection\cf3 (\cf4 connectionString\cf3 ))\par ??\cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??\{\par ??    \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??    \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 1"\cf3 );\par ??    \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??    \cf1 {\b try}\par ??\cf3     \{\par ??        \cf4 con\cf3 .\cf4 Open\cf3 ();\par ??        \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??    \}\par ??    \cf1 {\b finally}\par ??\cf3     \{\par ??        \cf4 con\cf3 .\cf4 Close\cf3 ();\par ??    \}\par ??\}}
--&gt;
&lt;/p&gt;
&lt;div style="overflow-y: auto; font-size: 9pt; background: #3f3f3f; width: 700px; color: #dcdccc; font-family: consolas; height: 248px"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 116&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight: bold; color: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;connectionString&lt;/span&gt; = &lt;span style="color: #2b91af"&gt;ConfigurationManager&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;ConnectionStrings&lt;/span&gt;[&lt;span style="color: #c89191"&gt;"Testing"&lt;/span&gt;].&lt;span style="color: #dfdfbf"&gt;ConnectionString&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 117&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight: bold; color: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;SqlConnection&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;con&lt;/span&gt; = &lt;span style="font-weight: bold; color: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlConnection&lt;/span&gt;(&lt;span style="color: #dfdfbf"&gt;connectionString&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 118&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight: bold; color: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="color: #2b91af"&gt;SqlCommand&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;cmd&lt;/span&gt; = &lt;span style="font-weight: bold; color: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;SqlCommand&lt;/span&gt;(&lt;span style="color: #c89191"&gt;"usp_ErrorLog_Insert"&lt;/span&gt;, &lt;span style="color: #dfdfbf"&gt;con&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 119&lt;/span&gt; {
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 120&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;CommandType&lt;/span&gt; = &lt;span style="color: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;CommandType&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;StoredProcedure&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 121&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="color: #c89191"&gt;"Message"&lt;/span&gt;, &lt;span style="color: #c89191"&gt;"Testing
1"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 122&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="color: #c89191"&gt;"UserID"&lt;/span&gt;, &lt;span style="color: #8acccf"&gt;5150&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 123&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;try&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 124&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 125&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;Open&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 126&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;ExecuteNonQuery&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 127&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 128&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;finally&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 129&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 130&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;Close&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 131&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 132&lt;/span&gt; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
With Enterprise Library, you write:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red43\green145\blue175;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 Database\cf3  \cf4 db\cf3  = \cf1 DatabaseFactory\cf3 .\cf4 CreateDatabase\cf3 (\cf5 "Testing"\cf3 );\par ??\cf1 DbCommand\cf3  \cf4 cmd\cf3  = \cf4 db\cf3 .\cf4 GetStoredProcCommand\cf3 (\cf5 "usp_ErrorLog_Insert"\cf3 );\par ??\cf4 db\cf3 .\cf4 AddInParameter\cf3 (\cf4 cmd\cf3 , \cf5 "Message"\cf3 , \cf4 System\cf3 .\cf4 Data\cf3 .\cf1 DbType\cf3 .\cf4 String\cf3 , \cf5 "Testing 1"\cf3 );\par ??\cf4 db\cf3 .\cf4 AddInParameter\cf3 (\cf4 cmd\cf3 , \cf5 "UserID"\cf3 , \cf4 System\cf3 .\cf4 Data\cf3 .\cf1 DbType\cf3 .\cf4 Int32\cf3 , \cf6 5150\cf3 );\par ??\cf4 db\cf3 .\cf4 ExecuteNonQuery\cf3 (\cf4 cmd\cf3 );}
--&gt;
&lt;/p&gt;
&lt;div style="overflow-y: auto; font-size: 9pt; background: #3f3f3f; width: 699px; color: #dcdccc; font-family: consolas; height: 82px"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 170&lt;/span&gt;&amp;nbsp;&lt;span style="color: #2b91af"&gt;Database&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;db&lt;/span&gt; = &lt;span style="color: #2b91af"&gt;DatabaseFactory&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;CreateDatabase&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 171&lt;/span&gt;&amp;nbsp;&lt;span style="color: #2b91af"&gt;DbCommand&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;cmd&lt;/span&gt; = &lt;span style="color: #dfdfbf"&gt;db&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;GetStoredProcCommand&lt;/span&gt;(&lt;span style="color: #c89191"&gt;"usp_ErrorLog_Insert"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 172&lt;/span&gt;&amp;nbsp;&lt;span style="color: #dfdfbf"&gt;db&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;AddInParameter&lt;/span&gt;(&lt;span style="color: #dfdfbf"&gt;cmd&lt;/span&gt;, &lt;span style="color: #c89191"&gt;"Message"&lt;/span&gt;, &lt;span style="color: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;DbType&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;String&lt;/span&gt;, &lt;span style="color: #c89191"&gt;"Testing
1"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 173&lt;/span&gt;&amp;nbsp;&lt;span style="color: #dfdfbf"&gt;db&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;AddInParameter&lt;/span&gt;(&lt;span style="color: #dfdfbf"&gt;cmd&lt;/span&gt;, &lt;span style="color: #c89191"&gt;"UserID"&lt;/span&gt;, &lt;span style="color: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;DbType&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;Int32&lt;/span&gt;, &lt;span style="color: #8acccf"&gt;5150&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 174&lt;/span&gt;&amp;nbsp;&lt;span style="color: #dfdfbf"&gt;db&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;ExecuteNonQuery&lt;/span&gt;(&lt;span style="color: #dfdfbf"&gt;cmd&lt;/span&gt;);
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Line 170 creates the database object. This is the hardest thing to get used to. You
call everything related to the Database object. In ADO.NET, we are used to creating
a connection, adding the connection to a command, using the command in an adapter.
Here you'll always be using the Database object to create a command, add parameters
to the command, execute the command, fill a DataSet, etc. It is definitely less code
to write, but it is also more readable and elegant.
&lt;/p&gt;
&lt;p&gt;
If you have a database to execute commands against other than the defaultDatabase
specified in the config file, then the first line changes to:
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red43\green145\blue175;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red200\green145\blue145;}??\fs18 \cf1\cb2\highlight2 Database\cf3  \cf4 db\cf3  = \cf1 DatabaseFactory\cf3 .\cf4 CreateDatabase\cf3 (\cf5 "Testing"\cf3 );}
--&gt;
&lt;/p&gt;
&lt;div style="overflow-y: auto; font-size: 9pt; background: #3f3f3f; width: 698px; color: #dcdccc; font-family: consolas; height: 24px"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp; 170&lt;/span&gt;&amp;nbsp;&lt;span style="color: #2b91af"&gt;Database&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;db&lt;/span&gt; = &lt;span style="color: #2b91af"&gt;DatabaseFactory&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;CreateDatabase&lt;/span&gt;(&lt;span style="color: #c89191"&gt;"OtherConnectionStringKey"&lt;/span&gt;);
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
That's it. The patterns &amp;amp; practices team has really done a nice job making it
painless to use Enterprise Library. Take the time to try it out again if you reviewed
a previous version. I reviewed 2.0, and chose not to use it. When 3.0 came out, I
was hooked.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=34796dd3-0878-431f-ba53-35e82627bce7" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,34796dd3-0878-431f-ba53-35e82627bce7.aspx</comments>
      <category>C#</category>
      <category>Enterprise Library</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=5aef3f0a-3e66-4e87-8469-0411651d2aba</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,5aef3f0a-3e66-4e87-8469-0411651d2aba.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,5aef3f0a-3e66-4e87-8469-0411651d2aba.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=5aef3f0a-3e66-4e87-8469-0411651d2aba</wfw:commentRss>
      <slash:comments>8</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Unless you are working on a extremely simple or read-only application, transactions
are a must. Using the System.Transactions namespace is the easiest and most efficient
way to maintain system consistency when dealing with multiple calls or multiple resources.
Although System.Transactions arrived in .NET in the 2005 product, it is still a relatively
unknown part of the framework. System.Transactions was designed by the Indigo team
in preparation for WCF. It is not compatible with Win98 or WinME, but most people
are incompatible with Win98 and WinME so it works out just fine.
</p>
        <p>
Before System.Transactions, we only had access to System.Data.SqlClient.SqlTransaction
or a true SQL transaction using BEGIN/ROLLBACK/COMMIT TRAN. Using SQL transactions,
you are stuck with only being able to update DB records as part of your transaction.
If you wanted to change a cached value in your app in addition to the SQL updates
in the same transaction then you would be out of luck. This also required a lot of
transaction code in your stored procedures, writing stored procedures that can be
called independently or part of transaction made for very messy stored procedures
and often led to multiple stored procedures that served the same purpose.
</p>
        <p>
Using the SqlTransaction class was also messy. The most important restriction is that
you need to have all database calls inside the same SqlConnection. This does not work
well for a well-designed N-tier application. The other problem is that you need to
handle your own non-DB transaction logic inside the same SqlTransaction and conditionally
commit/rollback as necessary. This all tends to lead to several try-catch statements
within one SqlTransaction. Handling the plumbing to manually add each SqlCommand to
the transaction gets old quickly too.
</p>
        <p>
          <strong>Using SqlTransaction</strong>
        </p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b string}\cf3  \cf4 connectionString\cf3  = \cf5 ConfigurationManager\cf3 .\cf4 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf4 ConnectionString\cf3 ;\par ??\cf1 {\b using}\cf3  (\cf5 SqlConnection\cf3  \cf4 con\cf3  = \cf1 {\b new}\cf3  \cf5 SqlConnection\cf3 (\cf4 connectionString\cf3 ))\par ??\{\par ??    \cf5 SqlTransaction\cf3  \cf4 tran\cf3  = \cf1 {\b null}\cf3 ;\par ??    \cf1 {\b try}\par ??\cf3     \{\par ??        \cf4 con\cf3 .\cf4 Open\cf3 ();\par ??        \cf4 tran\cf3  = \cf4 con\cf3 .\cf4 BeginTransaction\cf3 ();\par ??        \cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??        \{\par ??            \cf4 cmd\cf3 .\cf4 Transaction\cf3  = \cf4 tran\cf3 ;\par ??            \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??            \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 1"\cf3 );\par ??            \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??            \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??        \}\par ??\par ??        \cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??        \{\par ??            \cf4 cmd\cf3 .\cf4 Transaction\cf3  = \cf4 tran\cf3 ;\par ??            \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??            \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 2"\cf3 );\par ??            \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??            \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??        \}\par ??\par ??        \cf4 tran\cf3 .\cf4 Commit\cf3 ();\par ??    \}\par ??    \cf1 {\b catch}\par ??\cf3     \{\par ??        \cf1 {\b if}\cf3  (\cf4 tran\cf3  != \cf1 {\b null}\cf3 ) \cf4 tran\cf3 .\cf4 Rollback\cf3 ();\par ??    \}\par ??    \cf1 {\b finally}\par ??\cf3     \{\par ??        \cf4 con\cf3 .\cf4 Close\cf3 ();\par ??    \}\par ??\}\par ??}
-->
        </p>
        <div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 761px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 250px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   27</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">connectionString</span> = <span style="COLOR: #2b91af">ConfigurationManager</span>.<span style="COLOR: #dfdfbf">ConnectionStrings</span>[<span style="COLOR: #c89191">"Testing"</span>].<span style="COLOR: #dfdfbf">ConnectionString</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   28</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">SqlConnection</span><span style="COLOR: #dfdfbf">con</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SqlConnection</span>(<span style="COLOR: #dfdfbf">connectionString</span>))
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   29</span> {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   30</span>     <span style="COLOR: #2b91af">SqlTransaction</span><span style="COLOR: #dfdfbf">tran</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">null</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   31</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">try</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   32</span>     {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   33</span>         <span style="COLOR: #dfdfbf">con</span>.<span style="COLOR: #dfdfbf">Open</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   34</span>         <span style="COLOR: #dfdfbf">tran</span> = <span style="COLOR: #dfdfbf">con</span>.<span style="COLOR: #dfdfbf">BeginTransaction</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   35</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">SqlCommand</span><span style="COLOR: #dfdfbf">cmd</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SqlCommand</span>(<span style="COLOR: #c89191">"usp_ErrorLog_Insert"</span>, <span style="COLOR: #dfdfbf">con</span>))
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   36</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   37</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Transaction</span> = <span style="COLOR: #dfdfbf">tran</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   38</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">CommandType</span> = <span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Data</span>.<span style="COLOR: #2b91af">CommandType</span>.<span style="COLOR: #dfdfbf">StoredProcedure</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   39</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Parameters</span>.<span style="COLOR: #dfdfbf">AddWithValue</span>(<span style="COLOR: #c89191">"Message"</span>, <span style="COLOR: #c89191">"Testing
1"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   40</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Parameters</span>.<span style="COLOR: #dfdfbf">AddWithValue</span>(<span style="COLOR: #c89191">"UserID"</span>, <span style="COLOR: #8acccf">5150</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   41</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">ExecuteNonQuery</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   42</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   43</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   44</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">SqlCommand</span><span style="COLOR: #dfdfbf">cmd</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SqlCommand</span>(<span style="COLOR: #c89191">"usp_ErrorLog_Insert"</span>, <span style="COLOR: #dfdfbf">con</span>))
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   45</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   46</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Transaction</span> = <span style="COLOR: #dfdfbf">tran</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   47</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">CommandType</span> = <span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Data</span>.<span style="COLOR: #2b91af">CommandType</span>.<span style="COLOR: #dfdfbf">StoredProcedure</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   48</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Parameters</span>.<span style="COLOR: #dfdfbf">AddWithValue</span>(<span style="COLOR: #c89191">"Message"</span>, <span style="COLOR: #c89191">"Testing
2"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   49</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Parameters</span>.<span style="COLOR: #dfdfbf">AddWithValue</span>(<span style="COLOR: #c89191">"UserID"</span>, <span style="COLOR: #8acccf">5150</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   50</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">ExecuteNonQuery</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   51</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   52</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   53</span>         <span style="COLOR: #dfdfbf">tran</span>.<span style="COLOR: #dfdfbf">Commit</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   54</span>     }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   55</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">catch</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   56</span>     {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   57</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">if</span> (<span style="COLOR: #dfdfbf">tran</span> != <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">null</span>) <span style="COLOR: #dfdfbf">tran</span>.<span style="COLOR: #dfdfbf">Rollback</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   58</span>     }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   59</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">finally</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   60</span>     {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   61</span>         <span style="COLOR: #dfdfbf">con</span>.<span style="COLOR: #dfdfbf">Close</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   62</span>     }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   63</span> }
</p>
        </div>
        <p>
 
</p>
        <p>
System.Transactions liberated us from the mundane SqlClient code and repetitive try-catches.
simply wrapping your old ADO.NET with a using (TransactionScope) { } is all you need
to do. You will typically add a transactionScope.Complete() statement as the last
line in the TransactionScope using block is really all you need. Any exception thrown
before this point will break out of scope, implicitly aborting the transation. Much
better.
</p>
        <p>
System.Transactions uses the LTM (Lightweight Transaction Manager) when dealing with
single resources or machines. The transaction is automatically promoted to MSDTC (Microsoft
Distributed Transaction Coordinator) when another resource is enlisted in a transaction.
A lot of people struggle with MSDTC because it is difficult to setup, requires special
firewall considerations, and doesn't really work well for smart client applications
since you have to install MSDTC on every client machine.
</p>
        <p>
I'll show one transaction performed three different ways and show what happens with
the LTM and MSDTC for each of them. I will also demonstrate an excellent reason to
migrate to Enterprise Library.
</p>
        <p>
          <strong>1) Executing two ADO.NET SqlCommands in different SqlConnections</strong>
        </p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red43\green145\blue175;\red223\green223\blue191;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  (\cf4 TransactionScope\cf3  \cf5 scope\cf3  = \cf1 {\b new}\cf3  \cf4 TransactionScope\cf3 ())\par ??\{\par ??    \cf1 {\b string}\cf3  \cf5 connectionString\cf3  = \cf4 ConfigurationManager\cf3 .\cf5 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf5 ConnectionString\cf3 ;\par ??    \cf1 {\b using}\cf3  (\cf4 SqlConnection\cf3  \cf5 con\cf3  = \cf1 {\b new}\cf3  \cf4 SqlConnection\cf3 (\cf5 connectionString\cf3 ))\par ??    \cf1 {\b using}\cf3  (\cf4 SqlCommand\cf3  \cf5 cmd\cf3  = \cf1 {\b new}\cf3  \cf4 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf5 con\cf3 ))\par ??    \{\par ??        \cf5 cmd\cf3 .\cf5 CommandType\cf3  = \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 CommandType\cf3 .\cf5 StoredProcedure\cf3 ;\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 1"\cf3 );\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Open\cf3 ();\par ??            \cf5 cmd\cf3 .\cf5 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 LocalIdentifier\cf3 );\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 DistributedIdentifier\cf3 .\cf5 ToString\cf3 ());\par ??\par ??    \cf1 {\b using}\cf3  (\cf4 SqlConnection\cf3  \cf5 con\cf3  = \cf1 {\b new}\cf3  \cf4 SqlConnection\cf3 (\cf4 ConfigurationManager\cf3 .\cf5 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf5 ConnectionString\cf3 ))\par ??    \cf1 {\b using}\cf3  (\cf4 SqlCommand\cf3  \cf5 cmd\cf3  = \cf1 {\b new}\cf3  \cf4 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf5 con\cf3 ))\par ??    \{\par ??        \cf5 cmd\cf3 .\cf5 CommandType\cf3  = \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 CommandType\cf3 .\cf5 StoredProcedure\cf3 ;\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 2"\cf3 );\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Open\cf3 ();\par ??            \cf5 cmd\cf3 .\cf5 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 LocalIdentifier\cf3 );\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 DistributedIdentifier\cf3 .\cf5 ToString\cf3 ());\par ??\par ??    \cf5 scope\cf3 .\cf5 Complete\cf3 ();\par ??\}}
-->
        </p>
        <p>
        </p>
        <p>
        </p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red43\green145\blue175;\red223\green223\blue191;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  (\cf4 TransactionScope\cf3  \cf5 scope\cf3  = \cf1 {\b new}\cf3  \cf4 TransactionScope\cf3 ())\par ??\{\par ??    \cf1 {\b string}\cf3  \cf5 connectionString\cf3  = \cf4 ConfigurationManager\cf3 .\cf5 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf5 ConnectionString\cf3 ;\par ??    \cf1 {\b using}\cf3  (\cf4 SqlConnection\cf3  \cf5 con\cf3  = \cf1 {\b new}\cf3  \cf4 SqlConnection\cf3 (\cf5 connectionString\cf3 ))\par ??    \cf1 {\b using}\cf3  (\cf4 SqlCommand\cf3  \cf5 cmd\cf3  = \cf1 {\b new}\cf3  \cf4 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf5 con\cf3 ))\par ??    \{\par ??        \cf5 cmd\cf3 .\cf5 CommandType\cf3  = \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 CommandType\cf3 .\cf5 StoredProcedure\cf3 ;\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 1"\cf3 );\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Open\cf3 ();\par ??            \cf5 cmd\cf3 .\cf5 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 LocalIdentifier\cf3 );\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 DistributedIdentifier\cf3 .\cf5 ToString\cf3 ());\par ??\par ??    \cf1 {\b using}\cf3  (\cf4 SqlConnection\cf3  \cf5 con\cf3  = \cf1 {\b new}\cf3  \cf4 SqlConnection\cf3 (\cf5 connectionString\cf3 ))\par ??    \cf1 {\b using}\cf3  (\cf4 SqlCommand\cf3  \cf5 cmd\cf3  = \cf1 {\b new}\cf3  \cf4 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf5 con\cf3 ))\par ??    \{\par ??        \cf5 cmd\cf3 .\cf5 CommandType\cf3  = \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 CommandType\cf3 .\cf5 StoredProcedure\cf3 ;\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 2"\cf3 );\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Open\cf3 ();\par ??            \cf5 cmd\cf3 .\cf5 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 LocalIdentifier\cf3 );\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 DistributedIdentifier\cf3 .\cf5 ToString\cf3 ());\par ??\par ??    \cf5 scope\cf3 .\cf5 Complete\cf3 ();\par ??\}}
-->
        </p>
        <div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 764px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 250px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  122</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">TransactionScope</span><span style="COLOR: #dfdfbf">scope</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">TransactionScope</span>())
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  123</span> {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  124</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">connectionString</span> = <span style="COLOR: #2b91af">ConfigurationManager</span>.<span style="COLOR: #dfdfbf">ConnectionStrings</span>[<span style="COLOR: #c89191">"Testing"</span>].<span style="COLOR: #dfdfbf">ConnectionString</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  125</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">SqlConnection</span><span style="COLOR: #dfdfbf">con</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SqlConnection</span>(<span style="COLOR: #dfdfbf">connectionString</span>))
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  126</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">SqlCommand</span><span style="COLOR: #dfdfbf">cmd</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SqlCommand</span>(<span style="COLOR: #c89191">"usp_ErrorLog_Insert"</span>, <span style="COLOR: #dfdfbf">con</span>))
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  127</span>     {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  128</span>         <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">CommandType</span> = <span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Data</span>.<span style="COLOR: #2b91af">CommandType</span>.<span style="COLOR: #dfdfbf">StoredProcedure</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  129</span>         <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Parameters</span>.<span style="COLOR: #dfdfbf">AddWithValue</span>(<span style="COLOR: #c89191">"Message"</span>, <span style="COLOR: #c89191">"Testing
1"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  130</span>         <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Parameters</span>.<span style="COLOR: #dfdfbf">AddWithValue</span>(<span style="COLOR: #c89191">"UserID"</span>, <span style="COLOR: #8acccf">5150</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  131</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">try</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  132</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  133</span>             <span style="COLOR: #dfdfbf">con</span>.<span style="COLOR: #dfdfbf">Open</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  134</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">ExecuteNonQuery</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  135</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  136</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">finally</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  137</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  138</span>             <span style="COLOR: #dfdfbf">con</span>.<span style="COLOR: #dfdfbf">Close</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  139</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  140</span>     }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  141</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  142</span>     <span style="COLOR: #2b91af">Console</span>.<span style="COLOR: #dfdfbf">WriteLine</span>(<span style="COLOR: #c89191">"Local
Transaction ID: {0}"</span>, 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  143</span>         <span style="COLOR: #2b91af">Transaction</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">TransactionInformation</span>.<span style="COLOR: #dfdfbf">LocalIdentifier</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  144</span>     <span style="COLOR: #2b91af">Console</span>.<span style="COLOR: #dfdfbf">WriteLine</span>(<span style="COLOR: #c89191">"Distributed
Transaction ID: {0}"</span>, 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  145</span>         <span style="COLOR: #2b91af">Transaction</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">TransactionInformation</span>.<span style="COLOR: #dfdfbf">DistributedIdentifier</span>.<span style="COLOR: #dfdfbf">ToString</span>());
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  146</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  147</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">SqlConnection</span><span style="COLOR: #dfdfbf">con</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SqlConnection</span>(<span style="COLOR: #dfdfbf">connectionString</span>))
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  148</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">SqlCommand</span><span style="COLOR: #dfdfbf">cmd</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SqlCommand</span>(<span style="COLOR: #c89191">"usp_ErrorLog_Insert"</span>, <span style="COLOR: #dfdfbf">con</span>))
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  149</span>     {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  150</span>         <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">CommandType</span> = <span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Data</span>.<span style="COLOR: #2b91af">CommandType</span>.<span style="COLOR: #dfdfbf">StoredProcedure</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  151</span>         <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Parameters</span>.<span style="COLOR: #dfdfbf">AddWithValue</span>(<span style="COLOR: #c89191">"Message"</span>, <span style="COLOR: #c89191">"Testing
2"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  152</span>         <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Parameters</span>.<span style="COLOR: #dfdfbf">AddWithValue</span>(<span style="COLOR: #c89191">"UserID"</span>, <span style="COLOR: #8acccf">5150</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  153</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">try</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  154</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  155</span>             <span style="COLOR: #dfdfbf">con</span>.<span style="COLOR: #dfdfbf">Open</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  156</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">ExecuteNonQuery</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  157</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  158</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">finally</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  159</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  160</span>             <span style="COLOR: #dfdfbf">con</span>.<span style="COLOR: #dfdfbf">Close</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  161</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  162</span>     }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  163</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  164</span>     <span style="COLOR: #2b91af">Console</span>.<span style="COLOR: #dfdfbf">WriteLine</span>(<span style="COLOR: #c89191">"Local
Transaction ID: {0}"</span>, 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  165</span>         <span style="COLOR: #2b91af">Transaction</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">TransactionInformation</span>.<span style="COLOR: #dfdfbf">LocalIdentifier</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  166</span>     <span style="COLOR: #2b91af">Console</span>.<span style="COLOR: #dfdfbf">WriteLine</span>(<span style="COLOR: #c89191">"Distributed
Transaction ID: {0}"</span>, 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  167</span>         <span style="COLOR: #2b91af">Transaction</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">TransactionInformation</span>.<span style="COLOR: #dfdfbf">DistributedIdentifier</span>.<span style="COLOR: #dfdfbf">ToString</span>());
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  168</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  169</span>     <span style="COLOR: #dfdfbf">scope</span>.<span style="COLOR: #dfdfbf">Complete</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  170</span> }
</p>
        </div>
        <p>
 
</p>
        <p>
This writes the following to the command line:
</p>
        <blockquote>
          <p>
            <font face="Courier New" size="2">
              <strong>Local Transaction ID: e90f47f4-df80-496b-a9c0-0c45b2f452c4:2<br />
Distributed Transaction ID: 00000000-0000-0000-0000-000000000000<br />
Local Transaction ID: e90f47f4-df80-496b-a9c0-0c45b2f452c4:2<br />
Distributed Transaction ID: 1fad8108-ddae-496a-a7da-ce92df175e40</strong>
            </font>
          </p>
        </blockquote>
        <p>
You'll notice that the first command creates a transaction using LTM as indicated
by the <em>Local Transaction ID</em>. After the second command is executed, the transaction
is promoted to DTC as indicated by the <em>Distributed Transaction ID</em>. This is
expected because there are two distinct SqlConnections. Even though the connection
string is the same, TransactionScope treats these ADO.NET objects as unique resources.
</p>
        <p>
This has additional implications when connection pooling comes into play. After I
close the first connection, it is returned to the pool and is available for use. If
this connection is requested for use, it will no longer be available to commit or
abort this transaction, and you will see the dreaded MSDTC error "Communication with
the underlying transaction manager has failed."
</p>
        <p>
        </p>
        <p>
          <strong>2) Executing two ADO.NET SqlCommands in the same SqlConnection</strong>
        </p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red225\green225\blue138;\red43\green145\blue175;\red223\green223\blue191;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2             \cf3 {\b using}\cf1  (\cf4 SqlConnection\cf1  \cf5 con\cf1  = \cf3 {\b new}\cf1  \cf4 SqlConnection\cf1 (\cf4 ConfigurationManager\cf1 .\cf5 ConnectionStrings\cf1 [\cf6 "Testing"\cf1 ].\cf5 ConnectionString\cf1 ))\par ??            \{\par ??                \cf4 SqlTransaction\cf1  \cf5 tran\cf1  = \cf3 {\b null}\cf1 ;\par ??                \cf3 {\b try}\par ??\cf1                 \{\par ??                    \cf5 con\cf1 .\cf5 Open\cf1 ();\par ??                    \cf5 tran\cf1  = \cf5 con\cf1 .\cf5 BeginTransaction\cf1 ();\par ??                    \cf3 {\b using}\cf1  (\cf4 SqlCommand\cf1  \cf5 cmd\cf1  = \cf3 {\b new}\cf1  \cf4 SqlCommand\cf1 (\cf6 "usp_ErrorLog_Insert"\cf1 , \cf5 con\cf1 ))\par ??                    \{\par ??                        \cf5 cmd\cf1 .\cf5 Transaction\cf1  = \cf5 tran\cf1 ;\par ??                        \cf5 cmd\cf1 .\cf5 CommandType\cf1  = \cf5 System\cf1 .\cf5 Data\cf1 .\cf4 CommandType\cf1 .\cf5 StoredProcedure\cf1 ;\par ??                        \cf5 cmd\cf1 .\cf5 Parameters\cf1 .\cf5 AddWithValue\cf1 (\cf6 "Message"\cf1 , \cf6 "Testing 1"\cf1 );\par ??                        \cf5 cmd\cf1 .\cf5 Parameters\cf1 .\cf5 AddWithValue\cf1 (\cf6 "UserID"\cf1 , \cf7 5150\cf1 );\par ??                        \cf5 cmd\cf1 .\cf5 ExecuteNonQuery\cf1 ();\par ??                    \}\par ??\par ??                    \cf3 {\b using}\cf1  (\cf4 SqlCommand\cf1  \cf5 cmd\cf1  = \cf3 {\b new}\cf1  \cf4 SqlCommand\cf1 (\cf6 "usp_ErrorLog_Insert"\cf1 , \cf5 con\cf1 ))\par ??                    \{\par ??                        \cf5 cmd\cf1 .\cf5 Transaction\cf1  = \cf5 tran\cf1 ;\par ??                        \cf5 cmd\cf1 .\cf5 CommandType\cf1  = \cf5 System\cf1 .\cf5 Data\cf1 .\cf4 CommandType\cf1 .\cf5 StoredProcedure\cf1 ;\par ??                        \cf5 cmd\cf1 .\cf5 Parameters\cf1 .\cf5 AddWithValue\cf1 (\cf6 "Message"\cf1 , \cf6 "Testing 2"\cf1 );\par ??                        \cf5 cmd\cf1 .\cf5 Parameters\cf1 .\cf5 AddWithValue\cf1 (\cf6 "UserID"\cf1 , \cf7 5150\cf1 );\par ??                        \cf5 cmd\cf1 .\cf5 ExecuteNonQuery\cf1 ();\par ??                    \}\par ??\par ??                    \cf5 tran\cf1 .\cf5 Commit\cf1 ();\par ??                \}\par ??                \cf3 {\b catch}\par ??\cf1                 \{\par ??                    \cf3 {\b if}\cf1  (\cf5 tran\cf1  != \cf3 {\b null}\cf1 ) \cf5 tran\cf1 .\cf5 Rollback\cf1 ();\par ??                \}\par ??                \cf3 {\b finally}\par ??\cf1                 \{\par ??                    \cf5 con\cf1 .\cf5 Close\cf1 ();\par ??                \}\par ??            \}}
-->
        </p>
        <p>
        </p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red225\green225\blue138;\red223\green223\blue191;\red43\green145\blue175;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2             \cf3 {\b string}\cf1  \cf4 connectionString\cf1  = \cf5 ConfigurationManager\cf1 .\cf4 ConnectionStrings\cf1 [\cf6 "Testing"\cf1 ].\cf4 ConnectionString\cf1 ;\par ??            \cf3 {\b using}\cf1  (\cf5 SqlConnection\cf1  \cf4 con\cf1  = \cf3 {\b new}\cf1  \cf5 SqlConnection\cf1 (\cf4 connectionString\cf1 ))\par ??            \{\par ??                \cf5 SqlTransaction\cf1  \cf4 tran\cf1  = \cf3 {\b null}\cf1 ;\par ??                \cf3 {\b try}\par ??\cf1                 \{\par ??                    \cf4 con\cf1 .\cf4 Open\cf1 ();\par ??                    \cf4 tran\cf1  = \cf4 con\cf1 .\cf4 BeginTransaction\cf1 ();\par ??                    \cf3 {\b using}\cf1  (\cf5 SqlCommand\cf1  \cf4 cmd\cf1  = \cf3 {\b new}\cf1  \cf5 SqlCommand\cf1 (\cf6 "usp_ErrorLog_Insert"\cf1 , \cf4 con\cf1 ))\par ??                    \{\par ??                        \cf4 cmd\cf1 .\cf4 Transaction\cf1  = \cf4 tran\cf1 ;\par ??                        \cf4 cmd\cf1 .\cf4 CommandType\cf1  = \cf4 System\cf1 .\cf4 Data\cf1 .\cf5 CommandType\cf1 .\cf4 StoredProcedure\cf1 ;\par ??                        \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "Message"\cf1 , \cf6 "Testing 1"\cf1 );\par ??                        \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "UserID"\cf1 , \cf7 5150\cf1 );\par ??                        \cf4 cmd\cf1 .\cf4 ExecuteNonQuery\cf1 ();\par ??                    \}\par ??\par ??                    \cf3 {\b using}\cf1  (\cf5 SqlCommand\cf1  \cf4 cmd\cf1  = \cf3 {\b new}\cf1  \cf5 SqlCommand\cf1 (\cf6 "usp_ErrorLog_Insert"\cf1 , \cf4 con\cf1 ))\par ??                    \{\par ??                        \cf4 cmd\cf1 .\cf4 Transaction\cf1  = \cf4 tran\cf1 ;\par ??                        \cf4 cmd\cf1 .\cf4 CommandType\cf1  = \cf4 System\cf1 .\cf4 Data\cf1 .\cf5 CommandType\cf1 .\cf4 StoredProcedure\cf1 ;\par ??                        \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "Message"\cf1 , \cf6 "Testing 2"\cf1 );\par ??                        \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "UserID"\cf1 , \cf7 5150\cf1 );\par ??                        \cf4 cmd\cf1 .\cf4 ExecuteNonQuery\cf1 ();\par ??                    \}\par ??\par ??                    \cf4 tran\cf1 .\cf4 Commit\cf1 ();\par ??                \}\par ??                \cf3 {\b catch}\par ??\cf1                 \{\par ??                    \cf3 {\b if}\cf1  (\cf4 tran\cf1  != \cf3 {\b null}\cf1 ) \cf4 tran\cf1 .\cf4 Rollback\cf1 ();\par ??                \}\par ??                \cf3 {\b finally}\par ??\cf1                 \{\par ??                    \cf4 con\cf1 .\cf4 Close\cf1 ();\par ??                \}\par ??            \}}
-->
        </p>
        <p>
        </p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red225\green225\blue138;\red223\green223\blue191;\red43\green145\blue175;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2             \cf3 {\b string}\cf1  \cf4 connectionString\cf1  = \cf5 ConfigurationManager\cf1 .\cf4 ConnectionStrings\cf1 [\cf6 "Testing"\cf1 ].\cf4 ConnectionString\cf1 ;\par ??            \cf3 {\b using}\cf1  (\cf5 TransactionScope\cf1  \cf4 scope\cf1  = \cf3 {\b new}\cf1  \cf5 TransactionScope\cf1 ())\par ??            \cf3 {\b using}\cf1  (\cf5 SqlConnection\cf1  \cf4 con\cf1  = \cf3 {\b new}\cf1  \cf5 SqlConnection\cf1 (\cf4 connectionString\cf1 ))\par ??            \{\par ??                \cf3 {\b using}\cf1  (\cf5 SqlCommand\cf1  \cf4 cmd\cf1  = \cf3 {\b new}\cf1  \cf5 SqlCommand\cf1 (\cf6 "usp_ErrorLog_Insert"\cf1 , \cf4 con\cf1 ))\par ??                \{\par ??                    \cf4 cmd\cf1 .\cf4 CommandType\cf1  = \cf4 System\cf1 .\cf4 Data\cf1 .\cf5 CommandType\cf1 .\cf4 StoredProcedure\cf1 ;\par ??                    \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "Message"\cf1 , \cf6 "Testing 1"\cf1 );\par ??                    \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "UserID"\cf1 , \cf7 5150\cf1 );\par ??                    \cf3 {\b try}\par ??\cf1                     \{\par ??                        \cf4 con\cf1 .\cf4 Open\cf1 ();\par ??                        \cf4 cmd\cf1 .\cf4 ExecuteNonQuery\cf1 ();\par ??                    \}\par ??                    \cf3 {\b finally}\par ??\cf1                     \{\par ??                        \cf4 con\cf1 .\cf4 Close\cf1 ();\par ??                    \}\par ??                \}\par ??\par ??                \cf5 Console\cf1 .\cf4 WriteLine\cf1 (\cf6 "Local Transaction ID: \{0\}"\cf1 , \cf5 Transaction\cf1 .\cf4 Current\cf1 .\cf4 TransactionInformation\cf1 .\cf4 LocalIdentifier\cf1 );\par ??                \cf5 Console\cf1 .\cf4 WriteLine\cf1 (\cf6 "Distributed Transaction ID: \{0\}"\cf1 , \cf5 Transaction\cf1 .\cf4 Current\cf1 .\cf4 TransactionInformation\cf1 .\cf4 DistributedIdentifier\cf1 .\cf4 ToString\cf1 ());\par ??\par ??                \cf3 {\b using}\cf1  (\cf5 SqlCommand\cf1  \cf4 cmd\cf1  = \cf3 {\b new}\cf1  \cf5 SqlCommand\cf1 (\cf6 "usp_ErrorLog_Insert"\cf1 , \cf4 con\cf1 ))\par ??                \{\par ??                    \cf4 cmd\cf1 .\cf4 CommandType\cf1  = \cf4 System\cf1 .\cf4 Data\cf1 .\cf5 CommandType\cf1 .\cf4 StoredProcedure\cf1 ;\par ??                    \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "Message"\cf1 , \cf6 "Testing 2"\cf1 );\par ??                    \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "UserID"\cf1 , \cf7 5150\cf1 );\par ??                    \cf3 {\b try}\par ??\cf1                     \{\par ??                        \cf4 con\cf1 .\cf4 Open\cf1 ();\par ??                        \cf4 cmd\cf1 .\cf4 ExecuteNonQuery\cf1 ();\par ??                    \}\par ??                    \cf3 {\b finally}\par ??\cf1                     \{\par ??                        \cf4 con\cf1 .\cf4 Close\cf1 ();\par ??                    \}\par ??                \}\par ??\par ??                \cf5 Console\cf1 .\cf4 WriteLine\cf1 (\cf6 "Local Transaction ID: \{0\}"\cf1 , \cf5 Transaction\cf1 .\cf4 Current\cf1 .\cf4 TransactionInformation\cf1 .\cf4 LocalIdentifier\cf1 );\par ??                \cf5 Console\cf1 .\cf4 WriteLine\cf1 (\cf6 "Distributed Transaction ID: \{0\}"\cf1 , \cf5 Transaction\cf1 .\cf4 Current\cf1 .\cf4 TransactionInformation\cf1 .\cf4 DistributedIdentifier\cf1 .\cf4 ToString\cf1 ());\par ??\par ??                \cf4 scope\cf1 .\cf4 Complete\cf1 ();\par ??            \}}
-->
        </p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b string}\cf3  \cf4 connectionString\cf3  = \cf5 ConfigurationManager\cf3 .\cf4 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf4 ConnectionString\cf3 ;\par ??\cf1 {\b using}\cf3  (\cf5 TransactionScope\cf3  \cf4 scope\cf3  = \cf1 {\b new}\cf3  \cf5 TransactionScope\cf3 ())\par ??\cf1 {\b using}\cf3  (\cf5 SqlConnection\cf3  \cf4 con\cf3  = \cf1 {\b new}\cf3  \cf5 SqlConnection\cf3 (\cf4 connectionString\cf3 ))\par ??\{\par ??    \cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??    \{\par ??        \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 1"\cf3 );\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Open\cf3 ();\par ??            \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 LocalIdentifier\cf3 );\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 DistributedIdentifier\cf3 .\cf4 ToString\cf3 ());\par ??\par ??    \cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??    \{\par ??        \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 2"\cf3 );\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Open\cf3 ();\par ??            \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 LocalIdentifier\cf3 );\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 DistributedIdentifier\cf3 .\cf4 ToString\cf3 ());\par ??\par ??    \cf4 scope\cf3 .\cf4 Complete\cf3 ();\par ??\}}
-->
        </p>
        <p>
        </p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b string}\cf3  \cf4 connectionString\cf3  = \cf5 ConfigurationManager\cf3 .\cf4 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf4 ConnectionString\cf3 ;\par ??\cf1 {\b using}\cf3  (\cf5 TransactionScope\cf3  \cf4 scope\cf3  = \cf1 {\b new}\cf3  \cf5 TransactionScope\cf3 ())\par ??\cf1 {\b using}\cf3  (\cf5 SqlConnection\cf3  \cf4 con\cf3  = \cf1 {\b new}\cf3  \cf5 SqlConnection\cf3 (\cf4 connectionString\cf3 ))\par ??\{\par ??    \cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??    \{\par ??        \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 1"\cf3 );\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Open\cf3 ();\par ??            \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 LocalIdentifier\cf3 );\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 DistributedIdentifier\cf3 .\cf4 ToString\cf3 ());\par ??\par ??    \cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??    \{\par ??        \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 2"\cf3 );\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Open\cf3 ();\par ??            \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 LocalIdentifier\cf3 );\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 DistributedIdentifier\cf3 .\cf4 ToString\cf3 ());\par ??\par ??    \cf4 scope\cf3 .\cf4 Complete\cf3 ();\par ??\}}
-->
        </p>
        <div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 765px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 250px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   69</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">connectionString</span> = <span style="COLOR: #2b91af">ConfigurationManager</span>.<span style="COLOR: #dfdfbf">ConnectionStrings</span>[<span style="COLOR: #c89191">"Testing"</span>].<span style="COLOR: #dfdfbf">ConnectionString</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   70</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">TransactionScope</span><span style="COLOR: #dfdfbf">scope</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">TransactionScope</span>())
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   71</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">SqlConnection</span><span style="COLOR: #dfdfbf">con</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SqlConnection</span>(<span style="COLOR: #dfdfbf">connectionString</span>))
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   72</span> {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   73</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">SqlCommand</span><span style="COLOR: #dfdfbf">cmd</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SqlCommand</span>(<span style="COLOR: #c89191">"usp_ErrorLog_Insert"</span>, <span style="COLOR: #dfdfbf">con</span>))
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   74</span>     {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   75</span>         <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">CommandType</span> = <span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Data</span>.<span style="COLOR: #2b91af">CommandType</span>.<span style="COLOR: #dfdfbf">StoredProcedure</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   76</span>         <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Parameters</span>.<span style="COLOR: #dfdfbf">AddWithValue</span>(<span style="COLOR: #c89191">"Message"</span>, <span style="COLOR: #c89191">"Testing
1"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   77</span>         <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Parameters</span>.<span style="COLOR: #dfdfbf">AddWithValue</span>(<span style="COLOR: #c89191">"UserID"</span>, <span style="COLOR: #8acccf">5150</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   78</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">try</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   79</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   80</span>             <span style="COLOR: #dfdfbf">con</span>.<span style="COLOR: #dfdfbf">Open</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   81</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">ExecuteNonQuery</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   82</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   83</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">finally</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   84</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   85</span>             <span style="COLOR: #dfdfbf">con</span>.<span style="COLOR: #dfdfbf">Close</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   86</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   87</span>     }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   88</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   89</span>     <span style="COLOR: #2b91af">Console</span>.<span style="COLOR: #dfdfbf">WriteLine</span>(<span style="COLOR: #c89191">"Local
Transaction ID: {0}"</span>, 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   90</span>         <span style="COLOR: #2b91af">Transaction</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">TransactionInformation</span>.<span style="COLOR: #dfdfbf">LocalIdentifier</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   91</span>     <span style="COLOR: #2b91af">Console</span>.<span style="COLOR: #dfdfbf">WriteLine</span>(<span style="COLOR: #c89191">"Distributed
Transaction ID: {0}"</span>, 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   92</span>         <span style="COLOR: #2b91af">Transaction</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">TransactionInformation</span>.<span style="COLOR: #dfdfbf">DistributedIdentifier</span>.<span style="COLOR: #dfdfbf">ToString</span>());
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   93</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   94</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">SqlCommand</span><span style="COLOR: #dfdfbf">cmd</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SqlCommand</span>(<span style="COLOR: #c89191">"usp_ErrorLog_Insert"</span>, <span style="COLOR: #dfdfbf">con</span>))
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   95</span>     {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   96</span>         <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">CommandType</span> = <span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Data</span>.<span style="COLOR: #2b91af">CommandType</span>.<span style="COLOR: #dfdfbf">StoredProcedure</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   97</span>         <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Parameters</span>.<span style="COLOR: #dfdfbf">AddWithValue</span>(<span style="COLOR: #c89191">"Message"</span>, <span style="COLOR: #c89191">"Testing
2"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   98</span>         <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">Parameters</span>.<span style="COLOR: #dfdfbf">AddWithValue</span>(<span style="COLOR: #c89191">"UserID"</span>, <span style="COLOR: #8acccf">5150</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   99</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">try</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  100</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  101</span>             <span style="COLOR: #dfdfbf">con</span>.<span style="COLOR: #dfdfbf">Open</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  102</span>             <span style="COLOR: #dfdfbf">cmd</span>.<span style="COLOR: #dfdfbf">ExecuteNonQuery</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  103</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  104</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">finally</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  105</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  106</span>             <span style="COLOR: #dfdfbf">con</span>.<span style="COLOR: #dfdfbf">Close</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  107</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  108</span>     }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  109</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  110</span>     <span style="COLOR: #2b91af">Console</span>.<span style="COLOR: #dfdfbf">WriteLine</span>(<span style="COLOR: #c89191">"Local
Transaction ID: {0}"</span>, 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  111</span>         <span style="COLOR: #2b91af">Transaction</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">TransactionInformation</span>.<span style="COLOR: #dfdfbf">LocalIdentifier</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  112</span>     <span style="COLOR: #2b91af">Console</span>.<span style="COLOR: #dfdfbf">WriteLine</span>(<span style="COLOR: #c89191">"Distributed
Transaction ID: {0}"</span>, 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  113</span>         <span style="COLOR: #2b91af">Transaction</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">TransactionInformation</span>.<span style="COLOR: #dfdfbf">DistributedIdentifier</span>.<span style="COLOR: #dfdfbf">ToString</span>());
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  114</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  115</span>     <span style="COLOR: #dfdfbf">scope</span>.<span style="COLOR: #dfdfbf">Complete</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  116</span> }
</p>
        </div>
        <p>
 
</p>
        <p>
This writes the following to the command line:
</p>
        <blockquote>
          <p>
            <font face="Courier New" size="2">
              <strong>Local Transaction ID: e90f47f4-df80-496b-a9c0-0c45b2f452c4:1<br />
Distributed Transaction ID: 00000000-0000-0000-0000-000000000000<br />
Local Transaction ID: e90f47f4-df80-496b-a9c0-0c45b2f452c4:1<br />
Distributed Transaction ID: becac9c9-e15f-4370-9f73-7f369665bed7</strong>
            </font>
          </p>
        </blockquote>
        <p>
        </p>
        <p>
        </p>
        <p>
This is not expected because both commands are part of the same connection. Of course
I am closing the connection to simulate an N-tier app where the data access layer
is maintaining it's own SQL access, opening and closing its connection as it should.
If I did not close the connection, you would not see a <em>Distributed Transaction
ID</em> after the second command.
</p>
        <p>
        </p>
        <p>
          <strong>3) Executing two Enterprise Library commands</strong>
        </p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red43\green145\blue175;\red223\green223\blue191;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  (\cf4 TransactionScope\cf3  \cf5 scope\cf3  = \cf1 {\b new}\cf3  \cf4 TransactionScope\cf3 ())\par ??\{\par ??    \cf4 Database\cf3  \cf5 db\cf3  = \cf4 DatabaseFactory\cf3 .\cf5 CreateDatabase\cf3 (\cf6 "Testing"\cf3 );\par ??    \cf4 DbCommand\cf3  \cf5 cmd\cf3  = \cf5 db\cf3 .\cf5 GetStoredProcCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 );\par ??    \cf5 db\cf3 .\cf5 AddInParameter\cf3 (\cf5 cmd\cf3 , \cf6 "Message"\cf3 , \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 DbType\cf3 .\cf5 String\cf3 , \cf6 "Testing 1"\cf3 );\par ??    \cf5 db\cf3 .\cf5 AddInParameter\cf3 (\cf5 cmd\cf3 , \cf6 "UserID"\cf3 , \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 DbType\cf3 .\cf5 Int32\cf3 , \cf7 5150\cf3 );\par ??    \cf5 db\cf3 .\cf5 ExecuteNonQuery\cf3 (\cf5 cmd\cf3 );\par ??\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 LocalIdentifier\cf3 );\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 DistributedIdentifier\cf3 .\cf5 ToString\cf3 ());\par ??\par ??    \cf4 Database\cf3  \cf5 db1\cf3  = \cf4 DatabaseFactory\cf3 .\cf5 CreateDatabase\cf3 (\cf6 "Testing1"\cf3 );\par ??    \cf4 DbCommand\cf3  \cf5 cmd1\cf3  = \cf5 db\cf3 .\cf5 GetStoredProcCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 );\par ??    \cf5 db1\cf3 .\cf5 AddInParameter\cf3 (\cf5 cmd1\cf3 , \cf6 "Message"\cf3 , \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 DbType\cf3 .\cf5 String\cf3 , \cf6 "Testing 2"\cf3 );\par ??    \cf5 db1\cf3 .\cf5 AddInParameter\cf3 (\cf5 cmd1\cf3 , \cf6 "UserID"\cf3 , \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 DbType\cf3 .\cf5 Int32\cf3 , \cf7 5150\cf3 );\par ??    \cf5 db1\cf3 .\cf5 ExecuteNonQuery\cf3 (\cf5 cmd1\cf3 );\par ??\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 LocalIdentifier\cf3 );\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 DistributedIdentifier\cf3 .\cf5 ToString\cf3 ());\par ??\par ??    \cf5 scope\cf3 .\cf5 Complete\cf3 ();\par ??\}}
-->
        </p>
        <div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 761px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 250px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  176</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span> (<span style="COLOR: #2b91af">TransactionScope</span><span style="COLOR: #dfdfbf">scope</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">TransactionScope</span>())
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  177</span> {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  178</span>     <span style="COLOR: #2b91af">Database</span><span style="COLOR: #dfdfbf">db</span> = <span style="COLOR: #2b91af">DatabaseFactory</span>.<span style="COLOR: #dfdfbf">CreateDatabase</span>(<span style="COLOR: #c89191">"Testing"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  179</span>     <span style="COLOR: #2b91af">DbCommand</span><span style="COLOR: #dfdfbf">cmd</span> = <span style="COLOR: #dfdfbf">db</span>.<span style="COLOR: #dfdfbf">GetStoredProcCommand</span>(<span style="COLOR: #c89191">"usp_ErrorLog_Insert"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  180</span>     <span style="COLOR: #dfdfbf">db</span>.<span style="COLOR: #dfdfbf">AddInParameter</span>(<span style="COLOR: #dfdfbf">cmd</span>, <span style="COLOR: #c89191">"Message"</span>, <span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Data</span>.<span style="COLOR: #2b91af">DbType</span>.<span style="COLOR: #dfdfbf">String</span>, <span style="COLOR: #c89191">"Testing
1"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  181</span>     <span style="COLOR: #dfdfbf">db</span>.<span style="COLOR: #dfdfbf">AddInParameter</span>(<span style="COLOR: #dfdfbf">cmd</span>, <span style="COLOR: #c89191">"UserID"</span>, <span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Data</span>.<span style="COLOR: #2b91af">DbType</span>.<span style="COLOR: #dfdfbf">Int32</span>, <span style="COLOR: #8acccf">5150</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  182</span>     <span style="COLOR: #dfdfbf">db</span>.<span style="COLOR: #dfdfbf">ExecuteNonQuery</span>(<span style="COLOR: #dfdfbf">cmd</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  183</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  184</span>     <span style="COLOR: #2b91af">Console</span>.<span style="COLOR: #dfdfbf">WriteLine</span>(<span style="COLOR: #c89191">"Local
Transaction ID: {0}"</span>, 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  185</span>         <span style="COLOR: #2b91af">Transaction</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">TransactionInformation</span>.<span style="COLOR: #dfdfbf">LocalIdentifier</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  186</span>     <span style="COLOR: #2b91af">Console</span>.<span style="COLOR: #dfdfbf">WriteLine</span>(<span style="COLOR: #c89191">"Distributed
Transaction ID: {0}"</span>, 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  187</span>         <span style="COLOR: #2b91af">Transaction</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">TransactionInformation</span>.<span style="COLOR: #dfdfbf">DistributedIdentifier</span>.<span style="COLOR: #dfdfbf">ToString</span>());
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  188</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  189</span>     <span style="COLOR: #2b91af">Database</span><span style="COLOR: #dfdfbf">db1</span> = <span style="COLOR: #2b91af">DatabaseFactory</span>.<span style="COLOR: #dfdfbf">CreateDatabase</span>(<span style="COLOR: #c89191">"Testing1"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  190</span>     <span style="COLOR: #2b91af">DbCommand</span><span style="COLOR: #dfdfbf">cmd1</span> = <span style="COLOR: #dfdfbf">db</span>.<span style="COLOR: #dfdfbf">GetStoredProcCommand</span>(<span style="COLOR: #c89191">"usp_ErrorLog_Insert"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  191</span>     <span style="COLOR: #dfdfbf">db1</span>.<span style="COLOR: #dfdfbf">AddInParameter</span>(<span style="COLOR: #dfdfbf">cmd1</span>, <span style="COLOR: #c89191">"Message"</span>, <span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Data</span>.<span style="COLOR: #2b91af">DbType</span>.<span style="COLOR: #dfdfbf">String</span>, <span style="COLOR: #c89191">"Testing
2"</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  192</span>     <span style="COLOR: #dfdfbf">db1</span>.<span style="COLOR: #dfdfbf">AddInParameter</span>(<span style="COLOR: #dfdfbf">cmd1</span>, <span style="COLOR: #c89191">"UserID"</span>, <span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Data</span>.<span style="COLOR: #2b91af">DbType</span>.<span style="COLOR: #dfdfbf">Int32</span>, <span style="COLOR: #8acccf">5150</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  193</span>     <span style="COLOR: #dfdfbf">db1</span>.<span style="COLOR: #dfdfbf">ExecuteNonQuery</span>(<span style="COLOR: #dfdfbf">cmd1</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  194</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  195</span>     <span style="COLOR: #2b91af">Console</span>.<span style="COLOR: #dfdfbf">WriteLine</span>(<span style="COLOR: #c89191">"Local
Transaction ID: {0}"</span>, 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  196</span>         <span style="COLOR: #2b91af">Transaction</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">TransactionInformation</span>.<span style="COLOR: #dfdfbf">LocalIdentifier</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  197</span>     <span style="COLOR: #2b91af">Console</span>.<span style="COLOR: #dfdfbf">WriteLine</span>(<span style="COLOR: #c89191">"Distributed
Transaction ID: {0}"</span>, 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  198</span>         <span style="COLOR: #2b91af">Transaction</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">TransactionInformation</span>.<span style="COLOR: #dfdfbf">DistributedIdentifier</span>.<span style="COLOR: #dfdfbf">ToString</span>());
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  199</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  200</span>     <span style="COLOR: #dfdfbf">scope</span>.<span style="COLOR: #dfdfbf">Complete</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">  201</span> }
</p>
        </div>
        <p>
 
</p>
        <p>
This writes the following to the command line:
</p>
        <blockquote>
          <p>
            <font face="Courier New" size="2">
              <strong>Local Transaction ID: 6737b756-2d5b-4eff-902d-15f9ccd5c26f:3<br />
Distributed Transaction ID: 00000000-0000-0000-0000-000000000000<br />
Local Transaction ID: 6737b756-2d5b-4eff-902d-15f9ccd5c26f:3<br />
Distributed Transaction ID: 00000000-0000-0000-0000-000000000000</strong>
            </font>
          </p>
        </blockquote>
        <p>
Whoa! How cool is that? No DTC promotion. Enterprise Library is intelligently deciding
to keep the connection open when it is part of the transaction. This will save a lot
of wasted time as the promotion to DTC adds a noticeable delay. If I wasn't using
Enterprise Library already, I'd switch now.
</p>
        <p>
        </p>
        <p>
Useful links:
</p>
        <ul>
          <li>
            <a href="http://msdn.microsoft.com/en-us/library/ms172152.aspx">Implementing an Implicit
Transaction using Transaction Scope</a>
          </li>
          <li>
            <a href="http://msdn.microsoft.com/en-us/library/ms730266.aspx">WCF Transactions</a>
          </li>
          <li>
            <a href="http://msdn.microsoft.com/en-us/library/ms973865.aspx">Introducing System.Transactions
in the .NET Framework 2.0</a>
          </li>
        </ul>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=5aef3f0a-3e66-4e87-8469-0411651d2aba" />
      </body>
      <title>What happens to your transaction with different data access methods</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,5aef3f0a-3e66-4e87-8469-0411651d2aba.aspx</guid>
      <link>http://offroadcoder.com/2008/12/05/WhatHappensToYourTransactionWithDifferentDataAccessMethods.aspx</link>
      <pubDate>Fri, 05 Dec 2008 02:50:25 GMT</pubDate>
      <description>&lt;p&gt;
Unless you are working on a extremely simple or read-only application, transactions
are a must. Using the System.Transactions namespace is the easiest and most efficient
way to maintain system consistency when dealing with multiple calls or multiple resources.
Although System.Transactions arrived in .NET in the 2005 product, it is still a relatively
unknown part of the framework. System.Transactions was designed by the Indigo team
in preparation for WCF. It is not compatible with Win98 or WinME, but most people
are incompatible with Win98 and WinME so it works out just fine.
&lt;/p&gt;
&lt;p&gt;
Before System.Transactions, we only had access to System.Data.SqlClient.SqlTransaction
or a true SQL transaction using BEGIN/ROLLBACK/COMMIT TRAN. Using SQL transactions,
you are stuck with only being able to update DB records as part of your transaction.
If you wanted to change a cached value in your app in addition to the SQL updates
in the same transaction then you would be out of luck. This also required a lot of
transaction code in your stored procedures, writing stored procedures that can be
called independently or part of transaction made for very messy stored procedures
and often led to multiple stored procedures that served the same purpose.
&lt;/p&gt;
&lt;p&gt;
Using the SqlTransaction class was also messy. The most important restriction is that
you need to have all database calls inside the same SqlConnection. This does not work
well for a well-designed N-tier application. The other problem is that you need to
handle your own non-DB transaction logic inside the same SqlTransaction and conditionally
commit/rollback as necessary. This all tends to lead to several try-catch statements
within one SqlTransaction. Handling the plumbing to manually add each SqlCommand to
the transaction gets old quickly too.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Using SqlTransaction&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b string}\cf3  \cf4 connectionString\cf3  = \cf5 ConfigurationManager\cf3 .\cf4 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf4 ConnectionString\cf3 ;\par ??\cf1 {\b using}\cf3  (\cf5 SqlConnection\cf3  \cf4 con\cf3  = \cf1 {\b new}\cf3  \cf5 SqlConnection\cf3 (\cf4 connectionString\cf3 ))\par ??\{\par ??    \cf5 SqlTransaction\cf3  \cf4 tran\cf3  = \cf1 {\b null}\cf3 ;\par ??    \cf1 {\b try}\par ??\cf3     \{\par ??        \cf4 con\cf3 .\cf4 Open\cf3 ();\par ??        \cf4 tran\cf3  = \cf4 con\cf3 .\cf4 BeginTransaction\cf3 ();\par ??        \cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??        \{\par ??            \cf4 cmd\cf3 .\cf4 Transaction\cf3  = \cf4 tran\cf3 ;\par ??            \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??            \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 1"\cf3 );\par ??            \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??            \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??        \}\par ??\par ??        \cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??        \{\par ??            \cf4 cmd\cf3 .\cf4 Transaction\cf3  = \cf4 tran\cf3 ;\par ??            \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??            \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 2"\cf3 );\par ??            \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??            \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??        \}\par ??\par ??        \cf4 tran\cf3 .\cf4 Commit\cf3 ();\par ??    \}\par ??    \cf1 {\b catch}\par ??\cf3     \{\par ??        \cf1 {\b if}\cf3  (\cf4 tran\cf3  != \cf1 {\b null}\cf3 ) \cf4 tran\cf3 .\cf4 Rollback\cf3 ();\par ??    \}\par ??    \cf1 {\b finally}\par ??\cf3     \{\par ??        \cf4 con\cf3 .\cf4 Close\cf3 ();\par ??    \}\par ??\}\par ??}
--&gt;
&lt;/p&gt;
&lt;div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 761px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 250px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 27&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;connectionString&lt;/span&gt; = &lt;span style="COLOR: #2b91af"&gt;ConfigurationManager&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ConnectionStrings&lt;/span&gt;[&lt;span style="COLOR: #c89191"&gt;"Testing"&lt;/span&gt;].&lt;span style="COLOR: #dfdfbf"&gt;ConnectionString&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 28&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;SqlConnection&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SqlConnection&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;connectionString&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 29&lt;/span&gt; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 30&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;SqlTransaction&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;tran&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;null&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 31&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;try&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 32&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 33&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Open&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 34&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;tran&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;BeginTransaction&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 35&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"usp_ErrorLog_Insert"&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 36&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 37&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Transaction&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;tran&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 38&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;CommandType&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;CommandType&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;StoredProcedure&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 39&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Message"&lt;/span&gt;, &lt;span style="COLOR: #c89191"&gt;"Testing
1"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 40&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"UserID"&lt;/span&gt;, &lt;span style="COLOR: #8acccf"&gt;5150&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 41&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ExecuteNonQuery&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 42&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 43&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 44&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"usp_ErrorLog_Insert"&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 45&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 46&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Transaction&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;tran&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 47&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;CommandType&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;CommandType&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;StoredProcedure&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 48&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Message"&lt;/span&gt;, &lt;span style="COLOR: #c89191"&gt;"Testing
2"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 49&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"UserID"&lt;/span&gt;, &lt;span style="COLOR: #8acccf"&gt;5150&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 50&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ExecuteNonQuery&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 51&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 52&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 53&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;tran&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Commit&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 54&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 55&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;catch&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 56&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 57&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;if&lt;/span&gt; (&lt;span style="COLOR: #dfdfbf"&gt;tran&lt;/span&gt; != &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;null&lt;/span&gt;) &lt;span style="COLOR: #dfdfbf"&gt;tran&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Rollback&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 58&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 59&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;finally&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 60&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 61&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Close&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 62&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 63&lt;/span&gt; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
System.Transactions liberated us from the mundane SqlClient code and repetitive try-catches.
simply wrapping your old ADO.NET with a using (TransactionScope) { } is all you need
to do. You will typically add a transactionScope.Complete() statement as the last
line in the TransactionScope using block is really all you need. Any exception thrown
before this point will break out of scope, implicitly aborting the transation. Much
better.
&lt;/p&gt;
&lt;p&gt;
System.Transactions uses the LTM (Lightweight Transaction Manager) when dealing with
single resources or machines. The transaction is automatically promoted to MSDTC (Microsoft
Distributed Transaction Coordinator) when another resource is enlisted in a transaction.
A lot of people struggle with MSDTC because it is difficult to setup, requires special
firewall considerations, and doesn't really work well for smart client applications
since you have to install MSDTC on every client machine.
&lt;/p&gt;
&lt;p&gt;
I'll show one transaction performed three different ways and show what happens with
the LTM and MSDTC for each of them. I will also demonstrate an excellent reason to
migrate to Enterprise Library.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;1) Executing two ADO.NET SqlCommands in different SqlConnections&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red43\green145\blue175;\red223\green223\blue191;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  (\cf4 TransactionScope\cf3  \cf5 scope\cf3  = \cf1 {\b new}\cf3  \cf4 TransactionScope\cf3 ())\par ??\{\par ??    \cf1 {\b string}\cf3  \cf5 connectionString\cf3  = \cf4 ConfigurationManager\cf3 .\cf5 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf5 ConnectionString\cf3 ;\par ??    \cf1 {\b using}\cf3  (\cf4 SqlConnection\cf3  \cf5 con\cf3  = \cf1 {\b new}\cf3  \cf4 SqlConnection\cf3 (\cf5 connectionString\cf3 ))\par ??    \cf1 {\b using}\cf3  (\cf4 SqlCommand\cf3  \cf5 cmd\cf3  = \cf1 {\b new}\cf3  \cf4 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf5 con\cf3 ))\par ??    \{\par ??        \cf5 cmd\cf3 .\cf5 CommandType\cf3  = \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 CommandType\cf3 .\cf5 StoredProcedure\cf3 ;\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 1"\cf3 );\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Open\cf3 ();\par ??            \cf5 cmd\cf3 .\cf5 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 LocalIdentifier\cf3 );\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 DistributedIdentifier\cf3 .\cf5 ToString\cf3 ());\par ??\par ??    \cf1 {\b using}\cf3  (\cf4 SqlConnection\cf3  \cf5 con\cf3  = \cf1 {\b new}\cf3  \cf4 SqlConnection\cf3 (\cf4 ConfigurationManager\cf3 .\cf5 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf5 ConnectionString\cf3 ))\par ??    \cf1 {\b using}\cf3  (\cf4 SqlCommand\cf3  \cf5 cmd\cf3  = \cf1 {\b new}\cf3  \cf4 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf5 con\cf3 ))\par ??    \{\par ??        \cf5 cmd\cf3 .\cf5 CommandType\cf3  = \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 CommandType\cf3 .\cf5 StoredProcedure\cf3 ;\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 2"\cf3 );\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Open\cf3 ();\par ??            \cf5 cmd\cf3 .\cf5 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 LocalIdentifier\cf3 );\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 DistributedIdentifier\cf3 .\cf5 ToString\cf3 ());\par ??\par ??    \cf5 scope\cf3 .\cf5 Complete\cf3 ();\par ??\}}
--&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red43\green145\blue175;\red223\green223\blue191;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  (\cf4 TransactionScope\cf3  \cf5 scope\cf3  = \cf1 {\b new}\cf3  \cf4 TransactionScope\cf3 ())\par ??\{\par ??    \cf1 {\b string}\cf3  \cf5 connectionString\cf3  = \cf4 ConfigurationManager\cf3 .\cf5 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf5 ConnectionString\cf3 ;\par ??    \cf1 {\b using}\cf3  (\cf4 SqlConnection\cf3  \cf5 con\cf3  = \cf1 {\b new}\cf3  \cf4 SqlConnection\cf3 (\cf5 connectionString\cf3 ))\par ??    \cf1 {\b using}\cf3  (\cf4 SqlCommand\cf3  \cf5 cmd\cf3  = \cf1 {\b new}\cf3  \cf4 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf5 con\cf3 ))\par ??    \{\par ??        \cf5 cmd\cf3 .\cf5 CommandType\cf3  = \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 CommandType\cf3 .\cf5 StoredProcedure\cf3 ;\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 1"\cf3 );\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Open\cf3 ();\par ??            \cf5 cmd\cf3 .\cf5 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 LocalIdentifier\cf3 );\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 DistributedIdentifier\cf3 .\cf5 ToString\cf3 ());\par ??\par ??    \cf1 {\b using}\cf3  (\cf4 SqlConnection\cf3  \cf5 con\cf3  = \cf1 {\b new}\cf3  \cf4 SqlConnection\cf3 (\cf5 connectionString\cf3 ))\par ??    \cf1 {\b using}\cf3  (\cf4 SqlCommand\cf3  \cf5 cmd\cf3  = \cf1 {\b new}\cf3  \cf4 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf5 con\cf3 ))\par ??    \{\par ??        \cf5 cmd\cf3 .\cf5 CommandType\cf3  = \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 CommandType\cf3 .\cf5 StoredProcedure\cf3 ;\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 2"\cf3 );\par ??        \cf5 cmd\cf3 .\cf5 Parameters\cf3 .\cf5 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Open\cf3 ();\par ??            \cf5 cmd\cf3 .\cf5 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf5 con\cf3 .\cf5 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 LocalIdentifier\cf3 );\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 DistributedIdentifier\cf3 .\cf5 ToString\cf3 ());\par ??\par ??    \cf5 scope\cf3 .\cf5 Complete\cf3 ();\par ??\}}
--&gt;
&lt;/p&gt;
&lt;div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 764px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 250px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 122&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;TransactionScope&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;scope&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TransactionScope&lt;/span&gt;())
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 123&lt;/span&gt; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 124&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;connectionString&lt;/span&gt; = &lt;span style="COLOR: #2b91af"&gt;ConfigurationManager&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ConnectionStrings&lt;/span&gt;[&lt;span style="COLOR: #c89191"&gt;"Testing"&lt;/span&gt;].&lt;span style="COLOR: #dfdfbf"&gt;ConnectionString&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 125&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;SqlConnection&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SqlConnection&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;connectionString&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 126&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"usp_ErrorLog_Insert"&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 127&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 128&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;CommandType&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;CommandType&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;StoredProcedure&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 129&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Message"&lt;/span&gt;, &lt;span style="COLOR: #c89191"&gt;"Testing
1"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 130&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"UserID"&lt;/span&gt;, &lt;span style="COLOR: #8acccf"&gt;5150&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 131&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;try&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 132&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 133&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Open&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 134&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ExecuteNonQuery&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 135&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 136&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;finally&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 137&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 138&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Close&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 139&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 140&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 141&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 142&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;WriteLine&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Local
Transaction ID: {0}"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 143&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Transaction&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;TransactionInformation&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;LocalIdentifier&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 144&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;WriteLine&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Distributed
Transaction ID: {0}"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 145&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Transaction&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;TransactionInformation&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;DistributedIdentifier&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ToString&lt;/span&gt;());
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 146&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 147&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;SqlConnection&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SqlConnection&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;connectionString&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 148&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"usp_ErrorLog_Insert"&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 149&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 150&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;CommandType&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;CommandType&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;StoredProcedure&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 151&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Message"&lt;/span&gt;, &lt;span style="COLOR: #c89191"&gt;"Testing
2"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 152&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"UserID"&lt;/span&gt;, &lt;span style="COLOR: #8acccf"&gt;5150&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 153&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;try&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 154&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 155&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Open&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 156&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ExecuteNonQuery&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 157&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 158&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;finally&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 159&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 160&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Close&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 161&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 162&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 163&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 164&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;WriteLine&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Local
Transaction ID: {0}"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 165&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Transaction&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;TransactionInformation&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;LocalIdentifier&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 166&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;WriteLine&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Distributed
Transaction ID: {0}"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 167&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Transaction&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;TransactionInformation&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;DistributedIdentifier&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ToString&lt;/span&gt;());
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 168&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 169&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;scope&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Complete&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 170&lt;/span&gt; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
This writes the following to the command line:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;font face="Courier New" size=2&gt;&lt;strong&gt;Local Transaction ID: e90f47f4-df80-496b-a9c0-0c45b2f452c4:2&lt;br&gt;
Distributed Transaction ID: 00000000-0000-0000-0000-000000000000&lt;br&gt;
Local Transaction ID: e90f47f4-df80-496b-a9c0-0c45b2f452c4:2&lt;br&gt;
Distributed Transaction ID: 1fad8108-ddae-496a-a7da-ce92df175e40&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
You'll notice that the first command creates a transaction using LTM as indicated
by the &lt;em&gt;Local Transaction ID&lt;/em&gt;. After the second command is executed, the transaction
is promoted to DTC as indicated by the &lt;em&gt;Distributed Transaction ID&lt;/em&gt;. This is
expected because there are two distinct SqlConnections. Even though the connection
string is the same, TransactionScope treats these ADO.NET objects as unique resources.
&lt;/p&gt;
&lt;p&gt;
This has additional implications when connection pooling comes into play. After I
close the first connection, it is returned to the pool and is available for use. If
this connection is requested for use, it will no longer be available to commit or
abort this transaction, and you will see the dreaded MSDTC error "Communication with
the underlying transaction manager has failed."
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;2) Executing two ADO.NET SqlCommands in the same SqlConnection&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red225\green225\blue138;\red43\green145\blue175;\red223\green223\blue191;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2             \cf3 {\b using}\cf1  (\cf4 SqlConnection\cf1  \cf5 con\cf1  = \cf3 {\b new}\cf1  \cf4 SqlConnection\cf1 (\cf4 ConfigurationManager\cf1 .\cf5 ConnectionStrings\cf1 [\cf6 "Testing"\cf1 ].\cf5 ConnectionString\cf1 ))\par ??            \{\par ??                \cf4 SqlTransaction\cf1  \cf5 tran\cf1  = \cf3 {\b null}\cf1 ;\par ??                \cf3 {\b try}\par ??\cf1                 \{\par ??                    \cf5 con\cf1 .\cf5 Open\cf1 ();\par ??                    \cf5 tran\cf1  = \cf5 con\cf1 .\cf5 BeginTransaction\cf1 ();\par ??                    \cf3 {\b using}\cf1  (\cf4 SqlCommand\cf1  \cf5 cmd\cf1  = \cf3 {\b new}\cf1  \cf4 SqlCommand\cf1 (\cf6 "usp_ErrorLog_Insert"\cf1 , \cf5 con\cf1 ))\par ??                    \{\par ??                        \cf5 cmd\cf1 .\cf5 Transaction\cf1  = \cf5 tran\cf1 ;\par ??                        \cf5 cmd\cf1 .\cf5 CommandType\cf1  = \cf5 System\cf1 .\cf5 Data\cf1 .\cf4 CommandType\cf1 .\cf5 StoredProcedure\cf1 ;\par ??                        \cf5 cmd\cf1 .\cf5 Parameters\cf1 .\cf5 AddWithValue\cf1 (\cf6 "Message"\cf1 , \cf6 "Testing 1"\cf1 );\par ??                        \cf5 cmd\cf1 .\cf5 Parameters\cf1 .\cf5 AddWithValue\cf1 (\cf6 "UserID"\cf1 , \cf7 5150\cf1 );\par ??                        \cf5 cmd\cf1 .\cf5 ExecuteNonQuery\cf1 ();\par ??                    \}\par ??\par ??                    \cf3 {\b using}\cf1  (\cf4 SqlCommand\cf1  \cf5 cmd\cf1  = \cf3 {\b new}\cf1  \cf4 SqlCommand\cf1 (\cf6 "usp_ErrorLog_Insert"\cf1 , \cf5 con\cf1 ))\par ??                    \{\par ??                        \cf5 cmd\cf1 .\cf5 Transaction\cf1  = \cf5 tran\cf1 ;\par ??                        \cf5 cmd\cf1 .\cf5 CommandType\cf1  = \cf5 System\cf1 .\cf5 Data\cf1 .\cf4 CommandType\cf1 .\cf5 StoredProcedure\cf1 ;\par ??                        \cf5 cmd\cf1 .\cf5 Parameters\cf1 .\cf5 AddWithValue\cf1 (\cf6 "Message"\cf1 , \cf6 "Testing 2"\cf1 );\par ??                        \cf5 cmd\cf1 .\cf5 Parameters\cf1 .\cf5 AddWithValue\cf1 (\cf6 "UserID"\cf1 , \cf7 5150\cf1 );\par ??                        \cf5 cmd\cf1 .\cf5 ExecuteNonQuery\cf1 ();\par ??                    \}\par ??\par ??                    \cf5 tran\cf1 .\cf5 Commit\cf1 ();\par ??                \}\par ??                \cf3 {\b catch}\par ??\cf1                 \{\par ??                    \cf3 {\b if}\cf1  (\cf5 tran\cf1  != \cf3 {\b null}\cf1 ) \cf5 tran\cf1 .\cf5 Rollback\cf1 ();\par ??                \}\par ??                \cf3 {\b finally}\par ??\cf1                 \{\par ??                    \cf5 con\cf1 .\cf5 Close\cf1 ();\par ??                \}\par ??            \}}
--&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red225\green225\blue138;\red223\green223\blue191;\red43\green145\blue175;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2             \cf3 {\b string}\cf1  \cf4 connectionString\cf1  = \cf5 ConfigurationManager\cf1 .\cf4 ConnectionStrings\cf1 [\cf6 "Testing"\cf1 ].\cf4 ConnectionString\cf1 ;\par ??            \cf3 {\b using}\cf1  (\cf5 SqlConnection\cf1  \cf4 con\cf1  = \cf3 {\b new}\cf1  \cf5 SqlConnection\cf1 (\cf4 connectionString\cf1 ))\par ??            \{\par ??                \cf5 SqlTransaction\cf1  \cf4 tran\cf1  = \cf3 {\b null}\cf1 ;\par ??                \cf3 {\b try}\par ??\cf1                 \{\par ??                    \cf4 con\cf1 .\cf4 Open\cf1 ();\par ??                    \cf4 tran\cf1  = \cf4 con\cf1 .\cf4 BeginTransaction\cf1 ();\par ??                    \cf3 {\b using}\cf1  (\cf5 SqlCommand\cf1  \cf4 cmd\cf1  = \cf3 {\b new}\cf1  \cf5 SqlCommand\cf1 (\cf6 "usp_ErrorLog_Insert"\cf1 , \cf4 con\cf1 ))\par ??                    \{\par ??                        \cf4 cmd\cf1 .\cf4 Transaction\cf1  = \cf4 tran\cf1 ;\par ??                        \cf4 cmd\cf1 .\cf4 CommandType\cf1  = \cf4 System\cf1 .\cf4 Data\cf1 .\cf5 CommandType\cf1 .\cf4 StoredProcedure\cf1 ;\par ??                        \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "Message"\cf1 , \cf6 "Testing 1"\cf1 );\par ??                        \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "UserID"\cf1 , \cf7 5150\cf1 );\par ??                        \cf4 cmd\cf1 .\cf4 ExecuteNonQuery\cf1 ();\par ??                    \}\par ??\par ??                    \cf3 {\b using}\cf1  (\cf5 SqlCommand\cf1  \cf4 cmd\cf1  = \cf3 {\b new}\cf1  \cf5 SqlCommand\cf1 (\cf6 "usp_ErrorLog_Insert"\cf1 , \cf4 con\cf1 ))\par ??                    \{\par ??                        \cf4 cmd\cf1 .\cf4 Transaction\cf1  = \cf4 tran\cf1 ;\par ??                        \cf4 cmd\cf1 .\cf4 CommandType\cf1  = \cf4 System\cf1 .\cf4 Data\cf1 .\cf5 CommandType\cf1 .\cf4 StoredProcedure\cf1 ;\par ??                        \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "Message"\cf1 , \cf6 "Testing 2"\cf1 );\par ??                        \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "UserID"\cf1 , \cf7 5150\cf1 );\par ??                        \cf4 cmd\cf1 .\cf4 ExecuteNonQuery\cf1 ();\par ??                    \}\par ??\par ??                    \cf4 tran\cf1 .\cf4 Commit\cf1 ();\par ??                \}\par ??                \cf3 {\b catch}\par ??\cf1                 \{\par ??                    \cf3 {\b if}\cf1  (\cf4 tran\cf1  != \cf3 {\b null}\cf1 ) \cf4 tran\cf1 .\cf4 Rollback\cf1 ();\par ??                \}\par ??                \cf3 {\b finally}\par ??\cf1                 \{\par ??                    \cf4 con\cf1 .\cf4 Close\cf1 ();\par ??                \}\par ??            \}}
--&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red225\green225\blue138;\red223\green223\blue191;\red43\green145\blue175;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2             \cf3 {\b string}\cf1  \cf4 connectionString\cf1  = \cf5 ConfigurationManager\cf1 .\cf4 ConnectionStrings\cf1 [\cf6 "Testing"\cf1 ].\cf4 ConnectionString\cf1 ;\par ??            \cf3 {\b using}\cf1  (\cf5 TransactionScope\cf1  \cf4 scope\cf1  = \cf3 {\b new}\cf1  \cf5 TransactionScope\cf1 ())\par ??            \cf3 {\b using}\cf1  (\cf5 SqlConnection\cf1  \cf4 con\cf1  = \cf3 {\b new}\cf1  \cf5 SqlConnection\cf1 (\cf4 connectionString\cf1 ))\par ??            \{\par ??                \cf3 {\b using}\cf1  (\cf5 SqlCommand\cf1  \cf4 cmd\cf1  = \cf3 {\b new}\cf1  \cf5 SqlCommand\cf1 (\cf6 "usp_ErrorLog_Insert"\cf1 , \cf4 con\cf1 ))\par ??                \{\par ??                    \cf4 cmd\cf1 .\cf4 CommandType\cf1  = \cf4 System\cf1 .\cf4 Data\cf1 .\cf5 CommandType\cf1 .\cf4 StoredProcedure\cf1 ;\par ??                    \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "Message"\cf1 , \cf6 "Testing 1"\cf1 );\par ??                    \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "UserID"\cf1 , \cf7 5150\cf1 );\par ??                    \cf3 {\b try}\par ??\cf1                     \{\par ??                        \cf4 con\cf1 .\cf4 Open\cf1 ();\par ??                        \cf4 cmd\cf1 .\cf4 ExecuteNonQuery\cf1 ();\par ??                    \}\par ??                    \cf3 {\b finally}\par ??\cf1                     \{\par ??                        \cf4 con\cf1 .\cf4 Close\cf1 ();\par ??                    \}\par ??                \}\par ??\par ??                \cf5 Console\cf1 .\cf4 WriteLine\cf1 (\cf6 "Local Transaction ID: \{0\}"\cf1 , \cf5 Transaction\cf1 .\cf4 Current\cf1 .\cf4 TransactionInformation\cf1 .\cf4 LocalIdentifier\cf1 );\par ??                \cf5 Console\cf1 .\cf4 WriteLine\cf1 (\cf6 "Distributed Transaction ID: \{0\}"\cf1 , \cf5 Transaction\cf1 .\cf4 Current\cf1 .\cf4 TransactionInformation\cf1 .\cf4 DistributedIdentifier\cf1 .\cf4 ToString\cf1 ());\par ??\par ??                \cf3 {\b using}\cf1  (\cf5 SqlCommand\cf1  \cf4 cmd\cf1  = \cf3 {\b new}\cf1  \cf5 SqlCommand\cf1 (\cf6 "usp_ErrorLog_Insert"\cf1 , \cf4 con\cf1 ))\par ??                \{\par ??                    \cf4 cmd\cf1 .\cf4 CommandType\cf1  = \cf4 System\cf1 .\cf4 Data\cf1 .\cf5 CommandType\cf1 .\cf4 StoredProcedure\cf1 ;\par ??                    \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "Message"\cf1 , \cf6 "Testing 2"\cf1 );\par ??                    \cf4 cmd\cf1 .\cf4 Parameters\cf1 .\cf4 AddWithValue\cf1 (\cf6 "UserID"\cf1 , \cf7 5150\cf1 );\par ??                    \cf3 {\b try}\par ??\cf1                     \{\par ??                        \cf4 con\cf1 .\cf4 Open\cf1 ();\par ??                        \cf4 cmd\cf1 .\cf4 ExecuteNonQuery\cf1 ();\par ??                    \}\par ??                    \cf3 {\b finally}\par ??\cf1                     \{\par ??                        \cf4 con\cf1 .\cf4 Close\cf1 ();\par ??                    \}\par ??                \}\par ??\par ??                \cf5 Console\cf1 .\cf4 WriteLine\cf1 (\cf6 "Local Transaction ID: \{0\}"\cf1 , \cf5 Transaction\cf1 .\cf4 Current\cf1 .\cf4 TransactionInformation\cf1 .\cf4 LocalIdentifier\cf1 );\par ??                \cf5 Console\cf1 .\cf4 WriteLine\cf1 (\cf6 "Distributed Transaction ID: \{0\}"\cf1 , \cf5 Transaction\cf1 .\cf4 Current\cf1 .\cf4 TransactionInformation\cf1 .\cf4 DistributedIdentifier\cf1 .\cf4 ToString\cf1 ());\par ??\par ??                \cf4 scope\cf1 .\cf4 Complete\cf1 ();\par ??            \}}
--&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b string}\cf3  \cf4 connectionString\cf3  = \cf5 ConfigurationManager\cf3 .\cf4 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf4 ConnectionString\cf3 ;\par ??\cf1 {\b using}\cf3  (\cf5 TransactionScope\cf3  \cf4 scope\cf3  = \cf1 {\b new}\cf3  \cf5 TransactionScope\cf3 ())\par ??\cf1 {\b using}\cf3  (\cf5 SqlConnection\cf3  \cf4 con\cf3  = \cf1 {\b new}\cf3  \cf5 SqlConnection\cf3 (\cf4 connectionString\cf3 ))\par ??\{\par ??    \cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??    \{\par ??        \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 1"\cf3 );\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Open\cf3 ();\par ??            \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 LocalIdentifier\cf3 );\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 DistributedIdentifier\cf3 .\cf4 ToString\cf3 ());\par ??\par ??    \cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??    \{\par ??        \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 2"\cf3 );\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Open\cf3 ();\par ??            \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 LocalIdentifier\cf3 );\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 DistributedIdentifier\cf3 .\cf4 ToString\cf3 ());\par ??\par ??    \cf4 scope\cf3 .\cf4 Complete\cf3 ();\par ??\}}
--&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b string}\cf3  \cf4 connectionString\cf3  = \cf5 ConfigurationManager\cf3 .\cf4 ConnectionStrings\cf3 [\cf6 "Testing"\cf3 ].\cf4 ConnectionString\cf3 ;\par ??\cf1 {\b using}\cf3  (\cf5 TransactionScope\cf3  \cf4 scope\cf3  = \cf1 {\b new}\cf3  \cf5 TransactionScope\cf3 ())\par ??\cf1 {\b using}\cf3  (\cf5 SqlConnection\cf3  \cf4 con\cf3  = \cf1 {\b new}\cf3  \cf5 SqlConnection\cf3 (\cf4 connectionString\cf3 ))\par ??\{\par ??    \cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??    \{\par ??        \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 1"\cf3 );\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Open\cf3 ();\par ??            \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 LocalIdentifier\cf3 );\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 DistributedIdentifier\cf3 .\cf4 ToString\cf3 ());\par ??\par ??    \cf1 {\b using}\cf3  (\cf5 SqlCommand\cf3  \cf4 cmd\cf3  = \cf1 {\b new}\cf3  \cf5 SqlCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 , \cf4 con\cf3 ))\par ??    \{\par ??        \cf4 cmd\cf3 .\cf4 CommandType\cf3  = \cf4 System\cf3 .\cf4 Data\cf3 .\cf5 CommandType\cf3 .\cf4 StoredProcedure\cf3 ;\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "Message"\cf3 , \cf6 "Testing 2"\cf3 );\par ??        \cf4 cmd\cf3 .\cf4 Parameters\cf3 .\cf4 AddWithValue\cf3 (\cf6 "UserID"\cf3 , \cf7 5150\cf3 );\par ??        \cf1 {\b try}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Open\cf3 ();\par ??            \cf4 cmd\cf3 .\cf4 ExecuteNonQuery\cf3 ();\par ??        \}\par ??        \cf1 {\b finally}\par ??\cf3         \{\par ??            \cf4 con\cf3 .\cf4 Close\cf3 ();\par ??        \}\par ??    \}\par ??\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 LocalIdentifier\cf3 );\par ??    \cf5 Console\cf3 .\cf4 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf5 Transaction\cf3 .\cf4 Current\cf3 .\cf4 TransactionInformation\cf3 .\cf4 DistributedIdentifier\cf3 .\cf4 ToString\cf3 ());\par ??\par ??    \cf4 scope\cf3 .\cf4 Complete\cf3 ();\par ??\}}
--&gt;
&lt;/p&gt;
&lt;div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 765px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 250px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 69&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;connectionString&lt;/span&gt; = &lt;span style="COLOR: #2b91af"&gt;ConfigurationManager&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ConnectionStrings&lt;/span&gt;[&lt;span style="COLOR: #c89191"&gt;"Testing"&lt;/span&gt;].&lt;span style="COLOR: #dfdfbf"&gt;ConnectionString&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 70&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;TransactionScope&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;scope&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TransactionScope&lt;/span&gt;())
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 71&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;SqlConnection&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SqlConnection&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;connectionString&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 72&lt;/span&gt; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 73&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"usp_ErrorLog_Insert"&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 74&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 75&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;CommandType&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;CommandType&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;StoredProcedure&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 76&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Message"&lt;/span&gt;, &lt;span style="COLOR: #c89191"&gt;"Testing
1"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 77&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"UserID"&lt;/span&gt;, &lt;span style="COLOR: #8acccf"&gt;5150&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 78&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;try&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 79&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 80&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Open&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 81&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ExecuteNonQuery&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 82&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 83&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;finally&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 84&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 85&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Close&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 86&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 87&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 88&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 89&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;WriteLine&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Local
Transaction ID: {0}"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 90&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Transaction&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;TransactionInformation&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;LocalIdentifier&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 91&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;WriteLine&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Distributed
Transaction ID: {0}"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 92&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Transaction&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;TransactionInformation&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;DistributedIdentifier&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ToString&lt;/span&gt;());
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 93&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 94&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SqlCommand&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"usp_ErrorLog_Insert"&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;))
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 95&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 96&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;CommandType&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;CommandType&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;StoredProcedure&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 97&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Message"&lt;/span&gt;, &lt;span style="COLOR: #c89191"&gt;"Testing
2"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 98&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Parameters&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddWithValue&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"UserID"&lt;/span&gt;, &lt;span style="COLOR: #8acccf"&gt;5150&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 99&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;try&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 100&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 101&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Open&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 102&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ExecuteNonQuery&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 103&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 104&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;finally&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 105&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 106&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;con&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Close&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 107&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 108&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 109&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 110&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;WriteLine&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Local
Transaction ID: {0}"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 111&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Transaction&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;TransactionInformation&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;LocalIdentifier&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 112&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;WriteLine&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Distributed
Transaction ID: {0}"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 113&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Transaction&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;TransactionInformation&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;DistributedIdentifier&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ToString&lt;/span&gt;());
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 114&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 115&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;scope&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Complete&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 116&lt;/span&gt; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
This writes the following to the command line:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;font face="Courier New" size=2&gt;&lt;strong&gt;Local Transaction ID: e90f47f4-df80-496b-a9c0-0c45b2f452c4:1&lt;br&gt;
Distributed Transaction ID: 00000000-0000-0000-0000-000000000000&lt;br&gt;
Local Transaction ID: e90f47f4-df80-496b-a9c0-0c45b2f452c4:1&lt;br&gt;
Distributed Transaction ID: becac9c9-e15f-4370-9f73-7f369665bed7&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
This is not expected because both commands are part of the same connection. Of course
I am closing the connection to simulate an N-tier app where the data access layer
is maintaining it's own SQL access, opening and closing its connection as it should.
If I did not close the connection, you would not see a &lt;em&gt;Distributed Transaction
ID&lt;/em&gt; after the second command.
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;3) Executing two Enterprise Library commands&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red43\green145\blue175;\red223\green223\blue191;\red200\green145\blue145;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  (\cf4 TransactionScope\cf3  \cf5 scope\cf3  = \cf1 {\b new}\cf3  \cf4 TransactionScope\cf3 ())\par ??\{\par ??    \cf4 Database\cf3  \cf5 db\cf3  = \cf4 DatabaseFactory\cf3 .\cf5 CreateDatabase\cf3 (\cf6 "Testing"\cf3 );\par ??    \cf4 DbCommand\cf3  \cf5 cmd\cf3  = \cf5 db\cf3 .\cf5 GetStoredProcCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 );\par ??    \cf5 db\cf3 .\cf5 AddInParameter\cf3 (\cf5 cmd\cf3 , \cf6 "Message"\cf3 , \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 DbType\cf3 .\cf5 String\cf3 , \cf6 "Testing 1"\cf3 );\par ??    \cf5 db\cf3 .\cf5 AddInParameter\cf3 (\cf5 cmd\cf3 , \cf6 "UserID"\cf3 , \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 DbType\cf3 .\cf5 Int32\cf3 , \cf7 5150\cf3 );\par ??    \cf5 db\cf3 .\cf5 ExecuteNonQuery\cf3 (\cf5 cmd\cf3 );\par ??\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 LocalIdentifier\cf3 );\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 DistributedIdentifier\cf3 .\cf5 ToString\cf3 ());\par ??\par ??    \cf4 Database\cf3  \cf5 db1\cf3  = \cf4 DatabaseFactory\cf3 .\cf5 CreateDatabase\cf3 (\cf6 "Testing1"\cf3 );\par ??    \cf4 DbCommand\cf3  \cf5 cmd1\cf3  = \cf5 db\cf3 .\cf5 GetStoredProcCommand\cf3 (\cf6 "usp_ErrorLog_Insert"\cf3 );\par ??    \cf5 db1\cf3 .\cf5 AddInParameter\cf3 (\cf5 cmd1\cf3 , \cf6 "Message"\cf3 , \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 DbType\cf3 .\cf5 String\cf3 , \cf6 "Testing 2"\cf3 );\par ??    \cf5 db1\cf3 .\cf5 AddInParameter\cf3 (\cf5 cmd1\cf3 , \cf6 "UserID"\cf3 , \cf5 System\cf3 .\cf5 Data\cf3 .\cf4 DbType\cf3 .\cf5 Int32\cf3 , \cf7 5150\cf3 );\par ??    \cf5 db1\cf3 .\cf5 ExecuteNonQuery\cf3 (\cf5 cmd1\cf3 );\par ??\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Local Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 LocalIdentifier\cf3 );\par ??    \cf4 Console\cf3 .\cf5 WriteLine\cf3 (\cf6 "Distributed Transaction ID: \{0\}"\cf3 , \par ??        \cf4 Transaction\cf3 .\cf5 Current\cf3 .\cf5 TransactionInformation\cf3 .\cf5 DistributedIdentifier\cf3 .\cf5 ToString\cf3 ());\par ??\par ??    \cf5 scope\cf3 .\cf5 Complete\cf3 ();\par ??\}}
--&gt;
&lt;/p&gt;
&lt;div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 761px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 250px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 176&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;TransactionScope&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;scope&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TransactionScope&lt;/span&gt;())
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 177&lt;/span&gt; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 178&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Database&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;db&lt;/span&gt; = &lt;span style="COLOR: #2b91af"&gt;DatabaseFactory&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;CreateDatabase&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Testing"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 179&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;DbCommand&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;db&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;GetStoredProcCommand&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"usp_ErrorLog_Insert"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 180&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;db&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddInParameter&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;, &lt;span style="COLOR: #c89191"&gt;"Message"&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;DbType&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;String&lt;/span&gt;, &lt;span style="COLOR: #c89191"&gt;"Testing
1"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 181&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;db&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddInParameter&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;, &lt;span style="COLOR: #c89191"&gt;"UserID"&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;DbType&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Int32&lt;/span&gt;, &lt;span style="COLOR: #8acccf"&gt;5150&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 182&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;db&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ExecuteNonQuery&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;cmd&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 183&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 184&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;WriteLine&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Local
Transaction ID: {0}"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 185&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Transaction&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;TransactionInformation&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;LocalIdentifier&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 186&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;WriteLine&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Distributed
Transaction ID: {0}"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 187&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Transaction&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;TransactionInformation&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;DistributedIdentifier&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ToString&lt;/span&gt;());
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 188&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 189&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Database&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;db1&lt;/span&gt; = &lt;span style="COLOR: #2b91af"&gt;DatabaseFactory&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;CreateDatabase&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Testing1"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 190&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;DbCommand&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;cmd1&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;db&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;GetStoredProcCommand&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"usp_ErrorLog_Insert"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 191&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;db1&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddInParameter&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;cmd1&lt;/span&gt;, &lt;span style="COLOR: #c89191"&gt;"Message"&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;DbType&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;String&lt;/span&gt;, &lt;span style="COLOR: #c89191"&gt;"Testing
2"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 192&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;db1&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;AddInParameter&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;cmd1&lt;/span&gt;, &lt;span style="COLOR: #c89191"&gt;"UserID"&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Data&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;DbType&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Int32&lt;/span&gt;, &lt;span style="COLOR: #8acccf"&gt;5150&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 193&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;db1&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ExecuteNonQuery&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;cmd1&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 194&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 195&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;WriteLine&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Local
Transaction ID: {0}"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 196&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Transaction&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;TransactionInformation&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;LocalIdentifier&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 197&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;WriteLine&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Distributed
Transaction ID: {0}"&lt;/span&gt;, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 198&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Transaction&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;TransactionInformation&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;DistributedIdentifier&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ToString&lt;/span&gt;());
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 199&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 200&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;scope&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Complete&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 201&lt;/span&gt; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
This writes the following to the command line:
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;font face="Courier New" size=2&gt;&lt;strong&gt;Local Transaction ID: 6737b756-2d5b-4eff-902d-15f9ccd5c26f:3&lt;br&gt;
Distributed Transaction ID: 00000000-0000-0000-0000-000000000000&lt;br&gt;
Local Transaction ID: 6737b756-2d5b-4eff-902d-15f9ccd5c26f:3&lt;br&gt;
Distributed Transaction ID: 00000000-0000-0000-0000-000000000000&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Whoa! How cool is that? No DTC promotion. Enterprise Library is intelligently deciding
to keep the connection open when it is part of the transaction. This will save a lot
of wasted time as the promotion to DTC adds a noticeable delay. If I wasn't using
Enterprise Library already, I'd switch now.
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Useful links:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms172152.aspx"&gt;Implementing an Implicit
Transaction using Transaction Scope&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms730266.aspx"&gt;WCF Transactions&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms973865.aspx"&gt;Introducing System.Transactions
in the .NET Framework 2.0&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=5aef3f0a-3e66-4e87-8469-0411651d2aba" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,5aef3f0a-3e66-4e87-8469-0411651d2aba.aspx</comments>
      <category>C#</category>
      <category>MSDTC</category>
      <category>SQL</category>
      <category>Transactions</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=bc3f77a3-9d3a-44cf-ba92-d71125cdc5bd</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,bc3f77a3-9d3a-44cf-ba92-d71125cdc5bd.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,bc3f77a3-9d3a-44cf-ba92-d71125cdc5bd.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=bc3f77a3-9d3a-44cf-ba92-d71125cdc5bd</wfw:commentRss>
      <slash:comments>9</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Don't be so quick to blame the service or MSDTC when you see the error "Communication
with the underlying transaction manager has failed."
</p>
        <p>
          <strong>Symptom:</strong>
        </p>
        <p>
An error message that reads something like: 
</p>
        <blockquote>
          <p>
System.Transactions.TransactionManagerCommunicationException: Communication with the
underlying transaction manager has failed. ---&gt; System.Runtime.InteropServices.COMException
(0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
</p>
        </blockquote>
        <p>
          <strong>Solutions:</strong>
        </p>
        <p>
  
</p>
        <p>
"Check your firewall settings" is what you will find in almost all forum posts and
on MSDN. You need port 135 open bi-directionally for RPC's end point mapper (EPM).
You also need ports 1024-5000 open bi-directionally if you have not specified your
own port settings for RPC in the registry. If you have your own ports specified in
the registry, then those need to be open bi-directionally. 
</p>
        <p>
  
</p>
        <p>
          <strong>
            <em>WHAT ?!? </em>
          </strong>It may also be your code causing the issue. If
you are using TransactionScope, you have to be mindful of every method called within
the using braces. Looking at the code below, you will see two service calls and a
seemingly innocuous <em>ShouldContinue()</em> method checking to see if the second
operation should be called. 
</p>
        <blockquote>
          <p>
            <font color="#0000ff">using</font> (TransactionScope scope = new TransactionScope()) 
</p>
          <p>
            <font color="#0000ff">using</font> (MyServiceClient proxy = new MyServiceClient()) 
</p>
          <p>
{ 
</p>
          <p>
       proxy.DoOperationOne(someID); 
</p>
          <p>
       
</p>
          <p>
       <font color="#0000ff">if</font> (ShouldContinue()) <font color="#008000">//
uh, oh! What if this has an ADO.NET connection that is opened and closed inside it?</font></p>
          <p>
       { 
</p>
          <p>
              
proxy.DoOperationTwo(someOtherID); 
</p>
          <p>
       } 
</p>
          <p>
}
</p>
        </blockquote>
        <p>
If <em>ShouldContinue()</em> opens and closes an SqlConnection, the TransactionScope
object has no means by which to commit or rollback this part of the transaction. This
will cause the error "Communication with the underlying transaction manager has failed." 
</p>
        <p>
  
</p>
        <p>
1. If you do not need to results of <em>DoOperationOne()</em> to feed <em>ShouldContinue()</em>,
then do that logic before the TransactionScope using block. 
</p>
        <p>
2. If you do need the result of <em>DoOperationOne()</em> to feed <em>ShouldContinue()</em>,
then you can wrap the internals of <em>ShouldContinue()</em> with a TransactionScope
using block specifying TransactionScopeOption.Suppress. This will not add the resource
access contained within the block to the ambient transaction. 
</p>
        <p>
3. Use an intelligent data access library like Enterprise Library that manages your
connections for you. It won't close the connection if enlisted in a transaction. 
</p>
        <p>
  
</p>
        <p>
Look at your code before you involve your network dudes. This is more common when
integrating legacy code with new service calls. 
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=bc3f77a3-9d3a-44cf-ba92-d71125cdc5bd" />
      </body>
      <title>Communication with the underlying transaction manager has failed.</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,bc3f77a3-9d3a-44cf-ba92-d71125cdc5bd.aspx</guid>
      <link>http://offroadcoder.com/2008/10/30/CommunicationWithTheUnderlyingTransactionManagerHasFailed.aspx</link>
      <pubDate>Thu, 30 Oct 2008 02:54:29 GMT</pubDate>
      <description>&lt;p&gt;
Don't be so quick to blame the service or MSDTC when you see the error "Communication
with the underlying transaction manager has failed."
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Symptom:&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
An error message that reads something like: &lt;blockquote&gt; 
&lt;p&gt;
System.Transactions.TransactionManagerCommunicationException: Communication with the
underlying transaction manager has failed. ---&amp;gt; System.Runtime.InteropServices.COMException
(0x80004005): Error HRESULT E_FAIL has been returned from a call to a COM component.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
&lt;strong&gt;Solutions:&lt;/strong&gt; 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
"Check your firewall settings" is what you will find in almost all forum posts and
on MSDN. You need port 135 open bi-directionally for RPC's end point mapper (EPM).
You also need ports 1024-5000 open bi-directionally if you have not specified your
own port settings for RPC in the registry. If you have your own ports specified in
the registry, then those need to be open bi-directionally. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
&lt;strong&gt;&lt;em&gt;WHAT ?!? &lt;/em&gt;&lt;/strong&gt;It may also be your code causing the issue. If
you are using TransactionScope, you have to be mindful of every method called within
the using braces. Looking at the code below, you will see two service calls and a
seemingly innocuous &lt;em&gt;ShouldContinue()&lt;/em&gt; method checking to see if the second
operation should be called. &lt;blockquote&gt; 
&lt;p&gt;
&lt;font color="#0000ff"&gt;using&lt;/font&gt; (TransactionScope scope = new TransactionScope()) 
&lt;p&gt;
&lt;font color="#0000ff"&gt;using&lt;/font&gt; (MyServiceClient proxy = new MyServiceClient()) 
&lt;p&gt;
{ 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; proxy.DoOperationOne(someID); 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;font color="#0000ff"&gt;if&lt;/font&gt; (ShouldContinue()) &lt;font color="#008000"&gt;//
uh, oh! What if this has an ADO.NET connection that is opened and closed inside it?&lt;/font&gt; 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; { 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
proxy.DoOperationTwo(someOtherID); 
&lt;p&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } 
&lt;p&gt;
}
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
If &lt;em&gt;ShouldContinue()&lt;/em&gt; opens and closes an SqlConnection, the TransactionScope
object has no means by which to commit or rollback this part of the transaction. This
will cause the error "Communication with the underlying transaction manager has failed." 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
1. If you do not need to results of &lt;em&gt;DoOperationOne()&lt;/em&gt; to feed &lt;em&gt;ShouldContinue()&lt;/em&gt;,
then do that logic before the TransactionScope using block. 
&lt;p&gt;
2. If you do need the result of &lt;em&gt;DoOperationOne()&lt;/em&gt; to feed &lt;em&gt;ShouldContinue()&lt;/em&gt;,
then you can wrap the internals of &lt;em&gt;ShouldContinue()&lt;/em&gt; with a TransactionScope
using block specifying TransactionScopeOption.Suppress. This will not add the resource
access contained within the block to the ambient transaction. 
&lt;p&gt;
3. Use an intelligent data access library like Enterprise Library that manages your
connections for you. It won't close the connection if enlisted in a transaction. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Look at your code before you involve your network dudes. This is more common when
integrating legacy code with new service calls. 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=bc3f77a3-9d3a-44cf-ba92-d71125cdc5bd" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,bc3f77a3-9d3a-44cf-ba92-d71125cdc5bd.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>MSDTC</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=cfeeb9f7-2a9e-40a5-99ce-dea714e3284d</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,cfeeb9f7-2a9e-40a5-99ce-dea714e3284d.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,cfeeb9f7-2a9e-40a5-99ce-dea714e3284d.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=cfeeb9f7-2a9e-40a5-99ce-dea714e3284d</wfw:commentRss>
      <slash:comments>9</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
WCF never ceases to amaze me. Around every corner is another fascinating use for WCF,
and much forethought on Microsoft's part to make it look and behave great. I wanted
to expose my services to my AJAX functions on my web site. I did not want to change
my class library because it is used by other clients. I could just add the service
classes to this web site, but why re-do when you can re-use.
</p>
        <p>
If you have an existing WCF Service Library, you will need to expose it with the <font color="#0000ff">AspNetCompatibilityRequirementsMode</font>.Allowed
attribute on the service class to make it visible to ASP.NET clients. To avoid changing
your service library in any way, the easiest thing to do is to add a new class to
your web site that inherits from your service class. In this example, my existing
service library uses the <em>JeepServices</em> namespace. Notice there is no implementation
in this class. It is simply a placeholder for the real service implementation with
the compatibility attribute attached.
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  \cf4 System\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 Linq\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 Runtime\cf3 .\cf4 Serialization\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 ServiceModel\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 ServiceModel\cf3 .\cf4 Activation\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 ServiceModel\cf3 .\cf4 Web\cf3 ;\par ??\par ??[\cf5 ServiceBehavior\cf3 (\cf4 IncludeExceptionDetailInFaults\cf3  = \cf1 {\b true}\cf3 )]\par ??[\cf5 AspNetCompatibilityRequirements\cf3 (\cf4 RequirementsMode\cf3  = \cf5 AspNetCompatibilityRequirementsMode\cf3 .\cf4 Allowed\cf3 )]\par ??\cf1 {\b public}\cf3  \cf1 {\b class}\cf3  \cf5 WebHttpService\cf3  : \cf4 JeepServices\cf3 .\cf5 Service\par ??\cf3 \{\par ??\}}
-->
        </p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  \cf4 System\cf3 .\cf4 ServiceModel\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 ServiceModel\cf3 .\cf4 Activation\cf3 ;\par ??\par ??[\cf5 ServiceBehavior\cf3 (\cf4 IncludeExceptionDetailInFaults\cf3  = \cf1 {\b true}\cf3 )]\par ??[\cf5 AspNetCompatibilityRequirements\cf3 (\cf4 RequirementsMode\cf3  = \cf5 AspNetCompatibilityRequirementsMode\cf3 .\cf4 Allowed\cf3 )]\par ??\cf1 {\b public}\cf3  \cf1 {\b class}\cf3  \cf5 WebHttpService\cf3  : \cf4 JeepServices\cf3 .\cf5 Service\par ??\cf3 \{\par ??\}}
-->
        </p>
        <div style="font-size: 9pt; background: #3f3f3f; width: 817px; color: #dcdccc; font-family: consolas; height: 126px">
          <p style="margin: 0px">
            <span style="color: #85ac8d">    1</span> <span style="font-weight: bold; color: #e1e18a">using</span><span style="color: #dfdfbf">System</span>.<span style="color: #dfdfbf">ServiceModel</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    2</span> <span style="font-weight: bold; color: #e1e18a">using</span><span style="color: #dfdfbf">System</span>.<span style="color: #dfdfbf">ServiceModel</span>.<span style="color: #dfdfbf">Activation</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    3</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    4</span> [<span style="color: #2b91af">ServiceBehavior</span>]
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    5</span> [<span style="color: #2b91af">AspNetCompatibilityRequirements</span>(<span style="color: #dfdfbf">RequirementsMode</span> = <span style="color: #2b91af">AspNetCompatibilityRequirementsMode</span>.<span style="color: #dfdfbf">Allowed</span>)]
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    6</span> <span style="font-weight: bold; color: #e1e18a">public</span><span style="font-weight: bold; color: #e1e18a">class</span><span style="color: #2b91af">WebHttpService</span> : <span style="color: #dfdfbf">JeepServices</span>.<span style="color: #2b91af">Service</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    7</span> {
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    8</span> }
</p>
        </div>
        <p>
        </p>
        <p>
Now that I have a ASP.NET compatible service, I need to expose it to the web site
clients. Create a service file (.svc), and change the <em>Service</em> and <em>CodeBehind</em> attributes
to point to the .svc file. The last thing you need is the <em>Factory</em> attribute.
This notifies WCF of this service, eliminating the need for a configuration file entry
for the service endpoint. In fact, you don't even need the &lt;system.servicemodel&gt;
in your configuration file at all. This is because it is only hosted as a web script,
and cannot be called outside of the web site.
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green238\blue98;\red239\green239\blue143;\red63\green63\blue63;\red220\green220\blue204;\red227\green206\blue171;\red223\green223\blue191;\red204\green147\blue147;}??\fs18 \cb2\highlight2 &lt;%\cf3\cb4\highlight4 @\cf5  \cf6 ServiceHost\cf5  \cf7 Language\cf3 =\cf8 "C#"\cf5  \cf7 Debug\cf3 =\cf8 "true"\cf5  \cf7 Service\cf3 =\cf8 "WebHttpService"\cf5  \cf7 CodeBehind\cf3 =\cf8 "~/App_Code/WebHttpService.cs"\par ??\cf5 \tab \cf7 Factory\cf3 =\cf8 "System.ServiceModel.Activation.WebScriptServiceHostFactory"\cf5  \cf0\cb2\highlight2 %&gt;}
-->
        </p>
        <div style="font-size: 9pt; background: #3f3f3f; width: 816px; color: #dcdccc; font-family: consolas; height: 43px">
          <p style="margin: 0px">
            <span style="color: #85ac8d">    1</span> <span style="background: #ffee62">&lt;%</span><span style="color: #efef8f">@</span><span style="color: #e3ceab">ServiceHost</span><span style="color: #dfdfbf">Language</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"C#"</span><span style="color: #dfdfbf">Debug</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"true"</span><span style="color: #dfdfbf">Service</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"WebHttpService"</span><span style="color: #dfdfbf">CodeBehind</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"~/App_Code/WebHttpService.cs"</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    2</span>     <span style="color: #dfdfbf">Factory</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"System.ServiceModel.Activation.WebScriptServiceHostFactory"</span><span style="background: #ffee62">%&gt;</span></p>
        </div>
        <p>
 
</p>
        <p>
In your web page you will need a few things. First your will need a <em>ScriptManager</em> with
a <em>ServiceReference</em> to the .svc file. You will then need the Javascript functions
to make the call (<em>DoJeepWork</em>), handle the success message (<em>OnJeepWorkSucceeded</em>),
and handle the failure message (<em>OnJeepWorkFailed</em>). Notice in <em>DoJeepWork</em> that
you don't call the service by it's service name <em>WebHttpService</em>, you call
it by the ServiceContract namespace and name. For this example, my interface has ServiceContract
attributes Namespace = "JeepServices", and Name = "JeepServiceContract". Now you just
wire up a ASP.NET control's OnClientClick or an input or anchor tag's onclick to <em>DoJeepWork()</em> and
you are good to go.
</p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green238\blue98;\red239\green239\blue143;\red63\green63\blue63;\red220\green220\blue204;\red227\green206\blue171;\red223\green223\blue191;\red204\green147\blue147;\red225\green225\blue138;\red200\green145\blue145;\red127\green159\blue127;}??\fs18 \cb2\highlight2 &lt;%\cf3\cb4\highlight4 @\cf5  \cf6 Page\cf5  \cf7 Language\cf3 =\cf8 "C#"\cf5  \cf7 AutoEventWireup\cf3 =\cf8 "true"\cf5  \cf7 CodeFile\cf3 =\cf8 "Default.aspx.cs"\cf5  \cf7 Inherits\cf3 =\cf8 "_Default"\cf5  \cf0\cb2\highlight2 %&gt;\par ??\par ??\cf3\cb4\highlight4 &lt;!\cf6 DOCTYPE\cf5  \cf7 html\cf5  \cf7 PUBLIC\cf5  \cf8 "-//W3C//DTD XHTML 1.0 Transitional//EN"\cf5  \cf8 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"\cf3 &gt;\par ??&lt;\cf6 html\cf5  \cf7 xmlns\cf3 =\cf8 "http://www.w3.org/1999/xhtml"\cf3 &gt;\par ??&lt;\cf6 head\cf5  \cf7 runat\cf3 =\cf8 "server"\cf3 &gt;\par ??\cf5 \tab \cf3 &lt;\cf6 title\cf3 &gt;\cf5 Test page\cf3 &lt;/\cf6 title\cf3 &gt;\par ??\par ??\cf5 \tab \cf3 &lt;\cf6 script\cf5  \cf7 type\cf3 =\cf8 "text/javascript"\cf3 &gt;\par ??\cf5 \tab \tab \cf9 {\b function}\cf5  \cf7 DoJeepWork\cf5 ()\par ??\tab \tab \{    \par ??\tab \tab \tab \cf7 JeepServices\cf5 .\cf7 JeepServiceContract\cf5 .\cf7 DoWork\cf5 (\cf7 OnJeepWorkSuccedeed\cf5 , \cf7 OnJeepWorkFailed\cf5 );\par ??\tab \tab \}\par ??\tab \tab \cf9 {\b function}\cf5  \cf7 OnJeepWorkSuccedeed\cf5 (\cf7 res\cf5 )\par ??\tab \tab \{\par ??\tab \tab \tab \cf7 document\cf5 .\cf7 getElementById\cf5 (\cf10 "&lt;%= this.lblMessage.ClientID %&gt;"\cf5 ).\cf7 innerText\cf5  = \cf7 res\cf5 ;\par ??\tab \tab \}\par ??\tab \tab \cf9 {\b function}\cf5  \cf7 OnJeepWorkFailed\cf5 (\cf7 error\cf5 )\par ??\tab \tab \{\par ??\tab \tab     \cf11 // Alert user to the error.    \par ??\cf5 \tab \tab     \cf7 alert\cf5 (\cf7 error\cf5 .\cf7 get_message\cf5 ());\par ??\tab \tab \}\par ??\tab \cf3 &lt;/\cf6 script\cf3 &gt;\par ??\par ??&lt;/\cf6 head\cf3 &gt;\par ??&lt;\cf6 body\cf3 &gt;\par ??\cf5 \tab \cf3 &lt;\cf6 form\cf5  \cf7 id\cf3 =\cf8 "form1"\cf5  \cf7 runat\cf3 =\cf8 "server"\cf3 &gt;\par ??\cf5 \tab \cf3 &lt;\cf6 div\cf3 &gt;\par ??\cf5 \tab \tab \cf3 &lt;\cf6 asp\cf3 :\cf6 ScriptManager\cf5  \cf7 runat\cf3 =\cf8 "server"\cf3 &gt;\par ??\cf5 \tab \tab \tab \cf3 &lt;\cf6 Services\cf3 &gt;\par ??\cf5 \tab \tab \tab \tab \cf3 &lt;\cf6 asp\cf3 :\cf6 ServiceReference\cf5  \cf7 Path\cf3 =\cf8 "~/Services/WebHttpService.svc"\cf5  \cf7 InlineScript\cf3 =\cf8 "false"\cf5  \cf3 /&gt;\par ??\cf5 \tab \tab \tab \cf3 &lt;/\cf6 Services\cf3 &gt;\par ??\cf5 \tab \tab \cf3 &lt;/\cf6 asp\cf3 :\cf6 ScriptManager\cf3 &gt;\par ??\cf5 \tab \tab \cf3 &lt;\cf6 asp\cf3 :\cf6 Label\cf5  \cf7 ID\cf3 =\cf8 "lblMessage"\cf5  \cf7 runat\cf3 =\cf8 "server"\cf5  \cf7 Text\cf3 =\cf8 "No work has been done"\cf5  \cf3 /&gt;\cf5  \cf3 &lt;\cf6 a\cf5  \cf7 href\cf3 =\cf8 "javascript:void(0); DoJeepWork()"\cf3 &gt;\cf5 Do Work\cf3 &lt;/\cf6 a\cf3 &gt;\par ??\cf5 \tab \cf3 &lt;/\cf6 div\cf3 &gt;\par ??\cf5 \tab \cf3 &lt;/\cf6 form\cf3 &gt;\par ??&lt;/\cf6 body\cf3 &gt;\par ??&lt;/\cf6 html\cf3 &gt;}
-->
        </p>
        <p>
        </p>
        <p>
          <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green238\blue98;\red239\green239\blue143;\red63\green63\blue63;\red220\green220\blue204;\red227\green206\blue171;\red223\green223\blue191;\red204\green147\blue147;\red225\green225\blue138;\red200\green145\blue145;\red127\green159\blue127;}??\fs18 \cb2\highlight2 &lt;%\cf3\cb4\highlight4 @\cf5  \cf6 Page\cf5  \cf7 Language\cf3 =\cf8 "C#"\cf5  \cf7 AutoEventWireup\cf3 =\cf8 "true"\cf5  \cf7 CodeFile\cf3 =\cf8 "Default.aspx.cs"\cf5  \cf7 Inherits\cf3 =\cf8 "_Default"\cf5  \cf0\cb2\highlight2 %&gt;\par ??\par ??\cf3\cb4\highlight4 &lt;!\cf6 DOCTYPE\cf5  \cf7 html\cf5  \cf7 PUBLIC\cf5  \cf8 "-//W3C//DTD XHTML 1.0 Transitional//EN"\par ??"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"\cf3 &gt;\par ??&lt;\cf6 html\cf5  \cf7 xmlns\cf3 =\cf8 "http://www.w3.org/1999/xhtml"\cf3 &gt;\par ??&lt;\cf6 head\cf5  \cf7 runat\cf3 =\cf8 "server"\cf3 &gt;\par ??\cf5 \tab \cf3 &lt;\cf6 title\cf3 &gt;\cf5 Test page\cf3 &lt;/\cf6 title\cf3 &gt;\par ??\par ??\cf5 \tab \cf3 &lt;\cf6 script\cf5  \cf7 type\cf3 =\cf8 "text/javascript"\cf3 &gt;\par ??\cf5 \tab \tab \cf9 {\b function}\cf5  \cf7 DoJeepWork\cf5 () \{\par ??\tab \tab \tab \cf7 JeepServices\cf5 .\cf7 JeepServiceContract\cf5 .\cf7 DoWork\cf5 (\cf7 OnJeepWorkSuccedeed\cf5 , \cf7 OnJeepWorkFailed\cf5 );\par ??\tab \tab \}\par ??\tab \tab \cf9 {\b function}\cf5  \cf7 OnJeepWorkSuccedeed\cf5 (\cf7 res\cf5 ) \{\par ??\tab \tab \tab \cf7 document\cf5 .\cf7 getElementById\cf5 (\cf10 "&lt;%= this.lblMessage.ClientID %&gt;"\cf5 ).\cf7 innerText\cf5  = \cf7 res\cf5 ;\par ??\tab \tab \}\par ??\tab \tab \cf9 {\b function}\cf5  \cf7 OnJeepWorkFailed\cf5 (\cf7 error\cf5 ) \{\par ??\tab \tab \tab \cf11 // Alert user to the error.    \par ??\cf5 \tab \tab \tab \cf7 alert\cf5 (\cf7 error\cf5 .\cf7 get_message\cf5 ());\par ??\tab \tab \}\par ??\tab \cf3 &lt;/\cf6 script\cf3 &gt;\par ??\par ??&lt;/\cf6 head\cf3 &gt;\par ??&lt;\cf6 body\cf3 &gt;\par ??\cf5 \tab \cf3 &lt;\cf6 form\cf5  \cf7 id\cf3 =\cf8 "form1"\cf5  \cf7 runat\cf3 =\cf8 "server"\cf3 &gt;\par ??\cf5 \tab \cf3 &lt;\cf6 div\cf3 &gt;\par ??\cf5 \tab \tab \cf3 &lt;\cf6 asp\cf3 :\cf6 ScriptManager\cf5  \cf7 runat\cf3 =\cf8 "server"\cf3 &gt;\par ??\cf5 \tab \tab \tab \cf3 &lt;\cf6 Services\cf3 &gt;\par ??\cf5 \tab \tab \tab \tab \cf3 &lt;\cf6 asp\cf3 :\cf6 ServiceReference\cf5  \cf7 Path\cf3 =\cf8 "~/Services/WebHttpService.svc"\cf5  \cf7 InlineScript\cf3 =\cf8 "false"\cf5  \cf3 /&gt;\par ??\cf5 \tab \tab \tab \cf3 &lt;/\cf6 Services\cf3 &gt;\par ??\cf5 \tab \tab \cf3 &lt;/\cf6 asp\cf3 :\cf6 ScriptManager\cf3 &gt;\par ??\cf5 \tab \tab \cf3 &lt;\cf6 asp\cf3 :\cf6 Label\cf5  \cf7 ID\cf3 =\cf8 "lblMessage"\cf5  \cf7 runat\cf3 =\cf8 "server"\cf5  \cf7 Text\cf3 =\cf8 "No work has been done"\cf5  \cf3 /&gt;\par ??\cf5 \tab \tab \cf3 &lt;\cf6 a\cf5  \cf7 href\cf3 =\cf8 "javascript:void(0); DoJeepWork()"\cf3 &gt;\cf5 Do Work\cf3 &lt;/\cf6 a\cf3 &gt;\par ??\cf5 \tab \cf3 &lt;/\cf6 div\cf3 &gt;\par ??\cf5 \tab \cf3 &lt;/\cf6 form\cf3 &gt;\par ??&lt;/\cf6 body\cf3 &gt;\par ??&lt;/\cf6 html\cf3 &gt;\par ??}
-->
        </p>
        <div style="font-size: 9pt; background: #3f3f3f; width: 819px; color: #dcdccc; font-family: consolas; height: 519px">
          <p style="margin: 0px">
            <span style="color: #85ac8d">    1</span> <span style="background: #ffee62">&lt;%</span><span style="color: #efef8f">@</span><span style="color: #e3ceab">Page</span><span style="color: #dfdfbf">Language</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"C#"</span><span style="color: #dfdfbf">AutoEventWireup</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"true"</span><span style="color: #dfdfbf">CodeFile</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"Default.aspx.cs"</span><span style="color: #dfdfbf">Inherits</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"_Default"</span><span style="background: #ffee62">%&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    2</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    3</span> <span style="color: #efef8f">&lt;!</span><span style="color: #e3ceab">DOCTYPE</span><span style="color: #dfdfbf">html</span><span style="color: #dfdfbf">PUBLIC</span><span style="color: #cc9393">"-//W3C//DTD
XHTML 1.0 Transitional//EN"</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    4</span> <span style="color: #cc9393">"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    5</span> <span style="color: #efef8f">&lt;</span><span style="color: #e3ceab">html</span><span style="color: #dfdfbf">xmlns</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"http://www.w3.org/1999/xhtml"</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    6</span> <span style="color: #efef8f">&lt;</span><span style="color: #e3ceab">head</span><span style="color: #dfdfbf">runat</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"server"</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    7</span>     <span style="color: #efef8f">&lt;</span><span style="color: #e3ceab">title</span><span style="color: #efef8f">&gt;</span>Test
page<span style="color: #efef8f">&lt;/</span><span style="color: #e3ceab">title</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    8</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">    9</span>     <span style="color: #efef8f">&lt;</span><span style="color: #e3ceab">script</span><span style="color: #dfdfbf">type</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"text/javascript"</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   10</span>         <span style="font-weight: bold; color: #e1e18a">function</span><span style="color: #dfdfbf">DoJeepWork</span>()
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   11</span>             <span style="color: #dfdfbf">JeepServices</span>.<span style="color: #dfdfbf">JeepServiceContract</span>.<span style="color: #dfdfbf">DoWork</span>(<span style="color: #dfdfbf">OnJeepWorkSuccedeed</span>, <span style="color: #dfdfbf">OnJeepWorkFailed</span>);
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   12</span>        
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   13</span>         <span style="font-weight: bold; color: #e1e18a">function</span><span style="color: #dfdfbf">OnJeepWorkSuccedeed</span>(<span style="color: #dfdfbf">res</span>)
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   14</span>             <span style="color: #dfdfbf">document</span>.<span style="color: #dfdfbf">getElementById</span>(<span style="color: #c89191">"&lt;%=
this.lblMessage.ClientID %&gt;"</span>).<span style="color: #dfdfbf">innerText</span> = <span style="color: #dfdfbf">res</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   15</span>        
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   16</span>         <span style="font-weight: bold; color: #e1e18a">function</span><span style="color: #dfdfbf">OnJeepWorkFailed</span>(<span style="color: #dfdfbf">error</span>)
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   17</span>             <span style="color: #7f9f7f">//
Alert user to the error.    </span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   18</span>             <span style="color: #dfdfbf">alert</span>(<span style="color: #dfdfbf">error</span>.<span style="color: #dfdfbf">get_message</span>());
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   19</span>        
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   20</span>     <span style="color: #efef8f">&lt;/</span><span style="color: #e3ceab">script</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   21</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   22</span> <span style="color: #efef8f">&lt;/</span><span style="color: #e3ceab">head</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   23</span> <span style="color: #efef8f">&lt;</span><span style="color: #e3ceab">body</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   24</span>     <span style="color: #efef8f">&lt;</span><span style="color: #e3ceab">form</span><span style="color: #dfdfbf">id</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"form1"</span><span style="color: #dfdfbf">runat</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"server"</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   25</span>     <span style="color: #efef8f">&lt;</span><span style="color: #e3ceab">div</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   26</span>         <span style="color: #efef8f">&lt;</span><span style="color: #e3ceab">asp</span><span style="color: #efef8f">:</span><span style="color: #e3ceab">ScriptManager</span><span style="color: #dfdfbf">runat</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"server"</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   27</span>             <span style="color: #efef8f">&lt;</span><span style="color: #e3ceab">Services</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   28</span>                 <span style="color: #efef8f">&lt;</span><span style="color: #e3ceab">asp</span><span style="color: #efef8f">:</span><span style="color: #e3ceab">ServiceReference</span><span style="color: #dfdfbf">Path</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"~/Services/WebHttpService.svc"</span><span style="color: #dfdfbf">InlineScript</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"false"</span><span style="color: #efef8f">/&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   29</span>             <span style="color: #efef8f">&lt;/</span><span style="color: #e3ceab">Services</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   30</span>         <span style="color: #efef8f">&lt;/</span><span style="color: #e3ceab">asp</span><span style="color: #efef8f">:</span><span style="color: #e3ceab">ScriptManager</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   31</span>         <span style="color: #efef8f">&lt;</span><span style="color: #e3ceab">asp</span><span style="color: #efef8f">:</span><span style="color: #e3ceab">Label</span><span style="color: #dfdfbf">ID</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"lblMessage"</span><span style="color: #dfdfbf">runat</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"server"</span><span style="color: #dfdfbf">Text</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"No
work has been done"</span><span style="color: #efef8f">/&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   32</span>         <span style="color: #efef8f">&lt;</span><span style="color: #e3ceab">a</span><span style="color: #dfdfbf">href</span><span style="color: #efef8f">=</span><span style="color: #cc9393">"javascript:void(0);
DoJeepWork()"</span><span style="color: #efef8f">&gt;</span>Do Work<span style="color: #efef8f">&lt;/</span><span style="color: #e3ceab">a</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   33</span>     <span style="color: #efef8f">&lt;/</span><span style="color: #e3ceab">div</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   34</span>     <span style="color: #efef8f">&lt;/</span><span style="color: #e3ceab">form</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   35</span> <span style="color: #efef8f">&lt;/</span><span style="color: #e3ceab">body</span><span style="color: #efef8f">&gt;</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   36</span> <span style="color: #efef8f">&lt;/</span><span style="color: #e3ceab">html</span><span style="color: #efef8f">&gt;</span></p>
        </div>
        <p>
 
</p>
        <p>
Mission accomplished! Here you've seen how to expose an existing WCF service library
without changing any code in the library itself. Adding two files allowed the service
to be exposed to your AJAX clients. Best of all, there is no configuration file changes
to make.
</p>
        <p>
        </p>
        <p>
Useful Links:
</p>
        <ul>
          <li>
            <a href="http://msdn.microsoft.com/en-us/library/bb514961.aspx">Exposing WCF Services
to Client Script</a>
          </li>
        </ul>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=cfeeb9f7-2a9e-40a5-99ce-dea714e3284d" />
      </body>
      <title>Exposing existing WCF services to ASP.NET AJAX clients</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,cfeeb9f7-2a9e-40a5-99ce-dea714e3284d.aspx</guid>
      <link>http://offroadcoder.com/2008/09/21/ExposingExistingWCFServicesToASPNETAJAXClients.aspx</link>
      <pubDate>Sun, 21 Sep 2008 16:21:24 GMT</pubDate>
      <description>&lt;p&gt;
WCF never ceases to amaze me. Around every corner is another fascinating use for WCF,
and much forethought on Microsoft's part to make it look and behave great. I wanted
to expose my services to my AJAX functions on my web site. I did not want to change
my class library because it is used by other clients. I could just add the service
classes to this web site, but why re-do when you can re-use.
&lt;/p&gt;
&lt;p&gt;
If you have an existing WCF Service Library, you will need to expose it with the &lt;font color="#0000ff"&gt;AspNetCompatibilityRequirementsMode&lt;/font&gt;.Allowed
attribute on the service class to make it visible to ASP.NET clients. To avoid changing
your service library in any way, the easiest thing to do is to add a new class to
your web site that inherits from your service class. In this example, my existing
service library uses the &lt;em&gt;JeepServices&lt;/em&gt; namespace. Notice there is no implementation
in this class. It is simply a placeholder for the real service implementation with
the compatibility attribute attached.
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  \cf4 System\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 Linq\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 Runtime\cf3 .\cf4 Serialization\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 ServiceModel\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 ServiceModel\cf3 .\cf4 Activation\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 ServiceModel\cf3 .\cf4 Web\cf3 ;\par ??\par ??[\cf5 ServiceBehavior\cf3 (\cf4 IncludeExceptionDetailInFaults\cf3  = \cf1 {\b true}\cf3 )]\par ??[\cf5 AspNetCompatibilityRequirements\cf3 (\cf4 RequirementsMode\cf3  = \cf5 AspNetCompatibilityRequirementsMode\cf3 .\cf4 Allowed\cf3 )]\par ??\cf1 {\b public}\cf3  \cf1 {\b class}\cf3  \cf5 WebHttpService\cf3  : \cf4 JeepServices\cf3 .\cf5 Service\par ??\cf3 \{\par ??\}}
--&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  \cf4 System\cf3 .\cf4 ServiceModel\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 ServiceModel\cf3 .\cf4 Activation\cf3 ;\par ??\par ??[\cf5 ServiceBehavior\cf3 (\cf4 IncludeExceptionDetailInFaults\cf3  = \cf1 {\b true}\cf3 )]\par ??[\cf5 AspNetCompatibilityRequirements\cf3 (\cf4 RequirementsMode\cf3  = \cf5 AspNetCompatibilityRequirementsMode\cf3 .\cf4 Allowed\cf3 )]\par ??\cf1 {\b public}\cf3  \cf1 {\b class}\cf3  \cf5 WebHttpService\cf3  : \cf4 JeepServices\cf3 .\cf5 Service\par ??\cf3 \{\par ??\}}
--&gt;
&lt;/p&gt;
&lt;div style="font-size: 9pt; background: #3f3f3f; width: 817px; color: #dcdccc; font-family: consolas; height: 126px"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight: bold; color: #e1e18a"&gt;using&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;ServiceModel&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight: bold; color: #e1e18a"&gt;using&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;ServiceModel&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;Activation&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt; [&lt;span style="color: #2b91af"&gt;ServiceBehavior&lt;/span&gt;]
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt; [&lt;span style="color: #2b91af"&gt;AspNetCompatibilityRequirements&lt;/span&gt;(&lt;span style="color: #dfdfbf"&gt;RequirementsMode&lt;/span&gt; = &lt;span style="color: #2b91af"&gt;AspNetCompatibilityRequirementsMode&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;Allowed&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&lt;span style="font-weight: bold; color: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="font-weight: bold; color: #e1e18a"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;WebHttpService&lt;/span&gt; : &lt;span style="color: #dfdfbf"&gt;JeepServices&lt;/span&gt;.&lt;span style="color: #2b91af"&gt;Service&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt; {
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Now that I have a ASP.NET compatible service, I need to expose it to the web site
clients. Create a service file (.svc), and change the &lt;em&gt;Service&lt;/em&gt; and &lt;em&gt;CodeBehind&lt;/em&gt; attributes
to point to the .svc file. The last thing you need is the &lt;em&gt;Factory&lt;/em&gt; attribute.
This notifies WCF of this service, eliminating the need for a configuration file entry
for the service endpoint. In fact, you don't even need the &amp;lt;system.servicemodel&amp;gt;
in your configuration file at all. This is because it is only hosted as a web script,
and cannot be called outside of the web site.
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green238\blue98;\red239\green239\blue143;\red63\green63\blue63;\red220\green220\blue204;\red227\green206\blue171;\red223\green223\blue191;\red204\green147\blue147;}??\fs18 \cb2\highlight2 &amp;lt;%\cf3\cb4\highlight4 @\cf5  \cf6 ServiceHost\cf5  \cf7 Language\cf3 =\cf8 "C#"\cf5  \cf7 Debug\cf3 =\cf8 "true"\cf5  \cf7 Service\cf3 =\cf8 "WebHttpService"\cf5  \cf7 CodeBehind\cf3 =\cf8 "~/App_Code/WebHttpService.cs"\par ??\cf5 \tab \cf7 Factory\cf3 =\cf8 "System.ServiceModel.Activation.WebScriptServiceHostFactory"\cf5  \cf0\cb2\highlight2 %&amp;gt;}
--&gt;
&lt;/p&gt;
&lt;div style="font-size: 9pt; background: #3f3f3f; width: 816px; color: #dcdccc; font-family: consolas; height: 43px"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="background: #ffee62"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #efef8f"&gt;@&lt;/span&gt; &lt;span style="color: #e3ceab"&gt;ServiceHost&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;Language&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"C#"&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;Debug&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"true"&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;Service&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"WebHttpService"&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;CodeBehind&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"~/App_Code/WebHttpService.cs"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #dfdfbf"&gt;Factory&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"System.ServiceModel.Activation.WebScriptServiceHostFactory"&lt;/span&gt; &lt;span style="background: #ffee62"&gt;%&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
In your web page you will need a few things. First your will need a &lt;em&gt;ScriptManager&lt;/em&gt; with
a &lt;em&gt;ServiceReference&lt;/em&gt; to the .svc file. You will then need the Javascript functions
to make the call (&lt;em&gt;DoJeepWork&lt;/em&gt;), handle the success message (&lt;em&gt;OnJeepWorkSucceeded&lt;/em&gt;),
and handle the failure message (&lt;em&gt;OnJeepWorkFailed&lt;/em&gt;). Notice in &lt;em&gt;DoJeepWork&lt;/em&gt; that
you don't call the service by it's service name &lt;em&gt;WebHttpService&lt;/em&gt;, you call
it by the ServiceContract namespace and name. For this example, my interface has ServiceContract
attributes Namespace = "JeepServices", and Name = "JeepServiceContract". Now you just
wire up a ASP.NET control's OnClientClick or an input or anchor tag's onclick to &lt;em&gt;DoJeepWork()&lt;/em&gt; and
you are good to go.
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green238\blue98;\red239\green239\blue143;\red63\green63\blue63;\red220\green220\blue204;\red227\green206\blue171;\red223\green223\blue191;\red204\green147\blue147;\red225\green225\blue138;\red200\green145\blue145;\red127\green159\blue127;}??\fs18 \cb2\highlight2 &amp;lt;%\cf3\cb4\highlight4 @\cf5  \cf6 Page\cf5  \cf7 Language\cf3 =\cf8 "C#"\cf5  \cf7 AutoEventWireup\cf3 =\cf8 "true"\cf5  \cf7 CodeFile\cf3 =\cf8 "Default.aspx.cs"\cf5  \cf7 Inherits\cf3 =\cf8 "_Default"\cf5  \cf0\cb2\highlight2 %&amp;gt;\par ??\par ??\cf3\cb4\highlight4 &amp;lt;!\cf6 DOCTYPE\cf5  \cf7 html\cf5  \cf7 PUBLIC\cf5  \cf8 "-//W3C//DTD XHTML 1.0 Transitional//EN"\cf5  \cf8 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"\cf3 &amp;gt;\par ??&amp;lt;\cf6 html\cf5  \cf7 xmlns\cf3 =\cf8 "http://www.w3.org/1999/xhtml"\cf3 &amp;gt;\par ??&amp;lt;\cf6 head\cf5  \cf7 runat\cf3 =\cf8 "server"\cf3 &amp;gt;\par ??\cf5 \tab \cf3 &amp;lt;\cf6 title\cf3 &amp;gt;\cf5 Test page\cf3 &amp;lt;/\cf6 title\cf3 &amp;gt;\par ??\par ??\cf5 \tab \cf3 &amp;lt;\cf6 script\cf5  \cf7 type\cf3 =\cf8 "text/javascript"\cf3 &amp;gt;\par ??\cf5 \tab \tab \cf9 {\b function}\cf5  \cf7 DoJeepWork\cf5 ()\par ??\tab \tab \{    \par ??\tab \tab \tab \cf7 JeepServices\cf5 .\cf7 JeepServiceContract\cf5 .\cf7 DoWork\cf5 (\cf7 OnJeepWorkSuccedeed\cf5 , \cf7 OnJeepWorkFailed\cf5 );\par ??\tab \tab \}\par ??\tab \tab \cf9 {\b function}\cf5  \cf7 OnJeepWorkSuccedeed\cf5 (\cf7 res\cf5 )\par ??\tab \tab \{\par ??\tab \tab \tab \cf7 document\cf5 .\cf7 getElementById\cf5 (\cf10 "&amp;lt;%= this.lblMessage.ClientID %&amp;gt;"\cf5 ).\cf7 innerText\cf5  = \cf7 res\cf5 ;\par ??\tab \tab \}\par ??\tab \tab \cf9 {\b function}\cf5  \cf7 OnJeepWorkFailed\cf5 (\cf7 error\cf5 )\par ??\tab \tab \{\par ??\tab \tab     \cf11 // Alert user to the error.    \par ??\cf5 \tab \tab     \cf7 alert\cf5 (\cf7 error\cf5 .\cf7 get_message\cf5 ());\par ??\tab \tab \}\par ??\tab \cf3 &amp;lt;/\cf6 script\cf3 &amp;gt;\par ??\par ??&amp;lt;/\cf6 head\cf3 &amp;gt;\par ??&amp;lt;\cf6 body\cf3 &amp;gt;\par ??\cf5 \tab \cf3 &amp;lt;\cf6 form\cf5  \cf7 id\cf3 =\cf8 "form1"\cf5  \cf7 runat\cf3 =\cf8 "server"\cf3 &amp;gt;\par ??\cf5 \tab \cf3 &amp;lt;\cf6 div\cf3 &amp;gt;\par ??\cf5 \tab \tab \cf3 &amp;lt;\cf6 asp\cf3 :\cf6 ScriptManager\cf5  \cf7 runat\cf3 =\cf8 "server"\cf3 &amp;gt;\par ??\cf5 \tab \tab \tab \cf3 &amp;lt;\cf6 Services\cf3 &amp;gt;\par ??\cf5 \tab \tab \tab \tab \cf3 &amp;lt;\cf6 asp\cf3 :\cf6 ServiceReference\cf5  \cf7 Path\cf3 =\cf8 "~/Services/WebHttpService.svc"\cf5  \cf7 InlineScript\cf3 =\cf8 "false"\cf5  \cf3 /&amp;gt;\par ??\cf5 \tab \tab \tab \cf3 &amp;lt;/\cf6 Services\cf3 &amp;gt;\par ??\cf5 \tab \tab \cf3 &amp;lt;/\cf6 asp\cf3 :\cf6 ScriptManager\cf3 &amp;gt;\par ??\cf5 \tab \tab \cf3 &amp;lt;\cf6 asp\cf3 :\cf6 Label\cf5  \cf7 ID\cf3 =\cf8 "lblMessage"\cf5  \cf7 runat\cf3 =\cf8 "server"\cf5  \cf7 Text\cf3 =\cf8 "No work has been done"\cf5  \cf3 /&amp;gt;\cf5  \cf3 &amp;lt;\cf6 a\cf5  \cf7 href\cf3 =\cf8 "javascript:void(0); DoJeepWork()"\cf3 &amp;gt;\cf5 Do Work\cf3 &amp;lt;/\cf6 a\cf3 &amp;gt;\par ??\cf5 \tab \cf3 &amp;lt;/\cf6 div\cf3 &amp;gt;\par ??\cf5 \tab \cf3 &amp;lt;/\cf6 form\cf3 &amp;gt;\par ??&amp;lt;/\cf6 body\cf3 &amp;gt;\par ??&amp;lt;/\cf6 html\cf3 &amp;gt;}
--&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red0\green0\blue0;\red255\green238\blue98;\red239\green239\blue143;\red63\green63\blue63;\red220\green220\blue204;\red227\green206\blue171;\red223\green223\blue191;\red204\green147\blue147;\red225\green225\blue138;\red200\green145\blue145;\red127\green159\blue127;}??\fs18 \cb2\highlight2 &amp;lt;%\cf3\cb4\highlight4 @\cf5  \cf6 Page\cf5  \cf7 Language\cf3 =\cf8 "C#"\cf5  \cf7 AutoEventWireup\cf3 =\cf8 "true"\cf5  \cf7 CodeFile\cf3 =\cf8 "Default.aspx.cs"\cf5  \cf7 Inherits\cf3 =\cf8 "_Default"\cf5  \cf0\cb2\highlight2 %&amp;gt;\par ??\par ??\cf3\cb4\highlight4 &amp;lt;!\cf6 DOCTYPE\cf5  \cf7 html\cf5  \cf7 PUBLIC\cf5  \cf8 "-//W3C//DTD XHTML 1.0 Transitional//EN"\par ??"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"\cf3 &amp;gt;\par ??&amp;lt;\cf6 html\cf5  \cf7 xmlns\cf3 =\cf8 "http://www.w3.org/1999/xhtml"\cf3 &amp;gt;\par ??&amp;lt;\cf6 head\cf5  \cf7 runat\cf3 =\cf8 "server"\cf3 &amp;gt;\par ??\cf5 \tab \cf3 &amp;lt;\cf6 title\cf3 &amp;gt;\cf5 Test page\cf3 &amp;lt;/\cf6 title\cf3 &amp;gt;\par ??\par ??\cf5 \tab \cf3 &amp;lt;\cf6 script\cf5  \cf7 type\cf3 =\cf8 "text/javascript"\cf3 &amp;gt;\par ??\cf5 \tab \tab \cf9 {\b function}\cf5  \cf7 DoJeepWork\cf5 () \{\par ??\tab \tab \tab \cf7 JeepServices\cf5 .\cf7 JeepServiceContract\cf5 .\cf7 DoWork\cf5 (\cf7 OnJeepWorkSuccedeed\cf5 , \cf7 OnJeepWorkFailed\cf5 );\par ??\tab \tab \}\par ??\tab \tab \cf9 {\b function}\cf5  \cf7 OnJeepWorkSuccedeed\cf5 (\cf7 res\cf5 ) \{\par ??\tab \tab \tab \cf7 document\cf5 .\cf7 getElementById\cf5 (\cf10 "&amp;lt;%= this.lblMessage.ClientID %&amp;gt;"\cf5 ).\cf7 innerText\cf5  = \cf7 res\cf5 ;\par ??\tab \tab \}\par ??\tab \tab \cf9 {\b function}\cf5  \cf7 OnJeepWorkFailed\cf5 (\cf7 error\cf5 ) \{\par ??\tab \tab \tab \cf11 // Alert user to the error.    \par ??\cf5 \tab \tab \tab \cf7 alert\cf5 (\cf7 error\cf5 .\cf7 get_message\cf5 ());\par ??\tab \tab \}\par ??\tab \cf3 &amp;lt;/\cf6 script\cf3 &amp;gt;\par ??\par ??&amp;lt;/\cf6 head\cf3 &amp;gt;\par ??&amp;lt;\cf6 body\cf3 &amp;gt;\par ??\cf5 \tab \cf3 &amp;lt;\cf6 form\cf5  \cf7 id\cf3 =\cf8 "form1"\cf5  \cf7 runat\cf3 =\cf8 "server"\cf3 &amp;gt;\par ??\cf5 \tab \cf3 &amp;lt;\cf6 div\cf3 &amp;gt;\par ??\cf5 \tab \tab \cf3 &amp;lt;\cf6 asp\cf3 :\cf6 ScriptManager\cf5  \cf7 runat\cf3 =\cf8 "server"\cf3 &amp;gt;\par ??\cf5 \tab \tab \tab \cf3 &amp;lt;\cf6 Services\cf3 &amp;gt;\par ??\cf5 \tab \tab \tab \tab \cf3 &amp;lt;\cf6 asp\cf3 :\cf6 ServiceReference\cf5  \cf7 Path\cf3 =\cf8 "~/Services/WebHttpService.svc"\cf5  \cf7 InlineScript\cf3 =\cf8 "false"\cf5  \cf3 /&amp;gt;\par ??\cf5 \tab \tab \tab \cf3 &amp;lt;/\cf6 Services\cf3 &amp;gt;\par ??\cf5 \tab \tab \cf3 &amp;lt;/\cf6 asp\cf3 :\cf6 ScriptManager\cf3 &amp;gt;\par ??\cf5 \tab \tab \cf3 &amp;lt;\cf6 asp\cf3 :\cf6 Label\cf5  \cf7 ID\cf3 =\cf8 "lblMessage"\cf5  \cf7 runat\cf3 =\cf8 "server"\cf5  \cf7 Text\cf3 =\cf8 "No work has been done"\cf5  \cf3 /&amp;gt;\par ??\cf5 \tab \tab \cf3 &amp;lt;\cf6 a\cf5  \cf7 href\cf3 =\cf8 "javascript:void(0); DoJeepWork()"\cf3 &amp;gt;\cf5 Do Work\cf3 &amp;lt;/\cf6 a\cf3 &amp;gt;\par ??\cf5 \tab \cf3 &amp;lt;/\cf6 div\cf3 &amp;gt;\par ??\cf5 \tab \cf3 &amp;lt;/\cf6 form\cf3 &amp;gt;\par ??&amp;lt;/\cf6 body\cf3 &amp;gt;\par ??&amp;lt;/\cf6 html\cf3 &amp;gt;\par ??}
--&gt;
&lt;/p&gt;
&lt;div style="font-size: 9pt; background: #3f3f3f; width: 819px; color: #dcdccc; font-family: consolas; height: 519px"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="background: #ffee62"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="color: #efef8f"&gt;@&lt;/span&gt; &lt;span style="color: #e3ceab"&gt;Page&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;Language&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"C#"&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;AutoEventWireup&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"true"&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;CodeFile&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"Default.aspx.cs"&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;Inherits&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"_Default"&lt;/span&gt; &lt;span style="background: #ffee62"&gt;%&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&lt;span style="color: #efef8f"&gt;&amp;lt;!&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;DOCTYPE&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;html&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;PUBLIC&lt;/span&gt; &lt;span style="color: #cc9393"&gt;"-//W3C//DTD
XHTML 1.0 Transitional//EN"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt;&amp;nbsp;&lt;span style="color: #cc9393"&gt;"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt;&amp;nbsp;&lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;html&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;xmlns&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"http://www.w3.org/1999/xhtml"&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;head&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;runat&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"server"&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;title&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;Test
page&lt;span style="color: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;title&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;script&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;type&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"text/javascript"&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;function&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;DoJeepWork&lt;/span&gt;()
{
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #dfdfbf"&gt;JeepServices&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;JeepServiceContract&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;DoWork&lt;/span&gt;(&lt;span style="color: #dfdfbf"&gt;OnJeepWorkSuccedeed&lt;/span&gt;, &lt;span style="color: #dfdfbf"&gt;OnJeepWorkFailed&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 13&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;function&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;OnJeepWorkSuccedeed&lt;/span&gt;(&lt;span style="color: #dfdfbf"&gt;res&lt;/span&gt;)
{
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #dfdfbf"&gt;document&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;getElementById&lt;/span&gt;(&lt;span style="color: #c89191"&gt;"&amp;lt;%=
this.lblMessage.ClientID %&amp;gt;"&lt;/span&gt;).&lt;span style="color: #dfdfbf"&gt;innerText&lt;/span&gt; = &lt;span style="color: #dfdfbf"&gt;res&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 16&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;function&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;OnJeepWorkFailed&lt;/span&gt;(&lt;span style="color: #dfdfbf"&gt;error&lt;/span&gt;)
{
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 17&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #7f9f7f"&gt;//
Alert user to the error.&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 18&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #dfdfbf"&gt;alert&lt;/span&gt;(&lt;span style="color: #dfdfbf"&gt;error&lt;/span&gt;.&lt;span style="color: #dfdfbf"&gt;get_message&lt;/span&gt;());
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 19&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 20&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;script&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 21&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 22&lt;/span&gt;&amp;nbsp;&lt;span style="color: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;head&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 23&lt;/span&gt;&amp;nbsp;&lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;body&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 24&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;form&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;id&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"form1"&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;runat&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"server"&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 25&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;div&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 26&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;asp&lt;/span&gt;&lt;span style="color: #efef8f"&gt;:&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;ScriptManager&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;runat&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"server"&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 27&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;Services&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 28&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;asp&lt;/span&gt;&lt;span style="color: #efef8f"&gt;:&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;ServiceReference&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;Path&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"~/Services/WebHttpService.svc"&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;InlineScript&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"false"&lt;/span&gt; &lt;span style="color: #efef8f"&gt;/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 29&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;Services&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 30&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;asp&lt;/span&gt;&lt;span style="color: #efef8f"&gt;:&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;ScriptManager&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 31&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;asp&lt;/span&gt;&lt;span style="color: #efef8f"&gt;:&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;Label&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;ID&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"lblMessage"&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;runat&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"server"&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;Text&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"No
work has been done"&lt;/span&gt; &lt;span style="color: #efef8f"&gt;/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 32&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;a&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;href&lt;/span&gt;&lt;span style="color: #efef8f"&gt;=&lt;/span&gt;&lt;span style="color: #cc9393"&gt;"javascript:void(0);
DoJeepWork()"&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;Do Work&lt;span style="color: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;a&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 33&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;div&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 34&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;form&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 35&lt;/span&gt;&amp;nbsp;&lt;span style="color: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;body&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 36&lt;/span&gt;&amp;nbsp;&lt;span style="color: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="color: #e3ceab"&gt;html&lt;/span&gt;&lt;span style="color: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Mission accomplished! Here you've seen how to expose an existing WCF service library
without changing any code in the library itself. Adding two files allowed the service
to be exposed to your AJAX clients. Best of all, there is no configuration file changes
to make.
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Useful Links:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/bb514961.aspx"&gt;Exposing WCF Services
to Client Script&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=cfeeb9f7-2a9e-40a5-99ce-dea714e3284d" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,cfeeb9f7-2a9e-40a5-99ce-dea714e3284d.aspx</comments>
      <category>.NET Framework</category>
      <category>AJAX</category>
      <category>ASP.NET</category>
      <category>C#</category>
      <category>Javascript</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=49e557e3-d9dd-4705-865f-71c4f468ed1b</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,49e557e3-d9dd-4705-865f-71c4f468ed1b.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,49e557e3-d9dd-4705-865f-71c4f468ed1b.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=49e557e3-d9dd-4705-865f-71c4f468ed1b</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Hosting an MSMQ service is a little bit different than the other bindings. Since WCF
is using MSMQ as a transport mechanism, you must setup the queues, permissions, and
bindingConfigurations to allow this to happen. Surprisingly, MSDN has a <a href="http://msdn.microsoft.com/en-us/library/ms752246.aspx">good
sample article</a> that goes into sufficient detail on how to set this up for the
3.5 WF-WCF-CardSpace samples. 
</p>
        <p>
I have read in other articles that the AppPool must have an interactive identity and
that the queue names needed to match the name of the .svc file. I did not find this
to be the case. I was able to use the <em>NetworkService</em> account for my AppPool
after adding receive and peek permissions for <em>NetworkService</em> on my queue.
Communication between client and WAS worked fine with my service file named WasServices.svc
and my queue address as <a title="net.msmq://localhost/private/QueuedService1" href="net.msmq://localhost/private/QueuedService1">net.msmq://localhost/private/QueuedService1</a>.
</p>
        <p>
You can download my solution with the following link: <a href="http://scott.klueppel.net/content/binary/WasServices.zip">WasServices.zip</a> (78K)
</p>
        <p>
Additional Info:
</p>
        <ul>
          <li>
            <a href="http://msdn.microsoft.com/en-us/library/ms752246.aspx">MSMQ Activation (MSDN)</a>
          </li>
          <li>
            <a href="http://idesign.net/idesign/DesktopDefault.aspx?tabindex=5&amp;tabid=11#WCFEssentials">IDesign
Code Library - Look for the WAS Hosting download</a>
          </li>
        </ul>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=49e557e3-d9dd-4705-865f-71c4f468ed1b" />
      </body>
      <title>Hosting an MSMQ WCF Service in WAS</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,49e557e3-d9dd-4705-865f-71c4f468ed1b.aspx</guid>
      <link>http://offroadcoder.com/2008/09/17/HostingAnMSMQWCFServiceInWAS.aspx</link>
      <pubDate>Wed, 17 Sep 2008 01:48:22 GMT</pubDate>
      <description>&lt;p&gt;
Hosting an MSMQ service is a little bit different than the other bindings. Since WCF
is using MSMQ as a transport mechanism, you must setup the queues, permissions, and
bindingConfigurations to allow this to happen. Surprisingly, MSDN has a &lt;a href="http://msdn.microsoft.com/en-us/library/ms752246.aspx"&gt;good
sample article&lt;/a&gt; that goes into sufficient detail on how to set this up for the
3.5 WF-WCF-CardSpace samples. 
&lt;/p&gt;
&lt;p&gt;
I have read in other articles that the AppPool must have an interactive identity and
that the queue names needed to match the name of the .svc file. I did not find this
to be the case. I was able to use the &lt;em&gt;NetworkService&lt;/em&gt; account for my AppPool
after adding receive and peek permissions for &lt;em&gt;NetworkService&lt;/em&gt; on my queue.
Communication between client and WAS worked fine with my service file named WasServices.svc
and my queue address as &lt;a title="net.msmq://localhost/private/QueuedService1" href="net.msmq://localhost/private/QueuedService1"&gt;net.msmq://localhost/private/QueuedService1&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
You can download my solution with the following link: &lt;a href="http://scott.klueppel.net/content/binary/WasServices.zip"&gt;WasServices.zip&lt;/a&gt; (78K)
&lt;/p&gt;
&lt;p&gt;
Additional Info:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://msdn.microsoft.com/en-us/library/ms752246.aspx"&gt;MSMQ Activation (MSDN)&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://idesign.net/idesign/DesktopDefault.aspx?tabindex=5&amp;amp;tabid=11#WCFEssentials"&gt;IDesign
Code Library - Look for the WAS Hosting download&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=49e557e3-d9dd-4705-865f-71c4f468ed1b" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,49e557e3-d9dd-4705-865f-71c4f468ed1b.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>WAS</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=a3e76678-c8fe-4440-898d-7739c8c99efb</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,a3e76678-c8fe-4440-898d-7739c8c99efb.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,a3e76678-c8fe-4440-898d-7739c8c99efb.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a3e76678-c8fe-4440-898d-7739c8c99efb</wfw:commentRss>
      <slash:comments>8</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It has taken me weeks to get WAS (Windows Activation Service) working. Finally, tonight,
my long hours of research has paid off. After everything I tried, it turned out to
be a general IIS7 issue caused by a stray http reservation that I probably entered
months ago during some testing. As I primarily use the built-in development server
for web development, I rarely crank up an IIS site on my development machine. 
</p>
        <p>
This post by Phil Haack helped me fix my IIS install:
</p>
        <p>
          <a href="http://haacked.com/archive/2007/05/21/the-iis-7-team-rocks.aspx">http://haacked.com/archive/2007/05/21/the-iis-7-team-rocks.aspx</a>
        </p>
        <p>
I have been cursing IIS7, Vista, and WAS for weeks. I should have been cursing my
own lack of IIS7 knowledge all along. Now that it's working, I am a big fan of WAS.
From the tone of recent forum responses and blog posts, very few people are using
WAS. Maybe it is due to Windows Server 2008 being so new. Not many people have Vista
workstations for development and <u>all</u> Windows Server 2008 servers to deploy
to. Knowing how many problems I had, I can only assume others are experiencing the
same thing. The only real info available right now is pre-release articles and MVP
posts about the new features with a sneak peak example on how to get it to work. Even
MSDN doesn't show how to use an existing WCF Service Library with WAS. They just walk
through a WsHttpBinding example as a new WCF web site served up by WAS.
</p>
        <p>
I'm posting the details so others will maybe see that it's really not that hard.
For this example I want to expose this service with the NetTcpBinding to prove that
it is not IIS hosting the service. I used the WCF Service Library project template
for my WCF service, and named the project <em>WasServices</em>. So the lame Service1
service is all I have in the library. I made no changes to the project and built it
in release mode to get the DLL. Some posts and articles out there say that the only
way to get WAS to work is to have an HTTP-based WCF web site. This is simply not true.
You just need to have an application set up in IIS.
</p>
        <p>
Here is the steps to success:
</p>
        <p>
1. Enable the required Windows Features to wake up IIS7 and WAS. You will find these
in the helpful links below.
</p>
        <p>
2. Configuration file <em>C:\Windows\System32\inetsrv\config\applicationHost.config</em> must
be modified to enable the required protocols on your web site and application. You
can modify the file yourself, or use command-line utilities.
</p>
        <blockquote>
          <p>
To enable net.tcp on the web site, if it is not already:
</p>
          <p>
            <font face="Courier New">%windir%\system32\inetsrv\appcmd.exe set site "Default Web
Site" -+bindings.[protocol='net.tcp',bindingInformation='808:*']</font>
          </p>
          <p>
To enable net.tcp on your application (my app is named <em>WasServices</em>) within
that web site, if it is not already:
</p>
          <p>
            <font face="Courier New">%windir%\system32\inetsrv\appcmd.exe set app "Default Web
Site/WasServices" /enabledProtocols:http,net.tcp</font>
          </p>
          <p>
          </p>
          <p>
Here is an exerpt from the applicationHost.config file showing the site and application
settings:
</p>
          <p>
          </p>
          <div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 848px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 218px">
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  151</span> <span style="COLOR: #efef8f">           
&lt;</span><span style="COLOR: #e3c66a">site</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">name</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">Default
Web Site</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">id</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">1</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">serverAutoStart</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">true</span><span style="COLOR: #efef8f">"&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  152</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">application</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">path</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">/</span><span style="COLOR: #efef8f">"&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  153</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">virtualDirectory</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">path</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">/</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">physicalPath</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">%SystemDrive%\inetpub\wwwroot</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  154</span> <span style="COLOR: #efef8f">               
&lt;/</span><span style="COLOR: #e3c66a">application</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  155</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">application</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">path</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">/WasServices</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">applicationPool</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">WasHosting</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">enabledProtocols</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">http,net.tcp</span><span style="COLOR: #efef8f">"&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  156</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">virtualDirectory</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">path</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">/</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">physicalPath</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">C:\inetpub\wwwroot\WasServices</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  157</span> <span style="COLOR: #efef8f">               
&lt;/</span><span style="COLOR: #e3c66a">application</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  158</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">bindings</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  159</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">binding</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">protocol</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">net.tcp</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">bindingInformation</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">808:*</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  160</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">binding</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">protocol</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">net.pipe</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">bindingInformation</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">*</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  161</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">binding</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">protocol</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">net.msmq</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">bindingInformation</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">localhost</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  162</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">binding</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">protocol</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">msmq.formatname</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">bindingInformation</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">localhost</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  163</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">binding</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">protocol</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">http</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">bindingInformation</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">*:80:</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  164</span> <span style="COLOR: #efef8f">               
&lt;/</span><span style="COLOR: #e3c66a">bindings</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">  165</span> <span style="COLOR: #efef8f">           
&lt;/</span><span style="COLOR: #e3c66a">site</span><span style="COLOR: #efef8f">&gt;</span></p>
          </div>
        </blockquote>
        <p>
3. Prepare the application in your application folder (C:\inetpub\wwwroot\WasServices)
</p>
        <blockquote>
          <p>
Create a service file (WasServices.svc) that points to your existing WCF service library:
</p>
          <p>
          </p>
          <div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 600px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 34px">
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    1</span> <span style="BACKGROUND: #ffee62">&lt;%</span><span style="COLOR: #efef8f">@</span><span style="COLOR: #e3ceab">ServiceHost</span><span style="COLOR: #dfdfbf">Service</span><span style="COLOR: #efef8f">=</span><span style="COLOR: #cc9393">"WasServices.Service1"</span><span style="BACKGROUND: #ffee62">%&gt;</span></p>
          </div>
          <p>
 
</p>
          <p>
Create a web.config file that specifies the service's endpoints:
</p>
          <p>
          </p>
          <p>
          </p>
          <div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 600px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px">
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    1</span> <span style="COLOR: #efef8f">&lt;?</span><span style="COLOR: #e3c66a">xml</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">version</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">1.0</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">encoding</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">utf-8</span><span style="COLOR: #efef8f">"?&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    2</span> <span style="COLOR: #efef8f">&lt;</span><span style="COLOR: #e3c66a">configuration</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    3</span> <span style="COLOR: #efef8f">   
&lt;</span><span style="COLOR: #e3c66a">system.serviceModel</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    4</span> <span style="COLOR: #efef8f">       
&lt;</span><span style="COLOR: #e3c66a">services</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    5</span> <span style="COLOR: #efef8f">           
&lt;</span><span style="COLOR: #e3c66a">service</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">name</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">WasServices.Service1</span><span style="COLOR: #efef8f">"</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    6</span> <span style="COLOR: #efef8f">                    </span><span style="COLOR: white">behaviorConfiguration</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">MEX</span><span style="COLOR: #efef8f">"&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    7</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">endpoint</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">address</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">wsHttp</span><span style="COLOR: #efef8f">"</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    8</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">binding</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">wsHttpBinding</span><span style="COLOR: #efef8f">"</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    9</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">contract</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">WasServices.IService1</span><span style="COLOR: #efef8f">"/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   10</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">endpoint</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">address</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">netTcp</span><span style="COLOR: #efef8f">"</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   11</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">binding</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">netTcpBinding</span><span style="COLOR: #efef8f">"</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   12</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">bindingConfiguration</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">NetTcpBinding_Common</span><span style="COLOR: #efef8f">"</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   13</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">contract</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">WasServices.IService1</span><span style="COLOR: #efef8f">"/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   14</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">endpoint</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">address</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">mex</span><span style="COLOR: #efef8f">"</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   15</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">binding</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">mexHttpBinding</span><span style="COLOR: #efef8f">"</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   16</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">contract</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">IMetadataExchange</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   17</span> <span style="COLOR: #efef8f">           
&lt;/</span><span style="COLOR: #e3c66a">service</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   18</span> <span style="COLOR: #efef8f">       
&lt;/</span><span style="COLOR: #e3c66a">services</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   19</span> <span style="COLOR: #efef8f">       
&lt;</span><span style="COLOR: #e3c66a">behaviors</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   20</span> <span style="COLOR: #efef8f">           
&lt;</span><span style="COLOR: #e3c66a">serviceBehaviors</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   21</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">behavior</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">name</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">MEX</span><span style="COLOR: #efef8f">"&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   22</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">serviceMetadata</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">httpGetEnabled</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">true</span><span style="COLOR: #efef8f">"/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   23</span> <span style="COLOR: #efef8f">               
&lt;/</span><span style="COLOR: #e3c66a">behavior</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   24</span> <span style="COLOR: #efef8f">           
&lt;/</span><span style="COLOR: #e3c66a">serviceBehaviors</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   25</span> <span style="COLOR: #efef8f">       
&lt;/</span><span style="COLOR: #e3c66a">behaviors</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   26</span> <span style="COLOR: #efef8f">       
&lt;</span><span style="COLOR: #e3c66a">bindings</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   27</span> <span style="COLOR: #efef8f">           
&lt;</span><span style="COLOR: #e3c66a">netTcpBinding</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   28</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">binding</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">name</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">NetTcpBinding_Common</span><span style="COLOR: #efef8f">"&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   29</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">reliableSession</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">enabled</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">true</span><span style="COLOR: #efef8f">"/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   30</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">security</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">mode</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">None</span><span style="COLOR: #efef8f">"/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   31</span> <span style="COLOR: #efef8f">               
&lt;/</span><span style="COLOR: #e3c66a">binding</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   32</span> <span style="COLOR: #efef8f">           
&lt;/</span><span style="COLOR: #e3c66a">netTcpBinding</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   33</span> <span style="COLOR: #efef8f">       
&lt;/</span><span style="COLOR: #e3c66a">bindings</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   34</span> <span style="COLOR: #efef8f">   
&lt;/</span><span style="COLOR: #e3c66a">system.serviceModel</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   35</span> <span style="COLOR: #efef8f">&lt;/</span><span style="COLOR: #e3c66a">configuration</span><span style="COLOR: #efef8f">&gt;</span></p>
          </div>
          <p>
 
</p>
          <p>
Place the release-compiled DLL created from the WCF Service Library in a new folder
named <em>Bin</em>.
</p>
        </blockquote>
        <p>
4. At this point, you can browse and see the familiar "You have created a service."
page for Service1.
</p>
        <p>
5. Write your proxy file and config file.
</p>
        <blockquote>
          <p>
WAS and IIS7 decide the address for your service, and it is not intuitive. 
</p>
          <p>
          </p>
          <div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 691px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px">
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    1</span> <span style="COLOR: #efef8f">&lt;?</span><span style="COLOR: #e3c66a">xml</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">version</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">1.0</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">encoding</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">utf-8</span><span style="COLOR: #efef8f">"
?&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    2</span> <span style="COLOR: #efef8f">&lt;</span><span style="COLOR: #e3c66a">configuration</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    3</span> <span style="COLOR: #efef8f">   
&lt;</span><span style="COLOR: #e3c66a">system.serviceModel</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    4</span> <span style="COLOR: #efef8f">       
&lt;</span><span style="COLOR: #e3c66a">client</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    5</span> <span style="COLOR: #efef8f">           
&lt;</span><span style="COLOR: #e3c66a">endpoint</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">address</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">net.tcp://localhost/WasServices/WasServices.svc/netTcp</span><span style="COLOR: #efef8f">"</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    6</span> <span style="COLOR: #efef8f">                      </span><span style="COLOR: white">binding</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">netTcpBinding</span><span style="COLOR: #efef8f">"</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    7</span> <span style="COLOR: #efef8f">                      </span><span style="COLOR: white">bindingConfiguration</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">NetTcpBinding_IService1</span><span style="COLOR: #efef8f">"</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    8</span> <span style="COLOR: #efef8f">                      </span><span style="COLOR: white">contract</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">WasServices.IService1</span><span style="COLOR: #efef8f">"</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">    9</span> <span style="COLOR: #efef8f">                      </span><span style="COLOR: white">name</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">NetTcpBinding_Common</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   10</span> <span style="COLOR: #efef8f">       
&lt;/</span><span style="COLOR: #e3c66a">client</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   11</span> <span style="COLOR: #efef8f">       
&lt;</span><span style="COLOR: #e3c66a">bindings</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   12</span> <span style="COLOR: #efef8f">           
&lt;</span><span style="COLOR: #e3c66a">netTcpBinding</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   13</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">binding</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">name</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">NetTcpBinding_Common</span><span style="COLOR: #efef8f">"&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   14</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">reliableSession</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">enabled</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">true</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   15</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">security</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">mode</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">None</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   16</span> <span style="COLOR: #efef8f">               
&lt;/</span><span style="COLOR: #e3c66a">binding</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   17</span> <span style="COLOR: #efef8f">           
&lt;/</span><span style="COLOR: #e3c66a">netTcpBinding</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   18</span> <span style="COLOR: #efef8f">       
&lt;/</span><span style="COLOR: #e3c66a">bindings</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   19</span> <span style="COLOR: #efef8f">   
&lt;/</span><span style="COLOR: #e3c66a">system.serviceModel</span><span style="COLOR: #efef8f">&gt;</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #85ac8d">   20</span> <span style="COLOR: #efef8f">&lt;/</span><span style="COLOR: #e3c66a">configuration</span><span style="COLOR: #efef8f">&gt;</span></p>
          </div>
          <p>
 
</p>
          <p>
The <em>/netTcp</em> at the end of the address is due to the address specified in
the service's web.config file. The address was given there as simply <em>netTcp</em>.
This is because IIS7 and WAS decide your address based on the available bindings and
ports you specified in the applicationHost.config file using appcmd.exe. Since my
enabled protocols are http and net.tcp and the only open tcp port is 808, you will
not see a port number in the address. The same would go for my wsHttpBinding since
the only allowable port is 80.
</p>
        </blockquote>
        <p>
I'm proud to be the fourth, and maybe final, member of the "Got WAS to work" club.
If anyone wants to join, and needs help to get in... please let me know.
</p>
        <blockquote>
          <p>
          </p>
        </blockquote>
        <p>
Here are some helpful links for those of you having problems:
</p>
        <ul>
          <li>
            <a href="http://yourbit.com/2008/03/09/hosting-a-windows-communication-foundation-service-in-iis7-on-windows-vista/">Hosting
a WCF Service using IIS7 and Windows Vista</a>
          </li>
          <li>
            <a href="http://blah.winsmarts.com/2008-4-Host_a_WCF_Service_in_IIS_7_-and-amp;_Windows_2008_-_The_right_way.aspx">Host
a WCF Service in IIS 7 &amp; Windows 2008 - The right way</a>
          </li>
          <li>
            <a href="http://www.devx.com/VistaSpecialReport/Article/33831">Hosting WCF Services
in Windows Activation Service</a>
          </li>
        </ul>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=a3e76678-c8fe-4440-898d-7739c8c99efb" />
      </body>
      <title>WASed up and ready to go</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,a3e76678-c8fe-4440-898d-7739c8c99efb.aspx</guid>
      <link>http://offroadcoder.com/2008/09/13/WASedUpAndReadyToGo.aspx</link>
      <pubDate>Sat, 13 Sep 2008 04:58:31 GMT</pubDate>
      <description>&lt;p&gt;
It has taken me weeks to get WAS (Windows Activation Service) working. Finally, tonight,
my long hours of research has paid off. After everything I tried, it turned out to
be a general IIS7 issue caused by a stray http reservation that I probably entered
months ago during some testing. As I primarily use the built-in development server
for web development, I rarely crank up an IIS site on my development machine. 
&lt;/p&gt;
&lt;p&gt;
This post by Phil Haack helped me fix my IIS install:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://haacked.com/archive/2007/05/21/the-iis-7-team-rocks.aspx"&gt;http://haacked.com/archive/2007/05/21/the-iis-7-team-rocks.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
I have been cursing IIS7, Vista, and WAS for weeks. I should have been cursing my
own lack of IIS7 knowledge all along. Now that it's working, I am a big fan of WAS.
From the tone of recent forum responses and blog posts, very few people are using
WAS. Maybe it is due to Windows Server 2008 being so new. Not many people have Vista
workstations for development and &lt;u&gt;all&lt;/u&gt; Windows Server 2008 servers to deploy
to. Knowing how many problems I had, I can only assume others are experiencing the
same thing. The only real info available right now is pre-release articles and MVP
posts about the new features with a sneak peak example on how to get it to work. Even
MSDN doesn't show how to use an existing WCF Service Library with WAS. They just walk
through a WsHttpBinding example as a new WCF web site served up by WAS.
&lt;/p&gt;
&lt;p&gt;
I'm posting the details so&amp;nbsp;others will maybe see that it's really not that hard.
For this example I want to expose this service with the NetTcpBinding to prove that
it is not IIS hosting the service. I used the WCF Service Library project template
for my WCF service, and named the project &lt;em&gt;WasServices&lt;/em&gt;. So the lame Service1
service is all I have in the library. I made no changes to the project and built it
in release mode to get the DLL. Some posts and articles out there say that the only
way to get WAS to work is to have an HTTP-based WCF web site. This is simply not true.
You just need to have an application set up in IIS.
&lt;/p&gt;
&lt;p&gt;
Here is the steps to success:
&lt;/p&gt;
&lt;p&gt;
1. Enable the required Windows Features to wake up IIS7 and WAS. You will find these
in the helpful links below.
&lt;/p&gt;
&lt;p&gt;
2. Configuration file &lt;em&gt;C:\Windows\System32\inetsrv\config\applicationHost.config&lt;/em&gt; must
be modified to enable the required protocols on your web site and application. You
can modify the file yourself, or use command-line utilities.
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
To enable net.tcp on the web site, if it is not already:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;%windir%\system32\inetsrv\appcmd.exe set site "Default Web
Site" -+bindings.[protocol='net.tcp',bindingInformation='808:*']&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
To enable net.tcp on your application (my app is named &lt;em&gt;WasServices&lt;/em&gt;) within
that web site, if it is not already:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;%windir%\system32\inetsrv\appcmd.exe set app "Default Web
Site/WasServices" /enabledProtocols:http,net.tcp&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Here is an exerpt from the applicationHost.config file showing the site and application
settings:
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 848px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 218px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 151&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;site&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;name&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;Default
Web Site&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;id&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;1&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;serverAutoStart&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;true&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 152&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;application&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;path&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;/&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 153&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;virtualDirectory&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;path&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;/&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;physicalPath&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;%SystemDrive%\inetpub\wwwroot&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 154&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;application&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 155&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;application&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;path&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;/WasServices&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;applicationPool&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;WasHosting&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;enabledProtocols&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;http,net.tcp&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 156&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;virtualDirectory&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;path&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;/&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;physicalPath&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;C:\inetpub\wwwroot\WasServices&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 157&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;application&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 158&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;bindings&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 159&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;protocol&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;net.tcp&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;bindingInformation&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;808:*&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 160&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;protocol&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;net.pipe&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;bindingInformation&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;*&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 161&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;protocol&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;net.msmq&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;bindingInformation&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;localhost&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 162&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;protocol&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;msmq.formatname&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;bindingInformation&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;localhost&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 163&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;protocol&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;http&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;bindingInformation&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;*:80:&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 164&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;bindings&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp; 165&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;site&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
3. Prepare the application in your application folder (C:\inetpub\wwwroot\WasServices)
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
Create a service file (WasServices.svc) that points to your existing WCF service library:
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 600px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 34px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="BACKGROUND: #ffee62"&gt;&amp;lt;%&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;@&lt;/span&gt; &lt;span style="COLOR: #e3ceab"&gt;ServiceHost&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;Service&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;=&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;"WasServices.Service1"&lt;/span&gt; &lt;span style="BACKGROUND: #ffee62"&gt;%&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Create a web.config file that specifies the service's endpoints:
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 600px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;xml&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;version&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;1.0&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;encoding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;utf-8&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"?&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;system.serviceModel&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;services&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;service&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;name&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;WasServices.Service1&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;MEX&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;address&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;wsHttp&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;wsHttpBinding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;contract&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;WasServices.IService1&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 10&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;address&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;netTcp&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 11&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;netTcpBinding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 12&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;NetTcpBinding_Common&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 13&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;contract&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;WasServices.IService1&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 14&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;address&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;mex&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 15&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;mexHttpBinding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 16&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;contract&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;IMetadataExchange&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 17&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;service&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 18&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;services&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 19&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;behaviors&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 20&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 21&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;behavior&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;name&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;MEX&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 22&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;serviceMetadata&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;httpGetEnabled&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;true&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 23&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;behavior&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 24&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 25&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;behaviors&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 26&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;bindings&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 27&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;netTcpBinding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 28&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;name&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;NetTcpBinding_Common&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 29&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;reliableSession&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;enabled&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;true&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 30&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;security&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;mode&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;None&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 31&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 32&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;netTcpBinding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 33&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;bindings&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 34&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;system.serviceModel&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 35&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
Place the release-compiled DLL created from the WCF Service Library in a new folder
named &lt;em&gt;Bin&lt;/em&gt;.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
4. At this point, you can browse and see the familiar "You have created a service."
page for Service1.
&lt;/p&gt;
&lt;p&gt;
5. Write your proxy file and config file.
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
WAS and IIS7 decide the address for your service, and it is not intuitive. 
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 691px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;xml&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;version&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;1.0&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;encoding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;utf-8&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
?&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;system.serviceModel&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;client&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;address&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;net.tcp://localhost/WasServices/WasServices.svc/netTcp&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;netTcpBinding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;NetTcpBinding_IService1&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;contract&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;WasServices.IService1&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;name&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;NetTcpBinding_Common&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 10&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;client&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 11&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;bindings&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 12&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;netTcpBinding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 13&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;name&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;NetTcpBinding_Common&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 14&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;reliableSession&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;enabled&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;true&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 15&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;security&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;mode&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;None&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 16&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 17&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;netTcpBinding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 18&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;bindings&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 19&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;system.serviceModel&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 20&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The &lt;em&gt;/netTcp&lt;/em&gt; at the end of the address is due to the address specified in
the service's web.config file. The address was given there as simply &lt;em&gt;netTcp&lt;/em&gt;.
This is because IIS7 and WAS decide your address based on the available bindings and
ports you specified in the applicationHost.config file using appcmd.exe. Since my
enabled protocols are http and net.tcp and the only open tcp port is 808, you will
not see a port number in the address. The same would go for my wsHttpBinding since
the only allowable port is 80.
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I'm proud to be the fourth, and maybe final, member of the "Got WAS to work" club.
If anyone wants to join, and needs help to get in... please let me know.
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Here are some helpful links for those of you having problems:
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://yourbit.com/2008/03/09/hosting-a-windows-communication-foundation-service-in-iis7-on-windows-vista/"&gt;Hosting
a WCF Service using IIS7 and Windows Vista&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://blah.winsmarts.com/2008-4-Host_a_WCF_Service_in_IIS_7_-and-amp;_Windows_2008_-_The_right_way.aspx"&gt;Host
a WCF Service in IIS 7 &amp;amp; Windows 2008 - The right way&lt;/a&gt; 
&lt;li&gt;
&lt;a href="http://www.devx.com/VistaSpecialReport/Article/33831"&gt;Hosting WCF Services
in Windows Activation Service&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=a3e76678-c8fe-4440-898d-7739c8c99efb" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,a3e76678-c8fe-4440-898d-7739c8c99efb.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>WAS</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=81c4ce95-c3f1-4bda-97cf-f344afba5a2d</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,81c4ce95-c3f1-4bda-97cf-f344afba5a2d.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,81c4ce95-c3f1-4bda-97cf-f344afba5a2d.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=81c4ce95-c3f1-4bda-97cf-f344afba5a2d</wfw:commentRss>
      <slash:comments>4</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Why clutter your inbox with error messages? Why make special code provisions for users
to receive error messages via email? Why not log your error messages and have users
subscribe to receive them in their favorite RSS aggregator?
</p>
        <p>
If you are logging your exceptions already, you may find it easier to provide a syndication
service. The process is ridiculously simple, and starts by creating a new project
using the "Syndication Service Library" template. This template creates everything
for you. All you need to do now is fill the <em>SyndicationFeed</em> with <em>SyndicationItem</em> objects.
</p>
        <p>
Add a new class file called Feeds.cs: 
</p>
        <p>
 
</p>
        <div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 873px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px">
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    1</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    2</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Linq</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    3</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">ServiceModel</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    4</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">ServiceModel</span>.<span style="COLOR: #dfdfbf">Syndication</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    5</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">ServiceModel</span>.<span style="COLOR: #dfdfbf">Web</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    6</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    7</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">namespace</span><span style="COLOR: #dfdfbf">SyndicationService</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    8</span> {</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">    9</span>    
[<span style="COLOR: #2b91af">ServiceContract</span>]</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   10</span>    
[<span style="COLOR: #2b91af">ServiceKnownType</span>(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">typeof</span>(<span style="COLOR: #2b91af">Atom10FeedFormatter</span>))]</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   11</span>    
[<span style="COLOR: #2b91af">ServiceKnownType</span>(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">typeof</span>(<span style="COLOR: #2b91af">Rss20FeedFormatter</span>))]</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   12</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">public</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">interface</span><span style="COLOR: #2b91af">IFeeds</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   13</span>    
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   14</span>        
[<span style="COLOR: #2b91af">OperationContract</span>]</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   15</span>        
[<span style="COLOR: #2b91af">WebGet</span>(<span style="COLOR: #dfdfbf">UriTemplate</span> = <span style="COLOR: #c89191">"{type}?env={env}&amp;app={app}"</span>, <span style="COLOR: #dfdfbf">BodyStyle</span> = <span style="COLOR: #2b91af">WebMessageBodyStyle</span>.<span style="COLOR: #dfdfbf">Bare</span>)]</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   16</span>         <span style="COLOR: #2b91af">SyndicationFeedFormatter</span><span style="COLOR: #dfdfbf">CreateFeed</span>(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">type</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">env</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">app</span>);</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   17</span>    
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   18</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   19</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">public</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">class</span><span style="COLOR: #2b91af">Feeds</span> : <span style="COLOR: #2b91af">IFeeds</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   20</span>    
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   21</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">public</span><span style="COLOR: #2b91af">SyndicationFeedFormatter</span><span style="COLOR: #dfdfbf">CreateFeed</span>(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">type</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">env</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">app</span>)</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   22</span>        
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   23</span>             <span style="COLOR: #2b91af">SyndicationFeed</span><span style="COLOR: #dfdfbf">feed</span> = <span style="COLOR: #dfdfbf">CreateSyndicationFeed</span>(<span style="COLOR: #dfdfbf">type</span>, <span style="COLOR: #dfdfbf">env</span>, <span style="COLOR: #dfdfbf">app</span>);</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   24</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   25</span>             <span style="COLOR: #7f9f7f">//
Return ATOM or RSS based on query string</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   26</span>             <span style="COLOR: #7f9f7f">//
rss -&gt; http://localhost:8000/Feeds/Errors?env=Production&amp;app=MyAppName</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   27</span>             <span style="COLOR: #7f9f7f">//
atom -&gt; http://localhost:8000/Feeds/Errors?env=Production&amp;app=MyAppName&amp;format=atom</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   28</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">query</span> = <span style="COLOR: #2b91af">WebOperationContext</span>.<span style="COLOR: #dfdfbf">Current</span>.<span style="COLOR: #dfdfbf">IncomingRequest</span>.<span style="COLOR: #dfdfbf">UriTemplateMatch</span>.<span style="COLOR: #dfdfbf">QueryParameters</span>[<span style="COLOR: #c89191">"format"</span>];</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   29</span>             <span style="COLOR: #2b91af">SyndicationFeedFormatter</span><span style="COLOR: #dfdfbf">formatter</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">null</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   30</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">if</span> (<span style="COLOR: #dfdfbf">query</span> == <span style="COLOR: #c89191">"atom"</span>)</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   31</span>            
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   32</span>                 <span style="COLOR: #dfdfbf">formatter</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">Atom10FeedFormatter</span>(<span style="COLOR: #dfdfbf">feed</span>);</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   33</span>            
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   34</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">else</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   35</span>            
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   36</span>                 <span style="COLOR: #dfdfbf">formatter</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">Rss20FeedFormatter</span>(<span style="COLOR: #dfdfbf">feed</span>);</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   37</span>            
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   38</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   39</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span><span style="COLOR: #dfdfbf">formatter</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   40</span>        
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   41</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   42</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">private</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">static</span><span style="COLOR: #2b91af">SyndicationFeed</span><span style="COLOR: #dfdfbf">CreateSyndicationFeed</span>(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">type</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">env</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">app</span>)</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   43</span>        
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   44</span>             <span style="COLOR: #2b91af">SyndicationFeed</span><span style="COLOR: #dfdfbf">feed</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   45</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">switch</span> (<span style="COLOR: #dfdfbf">type</span>.<span style="COLOR: #dfdfbf">ToLower</span>())</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   46</span>            
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   47</span>                 <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">case</span><span style="COLOR: #c89191">"errors"</span>:</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   48</span>                     <span style="COLOR: #dfdfbf">feed</span> = <span style="COLOR: #dfdfbf">CreateErrorsFeed</span>(<span style="COLOR: #dfdfbf">type</span>, <span style="COLOR: #dfdfbf">env</span>, <span style="COLOR: #dfdfbf">app</span>);</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   49</span>                     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">break</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   50</span>                 <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">default</span>:</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   51</span>                     <span style="COLOR: #dfdfbf">feed</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SyndicationFeed</span>(</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   52</span>                         <span style="COLOR: #2b91af">String</span>.<span style="COLOR: #dfdfbf">Format</span>(<span style="COLOR: #c89191">"Feed
is unavailable - Type: {0} / Environment: {1} / Application: {2}"</span>,</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   53</span>                         <span style="COLOR: #dfdfbf">type</span>, <span style="COLOR: #dfdfbf">env</span>, <span style="COLOR: #dfdfbf">app</span>), <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">null</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">null</span>);</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   54</span>                     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">break</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   55</span>            
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   56</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span><span style="COLOR: #dfdfbf">feed</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   57</span>        
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   58</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   59</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">private</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">static</span><span style="COLOR: #2b91af">SyndicationFeed</span><span style="COLOR: #dfdfbf">CreateErrorsFeed</span>(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">type</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">env</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">app</span>)</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   60</span>        
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   61</span>             <span style="COLOR: #2b91af">ApplicationLogDataContext</span><span style="COLOR: #dfdfbf">db</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">ApplicationLogDataContext</span>();</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   62</span> </strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   63</span>             <span style="COLOR: #2b91af">SyndicationFeed</span><span style="COLOR: #dfdfbf">feed</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SyndicationFeed</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   64</span>            
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   65</span>                 <span style="COLOR: #dfdfbf">Title</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">TextSyndicationContent</span>(<span style="COLOR: #2b91af">String</span>.<span style="COLOR: #dfdfbf">Format</span>(<span style="COLOR: #c89191">"{0}
{1} {2}"</span>, <span style="COLOR: #dfdfbf">env</span>, <span style="COLOR: #dfdfbf">app</span>, <span style="COLOR: #dfdfbf">type</span>)),</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   66</span>                 <span style="COLOR: #dfdfbf">Description</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">TextSyndicationContent</span>(</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   67</span>                     <span style="COLOR: #2b91af">String</span>.<span style="COLOR: #dfdfbf">Format</span>(<span style="COLOR: #c89191">"Application
error syndication for the {0} applicaiton ({1})."</span>, <span style="COLOR: #dfdfbf">app</span>, <span style="COLOR: #dfdfbf">env</span>)),</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   68</span>                 <span style="COLOR: #dfdfbf">Items</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">from</span><span style="COLOR: #dfdfbf">e</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">in</span><span style="COLOR: #dfdfbf">db</span>.<span style="COLOR: #dfdfbf">Exceptions</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   69</span>                         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">where</span><span style="COLOR: #dfdfbf">e</span>.<span style="COLOR: #dfdfbf">Environment</span> == <span style="COLOR: #dfdfbf">env</span> &amp;&amp; <span style="COLOR: #dfdfbf">e</span>.<span style="COLOR: #dfdfbf">Application</span> == <span style="COLOR: #dfdfbf">app</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   70</span>                         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">select</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">SyndicationItem</span></strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   71</span>                        
{</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   72</span>                             <span style="COLOR: #dfdfbf">Title</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">TextSyndicationContent</span>(<span style="COLOR: #dfdfbf">e</span>.<span style="COLOR: #dfdfbf">Message</span>),</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   73</span>                             <span style="COLOR: #dfdfbf">Content</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">TextSyndicationContent</span>(<span style="COLOR: #dfdfbf">e</span>.<span style="COLOR: #dfdfbf">StackTrace</span>)</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   74</span>                        
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   75</span>            
};</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   76</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span><span style="COLOR: #dfdfbf">feed</span>;</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   77</span>        
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   78</span>    
}</strong>
          </p>
          <p style="MARGIN: 0px">
            <strong>
              <span style="COLOR: #85ac8d">   79</span> }</strong>
          </p>
        </div>
        <p>
        </p>
        <p>
Modify the App.config file: 
</p>
        <p>
 
</p>
        <div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 876px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    1</span> <span style="COLOR: #efef8f">&lt;?</span><span style="COLOR: #e3c66a">xml</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">version</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">1.0</span><span style="COLOR: #efef8f">" </span><span style="COLOR: white">encoding</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">utf-8</span><span style="COLOR: #efef8f">"
?&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    2</span> <span style="COLOR: #efef8f">&lt;</span><span style="COLOR: #e3c66a">configuration</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    3</span> <span style="COLOR: #efef8f">   
&lt;</span><span style="COLOR: #e3c66a">configSections</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    4</span> <span style="COLOR: #efef8f">   
&lt;/</span><span style="COLOR: #e3c66a">configSections</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    5</span> <span style="COLOR: #efef8f">   
&lt;</span><span style="COLOR: #e3c66a">connectionStrings</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    6</span> <span style="COLOR: #efef8f">       
&lt;</span><span style="COLOR: #e3c66a">add</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">name</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">SyndicationService.Properties.Settings.ApplicationLogConnectionString</span><span style="COLOR: #efef8f">"</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    7</span> <span style="COLOR: #efef8f">            </span><span style="COLOR: white">connectionString</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">Data
Source=Scorpion;Initial Catalog=ApplicationLog;Integrated Security=True</span><span style="COLOR: #efef8f">"</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    8</span> <span style="COLOR: #efef8f">            </span><span style="COLOR: white">providerName</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">System.Data.SqlClient</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    9</span> <span style="COLOR: #efef8f">   
&lt;/</span><span style="COLOR: #e3c66a">connectionStrings</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   10</span> <span style="COLOR: #efef8f">   
&lt;</span><span style="COLOR: #e3c66a">system.serviceModel</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   11</span> <span style="COLOR: #efef8f">       
&lt;</span><span style="COLOR: #e3c66a">services</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   12</span> <span style="COLOR: #efef8f">           
&lt;</span><span style="COLOR: #e3c66a">service</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">name</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">SyndicationService.Feeds</span><span style="COLOR: #efef8f">"&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   13</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">host</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   14</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">baseAddresses</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   15</span> <span style="COLOR: #efef8f">                       
&lt;</span><span style="COLOR: #e3c66a">add</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">baseAddress</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">http://localhost:8000/</span><span style="COLOR: #efef8f">"
/&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   16</span> <span style="COLOR: #efef8f">                   
&lt;/</span><span style="COLOR: #e3c66a">baseAddresses</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   17</span> <span style="COLOR: #efef8f">               
&lt;/</span><span style="COLOR: #e3c66a">host</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   18</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">endpoint</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">contract</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">SyndicationService.IFeeds</span><span style="COLOR: #efef8f">"</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   19</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">address</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">Feeds</span><span style="COLOR: #efef8f">"</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   20</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">binding</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">webHttpBinding</span><span style="COLOR: #efef8f">"</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   21</span> <span style="COLOR: #efef8f">                          </span><span style="COLOR: white">behaviorConfiguration</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">WebHttpBinding_Common</span><span style="COLOR: #efef8f">"/&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   22</span> <span style="COLOR: #efef8f">           
&lt;/</span><span style="COLOR: #e3c66a">service</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   23</span> <span style="COLOR: #efef8f">       
&lt;/</span><span style="COLOR: #e3c66a">services</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   24</span> <span style="COLOR: #efef8f">       
&lt;</span><span style="COLOR: #e3c66a">behaviors</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   25</span> <span style="COLOR: #efef8f">           
&lt;</span><span style="COLOR: #e3c66a">endpointBehaviors</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   26</span> <span style="COLOR: #efef8f">               
&lt;</span><span style="COLOR: #e3c66a">behavior</span><span style="COLOR: #efef8f"></span><span style="COLOR: white">name</span><span style="COLOR: #efef8f">="</span><span style="COLOR: #cc9393">WebHttpBinding_Common</span><span style="COLOR: #efef8f">"&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   27</span> <span style="COLOR: #efef8f">                   
&lt;</span><span style="COLOR: #e3c66a">webHttp</span><span style="COLOR: #efef8f">/&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   28</span> <span style="COLOR: #efef8f">               
&lt;/</span><span style="COLOR: #e3c66a">behavior</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   29</span> <span style="COLOR: #efef8f">           
&lt;/</span><span style="COLOR: #e3c66a">endpointBehaviors</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   30</span> <span style="COLOR: #efef8f">       
&lt;/</span><span style="COLOR: #e3c66a">behaviors</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   31</span> <span style="COLOR: #efef8f">   
&lt;/</span><span style="COLOR: #e3c66a">system.serviceModel</span><span style="COLOR: #efef8f">&gt;</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   32</span> <span style="COLOR: #efef8f">&lt;/</span><span style="COLOR: #e3c66a">configuration</span><span style="COLOR: #efef8f">&gt;</span></p>
        </div>
        <p>
        </p>
        <p>
You will need to adjust your project's Debug options to have command arguments that
look similar to the following to F5-debug your service.
</p>
        <blockquote>
          <p>
            <strong>"/client:iexplore.exe" "/clientArgs:http://localhost:8000/Feeds/Errors?env=Production&amp;app=GeoTracker"</strong>
          </p>
        </blockquote>
        <p>
Press F5 to test it out.
</p>
        <p>
Here is the IE7 RSS viewer:
</p>
        <p>
          <a href="http://scott.klueppel.net/content/binary/ErrorLogRSSFeed_1304B/IE7_RSS_Viewer.png">
            <img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="425" alt="IE7_RSS_Viewer" src="http://scott.klueppel.net/content/binary/ErrorLogRSSFeed_1304B/IE7_RSS_Viewer_thumb.png" width="602" border="0" />
          </a>
        </p>
        <p>
Here is your RSS aggregator viewing the same feed:
</p>
        <p>
          <a href="http://scott.klueppel.net/content/binary/ErrorLogRSSFeed_1304B/RSS_Aggregator.png">
            <img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height="387" alt="RSS_Aggregator" src="http://scott.klueppel.net/content/binary/ErrorLogRSSFeed_1304B/RSS_Aggregator_thumb.png" width="602" border="0" />
          </a>
        </p>
        <p>
You will, of course, want to add some additional information to the content of your <em>SyndidationItem</em>,
a bogus phrase works for this example. 
</p>
        <p>
Also, it is unusual that you would care to keep your exception details around for
a long period of time. Since this is a syndicated feed of application errors, you
should make special arrangements to archive or delete your exception log on a regular
basis. This will not only keep your insert and select times low, but will also alleviate
the burden placed on a new subscriber when all of the exceptions from the database
appear at once. An alternative would also be to modify the LINQ in the code above
to only bring back exceptions from the last 7-60 days depending on your counts. I
already archive my exceptions to a master exception repository for all environments
by way of an ETL job. This way I can report on my errors without disturbing the live
environments too.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=81c4ce95-c3f1-4bda-97cf-f344afba5a2d" />
      </body>
      <title>Error Log RSS Feed</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,81c4ce95-c3f1-4bda-97cf-f344afba5a2d.aspx</guid>
      <link>http://offroadcoder.com/2008/08/31/ErrorLogRSSFeed.aspx</link>
      <pubDate>Sun, 31 Aug 2008 08:37:38 GMT</pubDate>
      <description>&lt;p&gt;
Why clutter your inbox with error messages? Why make special code provisions for users
to receive error messages via email? Why not log your error messages and have users
subscribe to receive them in their favorite RSS aggregator?
&lt;/p&gt;
&lt;p&gt;
If you are logging your exceptions already, you may find it easier to provide a syndication
service. The process is ridiculously simple, and starts by creating a new project
using the "Syndication Service Library" template. This template creates everything
for you. All you need to do now is fill the &lt;em&gt;SyndicationFeed&lt;/em&gt; with &lt;em&gt;SyndicationItem&lt;/em&gt; objects.
&lt;/p&gt;
&lt;p&gt;
Add a new class file called Feeds.cs: 
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 873px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Linq&lt;/span&gt;;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ServiceModel&lt;/span&gt;;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ServiceModel&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Syndication&lt;/span&gt;;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ServiceModel&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Web&lt;/span&gt;;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;namespace&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;SyndicationService&lt;/span&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt; {&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="COLOR: #2b91af"&gt;ServiceContract&lt;/span&gt;]&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="COLOR: #2b91af"&gt;ServiceKnownType&lt;/span&gt;(&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;Atom10FeedFormatter&lt;/span&gt;))]&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="COLOR: #2b91af"&gt;ServiceKnownType&lt;/span&gt;(&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;typeof&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;Rss20FeedFormatter&lt;/span&gt;))]&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;interface&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IFeeds&lt;/span&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 13&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;]&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="COLOR: #2b91af"&gt;WebGet&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;UriTemplate&lt;/span&gt; = &lt;span style="COLOR: #c89191"&gt;"{type}?env={env}&amp;amp;app={app}"&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;BodyStyle&lt;/span&gt; = &lt;span style="COLOR: #2b91af"&gt;WebMessageBodyStyle&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Bare&lt;/span&gt;)]&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 16&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;SyndicationFeedFormatter&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;CreateFeed&lt;/span&gt;(&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;type&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;env&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;app&lt;/span&gt;);&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 17&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 18&lt;/span&gt;&amp;nbsp;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 19&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Feeds&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;IFeeds&lt;/span&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 20&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 21&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SyndicationFeedFormatter&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;CreateFeed&lt;/span&gt;(&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;type&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;env&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;app&lt;/span&gt;)&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 22&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 23&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;SyndicationFeed&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;feed&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;CreateSyndicationFeed&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;type&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;env&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;app&lt;/span&gt;);&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 24&lt;/span&gt;&amp;nbsp;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 25&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #7f9f7f"&gt;//
Return ATOM or RSS based on query string&lt;/span&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 26&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #7f9f7f"&gt;//
rss -&amp;gt; http://localhost:8000/Feeds/Errors?env=Production&amp;amp;app=MyAppName&lt;/span&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 27&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #7f9f7f"&gt;//
atom -&amp;gt; http://localhost:8000/Feeds/Errors?env=Production&amp;amp;app=MyAppName&amp;amp;format=atom&lt;/span&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 28&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;query&lt;/span&gt; = &lt;span style="COLOR: #2b91af"&gt;WebOperationContext&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Current&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;IncomingRequest&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;UriTemplateMatch&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;QueryParameters&lt;/span&gt;[&lt;span style="COLOR: #c89191"&gt;"format"&lt;/span&gt;];&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 29&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;SyndicationFeedFormatter&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;formatter&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;null&lt;/span&gt;;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 30&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;if&lt;/span&gt; (&lt;span style="COLOR: #dfdfbf"&gt;query&lt;/span&gt; == &lt;span style="COLOR: #c89191"&gt;"atom"&lt;/span&gt;)&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 31&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 32&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;formatter&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Atom10FeedFormatter&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;feed&lt;/span&gt;);&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 33&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 34&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;else&lt;/span&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 35&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 36&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;formatter&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Rss20FeedFormatter&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;feed&lt;/span&gt;);&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 37&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 38&lt;/span&gt;&amp;nbsp;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 39&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;return&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;formatter&lt;/span&gt;;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 40&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 41&lt;/span&gt;&amp;nbsp;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 42&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;private&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;static&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SyndicationFeed&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;CreateSyndicationFeed&lt;/span&gt;(&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;type&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;env&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;app&lt;/span&gt;)&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 43&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 44&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;SyndicationFeed&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;feed&lt;/span&gt;;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 45&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;switch&lt;/span&gt; (&lt;span style="COLOR: #dfdfbf"&gt;type&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ToLower&lt;/span&gt;())&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 46&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 47&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;case&lt;/span&gt; &lt;span style="COLOR: #c89191"&gt;"errors"&lt;/span&gt;:&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 48&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;feed&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;CreateErrorsFeed&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;type&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;env&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;app&lt;/span&gt;);&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 49&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;break&lt;/span&gt;;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 50&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;default&lt;/span&gt;:&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 51&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;feed&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SyndicationFeed&lt;/span&gt;(&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 52&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Format&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Feed
is unavailable - Type: {0} / Environment: {1} / Application: {2}"&lt;/span&gt;,&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 53&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;type&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;env&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;app&lt;/span&gt;), &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;null&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;null&lt;/span&gt;);&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 54&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;break&lt;/span&gt;;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 55&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 56&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;return&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;feed&lt;/span&gt;;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 57&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 58&lt;/span&gt;&amp;nbsp;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 59&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;private&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;static&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SyndicationFeed&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;CreateErrorsFeed&lt;/span&gt;(&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;type&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;env&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;app&lt;/span&gt;)&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 60&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 61&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;ApplicationLogDataContext&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;db&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ApplicationLogDataContext&lt;/span&gt;();&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 62&lt;/span&gt;&amp;nbsp;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 63&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;SyndicationFeed&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;feed&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SyndicationFeed&lt;/span&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 64&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 65&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;Title&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TextSyndicationContent&lt;/span&gt;(&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Format&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"{0}
{1} {2}"&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;env&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;app&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;type&lt;/span&gt;)),&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 66&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;Description&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TextSyndicationContent&lt;/span&gt;(&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 67&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Format&lt;/span&gt;(&lt;span style="COLOR: #c89191"&gt;"Application
error syndication for the {0} applicaiton ({1})."&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;app&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;env&lt;/span&gt;)),&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 68&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;Items&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;from&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;e&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;in&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;db&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Exceptions&lt;/span&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 69&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;where&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;e&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Environment&lt;/span&gt; == &lt;span style="COLOR: #dfdfbf"&gt;env&lt;/span&gt; &amp;amp;&amp;amp; &lt;span style="COLOR: #dfdfbf"&gt;e&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Application&lt;/span&gt; == &lt;span style="COLOR: #dfdfbf"&gt;app&lt;/span&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 70&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;select&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;SyndicationItem&lt;/span&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 71&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 72&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;Title&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TextSyndicationContent&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;e&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Message&lt;/span&gt;),&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 73&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;Content&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;TextSyndicationContent&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;e&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;StackTrace&lt;/span&gt;)&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 74&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 75&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
};&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 76&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;return&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;feed&lt;/span&gt;;&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 77&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 78&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}&lt;/strong&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;strong&gt;&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 79&lt;/span&gt; }&lt;/strong&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
Modify the App.config file: 
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;div style="OVERFLOW-Y: auto; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 876px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;xml&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;version&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;1.0&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;" &lt;/span&gt;&lt;span style="COLOR: white"&gt;encoding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;utf-8&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
?&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;configSections&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;configSections&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;connectionStrings&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;add&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;name&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;SyndicationService.Properties.Settings.ApplicationLogConnectionString&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;connectionString&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;Data
Source=Scorpion;Initial Catalog=ApplicationLog;Integrated Security=True&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;providerName&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;System.Data.SqlClient&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;connectionStrings&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 10&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;system.serviceModel&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 11&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;services&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 12&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;service&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;name&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;SyndicationService.Feeds&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 13&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;host&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 14&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;baseAddresses&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 15&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;add&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;baseAddress&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;http://localhost:8000/&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"
/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 16&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;baseAddresses&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 17&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;host&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 18&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;contract&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;SyndicationService.IFeeds&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 19&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;address&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;Feeds&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 20&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;binding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;webHttpBinding&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 21&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: white"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;WebHttpBinding_Common&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 22&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;service&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 23&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;services&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 24&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;behaviors&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 25&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;endpointBehaviors&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 26&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;behavior&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt; &lt;/span&gt;&lt;span style="COLOR: white"&gt;name&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;="&lt;/span&gt;&lt;span style="COLOR: #cc9393"&gt;WebHttpBinding_Common&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;"&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 27&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;webHttp&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 28&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;behavior&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 29&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;endpointBehaviors&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 30&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;behaviors&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 31&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;system.serviceModel&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 32&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: #efef8f"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #e3c66a"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: #efef8f"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
You will need to adjust your project's Debug options to have command arguments that
look similar to the following to F5-debug your service.
&lt;/p&gt;
&lt;blockquote&gt; 
&lt;p&gt;
&lt;strong&gt;"/client:iexplore.exe" "/clientArgs:http://localhost:8000/Feeds/Errors?env=Production&amp;amp;app=GeoTracker"&lt;/strong&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
Press F5 to test it out.
&lt;/p&gt;
&lt;p&gt;
Here is the IE7 RSS viewer:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://scott.klueppel.net/content/binary/ErrorLogRSSFeed_1304B/IE7_RSS_Viewer.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=425 alt=IE7_RSS_Viewer src="http://scott.klueppel.net/content/binary/ErrorLogRSSFeed_1304B/IE7_RSS_Viewer_thumb.png" width=602 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Here is your RSS aggregator viewing the same feed:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://scott.klueppel.net/content/binary/ErrorLogRSSFeed_1304B/RSS_Aggregator.png"&gt;&lt;img style="BORDER-TOP-WIDTH: 0px; BORDER-LEFT-WIDTH: 0px; BORDER-BOTTOM-WIDTH: 0px; BORDER-RIGHT-WIDTH: 0px" height=387 alt=RSS_Aggregator src="http://scott.klueppel.net/content/binary/ErrorLogRSSFeed_1304B/RSS_Aggregator_thumb.png" width=602 border=0&gt;&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
You will, of course, want to add some additional information to the content of your &lt;em&gt;SyndidationItem&lt;/em&gt;,
a bogus phrase works for this example. 
&lt;/p&gt;
&lt;p&gt;
Also, it is unusual that you would care to keep your exception details around for
a long period of time. Since this is a syndicated feed of application errors, you
should make special arrangements to archive or delete your exception log on a regular
basis. This will not only keep your insert and select times low, but will also alleviate
the burden placed on a new subscriber when all of the exceptions from the database
appear at once. An alternative would also be to modify the LINQ in the code above
to only bring back exceptions from the last 7-60 days depending on your counts. I
already archive my exceptions to a master exception repository for all environments
by way of an ETL job. This way I can report on my errors without disturbing the live
environments too.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=81c4ce95-c3f1-4bda-97cf-f344afba5a2d" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,81c4ce95-c3f1-4bda-97cf-f344afba5a2d.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>LINQ</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=08b6d0c7-0e40-4390-af14-a4f2f872ff1a</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,08b6d0c7-0e40-4390-af14-a4f2f872ff1a.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,08b6d0c7-0e40-4390-af14-a4f2f872ff1a.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=08b6d0c7-0e40-4390-af14-a4f2f872ff1a</wfw:commentRss>
      <slash:comments>13</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I decided to come out of my cave and look around 3.5 a bit. I haven't read much about
extension methods, but find them quite useful. They are nothing more than a syntactically
superior static helper method. Let's look at a quick example so I can get back to
coming up with more excuses to use them everywhere.
</p>
        <p>
I like to batch my database calls as much as possible to avoid repeated opening/closing
of connections, etc. To do this, I pass a bunch of ID values into a stored procedure
as a comma-separated string. In the stored proc, I break the string apart with everyone's
favorite table-valued function fn_MakeTable() to make a table of IDs. Then I can JOIN,
UPDATE, or INSERT as needed.
</p>
        <p>
So let's say I have a collection of Orders which I can easily convert to an array
of OrderID integers with LINQ. My new best friend to create a comma-separated string
of OrderIDs is the following. 
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  \cf4 System\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 Configuration\cf3 ;\par ??\par ??\cf1 {\b namespace}\cf3  \cf4 Common\par ??\cf3 \{\par ??\tab \cf1 {\b public}\cf3  \cf1 {\b static}\cf3  \cf1 {\b class}\cf3  \cf5 ArrayHelper\par ??\cf3 \tab \{\par ??\tab \tab \cf1 {\b public}\cf3  \cf1 {\b static}\cf3  \cf1 {\b string}\cf3  \cf4 ToCsv\cf3 &lt;\cf4 T\cf3 &gt;(\cf1 {\b this}\cf3  \cf4 T\cf3 [] \cf4 array\cf3 )\par ??\tab \tab \{\par ??\tab \tab \tab \cf5 Converter\cf3 &lt;\cf4 T\cf3 , \cf1 {\b string}\cf3 &gt; \cf4 converter\cf3  = (\cf4 t\cf3 ) =&gt;\par ??\tab \tab \tab \tab \{\par ??\tab \tab \tab \tab \tab \cf1 {\b return}\cf3  \cf4 t\cf3 .\cf4 ToString\cf3 ();\par ??\tab \tab \tab \tab \};\par ??\tab \tab \tab \cf1 {\b return}\cf3  \cf4 ToCsv\cf3 (\cf4 array\cf3 , \cf4 converter\cf3 );\par ??\tab \tab \}\par ??\par ??\tab \tab \cf1 {\b public}\cf3  \cf1 {\b static}\cf3  \cf1 {\b string}\cf3  \cf4 ToCsv\cf3 &lt;\cf4 T\cf3 &gt;(\cf1 {\b this}\cf3  \cf4 T\cf3 [] \cf4 array\cf3 , \cf5 Converter\cf3 &lt;\cf4 T\cf3 , \cf1 {\b string}\cf3 &gt; \cf4 converter\cf3 )\par ??\tab \tab \{\par ??\tab \tab \tab \cf5 CommaDelimitedStringCollection\cf3  \cf4 csv\cf3  = \cf1 {\b new}\cf3  \cf5 CommaDelimitedStringCollection\cf3 ();\par ??\tab \tab \tab \cf1 {\b foreach}\cf3  (\cf4 T\cf3  \cf4 t\cf3  \cf1 {\b in}\cf3  \cf4 array\cf3 )\par ??\tab \tab \tab \{\par ??\tab \tab \tab \tab \cf4 csv\cf3 .\cf4 Add\cf3 (\cf4 converter\cf3 (\cf4 t\cf3 ));\par ??\tab \tab \tab \}\par ??\tab \tab \tab \cf1 {\b return}\cf3  \cf4 csv\cf3 .\cf4 ToString\cf3 ();\par ??\tab \tab \}\par ??\tab \}\par ??\}}
-->
        <div style="OVERFLOW-Y: scroll; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 760px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    1</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    2</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">using</span><span style="COLOR: #dfdfbf">System</span>.<span style="COLOR: #dfdfbf">Configuration</span>;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    3</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    4</span> <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">namespace</span><span style="COLOR: #dfdfbf">Common</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    5</span> {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    6</span>     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">public</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">static</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">class</span><span style="COLOR: #2b91af">ArrayHelper</span></p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    7</span>     {
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    8</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">public</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">static</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">ToCsv</span>&lt;<span style="COLOR: #dfdfbf">T</span>&gt;(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">this</span><span style="COLOR: #dfdfbf">T</span>[] <span style="COLOR: #dfdfbf">array</span>)
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">    9</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   10</span>             <span style="COLOR: #2b91af">Converter</span>&lt;<span style="COLOR: #dfdfbf">T</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span>&gt; <span style="COLOR: #dfdfbf">converter</span> =
(<span style="COLOR: #dfdfbf">t</span>) =&gt;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   11</span>                
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   12</span>                     <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span><span style="COLOR: #dfdfbf">t</span>.<span style="COLOR: #dfdfbf">ToString</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   13</span>                
};
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   14</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span><span style="COLOR: #dfdfbf">ToCsv</span>(<span style="COLOR: #dfdfbf">array</span>, <span style="COLOR: #dfdfbf">converter</span>);
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   15</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   16</span> 
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   17</span>         <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">public</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">static</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">ToCsv</span>&lt;<span style="COLOR: #dfdfbf">T</span>&gt;(<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">this</span><span style="COLOR: #dfdfbf">T</span>[] <span style="COLOR: #dfdfbf">array</span>, <span style="COLOR: #2b91af">Converter</span>&lt;<span style="COLOR: #dfdfbf">T</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span>&gt; <span style="COLOR: #dfdfbf">converter</span>)
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   18</span>        
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   19</span>             <span style="COLOR: #2b91af">CommaDelimitedStringCollection</span><span style="COLOR: #dfdfbf">csv</span> = <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">new</span><span style="COLOR: #2b91af">CommaDelimitedStringCollection</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   20</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">foreach</span> (<span style="COLOR: #dfdfbf">T</span><span style="COLOR: #dfdfbf">t</span><span style="FONT-WEIGHT: bold; COLOR: #e1e18a">in</span><span style="COLOR: #dfdfbf">array</span>)
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   21</span>            
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   22</span>                 <span style="COLOR: #dfdfbf">csv</span>.<span style="COLOR: #dfdfbf">Add</span>(<span style="COLOR: #dfdfbf">converter</span>(<span style="COLOR: #dfdfbf">t</span>));
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   23</span>            
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   24</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span><span style="COLOR: #dfdfbf">csv</span>.<span style="COLOR: #dfdfbf">ToString</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   25</span>        
}
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   26</span>     }
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   27</span> }
</p>
        </div>
        <p>
 
</p>
        <p>
You'll see that I have two ToCsv() methods. The first takes a generic array using
the <strong>this</strong> keyword and uses .ToString() as a default converter to string.
The second method requires you to additionally pass in a converter to convert the
object of type T to a string. Take those converted strings, add them to a <em>CommaDelimitedStringCollection</em> and
.ToString() that collection to a full CSV string of integer values.
</p>
        <p>
There are two ways to call these extension methods. The first is the more familiar
way. Since they are really nothing more than static helper methods, call them just
like any other:
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red225\green225\blue138;\red223\green223\blue191;\red138\green204\blue207;\red43\green145\blue175;}??\fs18 \cf1\cb2\highlight2 \tab \tab \tab \cf3 {\b int}\cf1 [] \cf4 array\cf1  = \{ \cf5 123\cf1 , \cf5 456\cf1  \};\par ??\tab \tab \tab \cf3 {\b string}\cf1  \cf4 csv\cf1  = \cf4 Common\cf1 .\cf6 ArrayHelper\cf1 .\cf4 ToCsv\cf1 (\cf4 array\cf1 );}
-->
        <div style="FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 469px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 34px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   14</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">int</span>[] <span style="COLOR: #dfdfbf">array</span> =
{ <span style="COLOR: #8acccf">123</span>, <span style="COLOR: #8acccf">456</span> };
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   15</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">csv</span> = <span style="COLOR: #dfdfbf">Common</span>.<span style="COLOR: #2b91af">ArrayHelper</span>.<span style="COLOR: #dfdfbf">ToCsv</span>(<span style="COLOR: #dfdfbf">array</span>);
</p>
        </div>
        <p>
 
</p>
        <p>
The second is the more elegant and more intuitive way. Call it as if it was built
into the Framework: 
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red225\green225\blue138;\red223\green223\blue191;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 \tab \tab \tab \cf3 {\b int}\cf1 [] \cf4 array\cf1  = \{ \cf5 123\cf1 , \cf5 456\cf1  \};\par ??\tab \tab \tab \cf3 {\b string}\cf1  \cf4 csv\cf1  = \cf4 array\cf1 .\cf4 ToCsv\cf1 ();}
-->
        <div style="FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 467px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 32px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   14</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">int</span>[] <span style="COLOR: #dfdfbf">array</span> =
{ <span style="COLOR: #8acccf">123</span>, <span style="COLOR: #8acccf">456</span> };
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   15</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">csv</span> = <span style="COLOR: #dfdfbf">array</span>.<span style="COLOR: #dfdfbf">ToCsv</span>();
</p>
        </div>
        <p>
 
</p>
        <p>
You may be wondering, what if I write a method that matches the signature of a built-in
method like .ToString(). Well, the built-in methods take precedence over extension
methods, so <strong>array.ToString()</strong> will still appear as <strong>System.Int32[]</strong>.
To get your new meaning of .ToString(), you just have to call it in the static helper
method way detailed above.
</p>
        <p>
For a generic array of T, you will likely want to provide your own <em>Converter</em> if
T's .ToString() method does not display the information you want to show in the CSV
string. Below is a lame example of a converter. It takes the <em>int</em> value,
converts it to the <em>char</em> value.
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red43\green145\blue175;\red225\green225\blue138;\red223\green223\blue191;}??\fs18 \cf1\cb2\highlight2 \tab \tab \tab \cf3 Converter\cf1 &lt;\cf4 {\b int}\cf1 , \cf4 {\b string}\cf1 &gt; \cf5 converter\cf1  = (\cf5 i\cf1 ) =&gt;\par ??\tab \tab \tab \{\par ??\tab \tab \tab \tab \cf4 {\b return}\cf1  ((\cf4 {\b char}\cf1 )\cf5 i\cf1 ).\cf5 ToString\cf1 ();\par ??\tab \tab \tab \};\par ??\tab \tab \tab \cf5 csv\cf1  = \cf5 array\cf1 .\cf5 ToCsv\cf1 (\cf5 converter\cf1 );}
-->
        <div style="FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 467px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 72px">
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   21</span>             <span style="COLOR: #2b91af">Converter</span>&lt;<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">int</span>, <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span>&gt; <span style="COLOR: #dfdfbf">converter</span> =
(<span style="COLOR: #dfdfbf">i</span>) =&gt;
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   22</span>            
{
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   23</span>                 <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">return</span> ((<span style="FONT-WEIGHT: bold; COLOR: #e1e18a">char</span>)<span style="COLOR: #dfdfbf">i</span>).<span style="COLOR: #dfdfbf">ToString</span>();
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   24</span>            
};
</p>
          <p style="MARGIN: 0px">
            <span style="COLOR: #85ac8d">   25</span>             <span style="FONT-WEIGHT: bold; COLOR: #e1e18a">string</span><span style="COLOR: #dfdfbf">csv</span> = <span style="COLOR: #dfdfbf">array</span>.<span style="COLOR: #dfdfbf">ToCsv</span>(<span style="COLOR: #dfdfbf">converter</span>);
</p>
        </div>
        <p>
 
</p>
        <p>
I think something so simple, and definitely re-usable, would benefit any developer.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=08b6d0c7-0e40-4390-af14-a4f2f872ff1a" />
      </body>
      <title>C# 3.0 Extension Methods</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,08b6d0c7-0e40-4390-af14-a4f2f872ff1a.aspx</guid>
      <link>http://offroadcoder.com/2008/08/27/C30ExtensionMethods.aspx</link>
      <pubDate>Wed, 27 Aug 2008 02:07:12 GMT</pubDate>
      <description>&lt;p&gt;
I decided to come out of my cave and look around 3.5 a bit. I haven't read much about
extension methods, but find them quite useful. They are nothing more than a syntactically
superior static helper method. Let's look at a quick example so I can get back to
coming up with more excuses to use them everywhere.
&lt;/p&gt;
&lt;p&gt;
I like to batch my database calls as much as possible to avoid repeated opening/closing
of connections, etc. To do this, I pass a bunch of ID values into a stored procedure
as a comma-separated string. In the stored proc, I break the string apart with everyone's
favorite table-valued function fn_MakeTable() to make a table of IDs. Then I can JOIN,
UPDATE, or INSERT as needed.
&lt;/p&gt;
&lt;p&gt;
So let's say I have a collection of Orders which I can easily convert to an array
of OrderID integers with LINQ. My new best friend to create a comma-separated string
of OrderIDs is the following. 
&lt;/p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red225\green225\blue138;\red63\green63\blue63;\red220\green220\blue204;\red223\green223\blue191;\red43\green145\blue175;}??\fs18 \cf1\cb2\highlight2 {\b using}\cf3  \cf4 System\cf3 ;\par ??\cf1 {\b using}\cf3  \cf4 System\cf3 .\cf4 Configuration\cf3 ;\par ??\par ??\cf1 {\b namespace}\cf3  \cf4 Common\par ??\cf3 \{\par ??\tab \cf1 {\b public}\cf3  \cf1 {\b static}\cf3  \cf1 {\b class}\cf3  \cf5 ArrayHelper\par ??\cf3 \tab \{\par ??\tab \tab \cf1 {\b public}\cf3  \cf1 {\b static}\cf3  \cf1 {\b string}\cf3  \cf4 ToCsv\cf3 &amp;lt;\cf4 T\cf3 &amp;gt;(\cf1 {\b this}\cf3  \cf4 T\cf3 [] \cf4 array\cf3 )\par ??\tab \tab \{\par ??\tab \tab \tab \cf5 Converter\cf3 &amp;lt;\cf4 T\cf3 , \cf1 {\b string}\cf3 &amp;gt; \cf4 converter\cf3  = (\cf4 t\cf3 ) =&amp;gt;\par ??\tab \tab \tab \tab \{\par ??\tab \tab \tab \tab \tab \cf1 {\b return}\cf3  \cf4 t\cf3 .\cf4 ToString\cf3 ();\par ??\tab \tab \tab \tab \};\par ??\tab \tab \tab \cf1 {\b return}\cf3  \cf4 ToCsv\cf3 (\cf4 array\cf3 , \cf4 converter\cf3 );\par ??\tab \tab \}\par ??\par ??\tab \tab \cf1 {\b public}\cf3  \cf1 {\b static}\cf3  \cf1 {\b string}\cf3  \cf4 ToCsv\cf3 &amp;lt;\cf4 T\cf3 &amp;gt;(\cf1 {\b this}\cf3  \cf4 T\cf3 [] \cf4 array\cf3 , \cf5 Converter\cf3 &amp;lt;\cf4 T\cf3 , \cf1 {\b string}\cf3 &amp;gt; \cf4 converter\cf3 )\par ??\tab \tab \{\par ??\tab \tab \tab \cf5 CommaDelimitedStringCollection\cf3  \cf4 csv\cf3  = \cf1 {\b new}\cf3  \cf5 CommaDelimitedStringCollection\cf3 ();\par ??\tab \tab \tab \cf1 {\b foreach}\cf3  (\cf4 T\cf3  \cf4 t\cf3  \cf1 {\b in}\cf3  \cf4 array\cf3 )\par ??\tab \tab \tab \{\par ??\tab \tab \tab \tab \cf4 csv\cf3 .\cf4 Add\cf3 (\cf4 converter\cf3 (\cf4 t\cf3 ));\par ??\tab \tab \tab \}\par ??\tab \tab \tab \cf1 {\b return}\cf3  \cf4 csv\cf3 .\cf4 ToString\cf3 ();\par ??\tab \tab \}\par ??\tab \}\par ??\}}
--&gt;
&lt;div style="OVERFLOW-Y: scroll; FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; OVERFLOW-X: auto; WIDTH: 760px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 200px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;using&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;System&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Configuration&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 3&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 4&lt;/span&gt;&amp;nbsp;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;namespace&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;Common&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5&lt;/span&gt; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 6&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;static&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;ArrayHelper&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 7&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 8&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;static&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;ToCsv&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #dfdfbf"&gt;T&lt;/span&gt;&amp;gt;(&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;this&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;T&lt;/span&gt;[] &lt;span style="COLOR: #dfdfbf"&gt;array&lt;/span&gt;)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; 9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Converter&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #dfdfbf"&gt;T&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt;&amp;gt; &lt;span style="COLOR: #dfdfbf"&gt;converter&lt;/span&gt; =
(&lt;span style="COLOR: #dfdfbf"&gt;t&lt;/span&gt;) =&amp;gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;return&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;t&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ToString&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 13&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
};
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;return&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;ToCsv&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;array&lt;/span&gt;, &lt;span style="COLOR: #dfdfbf"&gt;converter&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 16&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 17&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;static&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;ToCsv&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #dfdfbf"&gt;T&lt;/span&gt;&amp;gt;(&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;this&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;T&lt;/span&gt;[] &lt;span style="COLOR: #dfdfbf"&gt;array&lt;/span&gt;, &lt;span style="COLOR: #2b91af"&gt;Converter&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #dfdfbf"&gt;T&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt;&amp;gt; &lt;span style="COLOR: #dfdfbf"&gt;converter&lt;/span&gt;)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 18&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 19&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;CommaDelimitedStringCollection&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;csv&lt;/span&gt; = &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;CommaDelimitedStringCollection&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 20&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;foreach&lt;/span&gt; (&lt;span style="COLOR: #dfdfbf"&gt;T&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;t&lt;/span&gt; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;in&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;array&lt;/span&gt;)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 21&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 22&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #dfdfbf"&gt;csv&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;Add&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;converter&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;t&lt;/span&gt;));
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 23&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 24&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;return&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;csv&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ToString&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 25&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 26&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 27&lt;/span&gt; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
You'll see that I have two ToCsv() methods. The first takes a generic array using
the &lt;strong&gt;this&lt;/strong&gt; keyword and uses .ToString() as a default converter to string.
The second method requires you to additionally pass in a converter to convert the
object of type T to a string. Take those converted strings, add them to a &lt;em&gt;CommaDelimitedStringCollection&lt;/em&gt; and
.ToString() that collection to a full CSV string of integer values.
&lt;/p&gt;
&lt;p&gt;
There are two ways to call these extension methods. The first is the more familiar
way. Since they are really nothing more than static helper methods, call them just
like any other:
&lt;/p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red225\green225\blue138;\red223\green223\blue191;\red138\green204\blue207;\red43\green145\blue175;}??\fs18 \cf1\cb2\highlight2 \tab \tab \tab \cf3 {\b int}\cf1 [] \cf4 array\cf1  = \{ \cf5 123\cf1 , \cf5 456\cf1  \};\par ??\tab \tab \tab \cf3 {\b string}\cf1  \cf4 csv\cf1  = \cf4 Common\cf1 .\cf6 ArrayHelper\cf1 .\cf4 ToCsv\cf1 (\cf4 array\cf1 );}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 469px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 34px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;int&lt;/span&gt;[] &lt;span style="COLOR: #dfdfbf"&gt;array&lt;/span&gt; =
{ &lt;span style="COLOR: #8acccf"&gt;123&lt;/span&gt;, &lt;span style="COLOR: #8acccf"&gt;456&lt;/span&gt; };
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;csv&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;Common&lt;/span&gt;.&lt;span style="COLOR: #2b91af"&gt;ArrayHelper&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ToCsv&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;array&lt;/span&gt;);
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The second is the more elegant and more intuitive way. Call it as if it was built
into the Framework: 
&lt;/p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red225\green225\blue138;\red223\green223\blue191;\red138\green204\blue207;}??\fs18 \cf1\cb2\highlight2 \tab \tab \tab \cf3 {\b int}\cf1 [] \cf4 array\cf1  = \{ \cf5 123\cf1 , \cf5 456\cf1  \};\par ??\tab \tab \tab \cf3 {\b string}\cf1  \cf4 csv\cf1  = \cf4 array\cf1 .\cf4 ToCsv\cf1 ();}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 467px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 32px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;int&lt;/span&gt;[] &lt;span style="COLOR: #dfdfbf"&gt;array&lt;/span&gt; =
{ &lt;span style="COLOR: #8acccf"&gt;123&lt;/span&gt;, &lt;span style="COLOR: #8acccf"&gt;456&lt;/span&gt; };
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;csv&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;array&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ToCsv&lt;/span&gt;();
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
You may be wondering, what if I write a method that matches the signature of a built-in
method like .ToString(). Well, the built-in methods take precedence over extension
methods, so &lt;strong&gt;array.ToString()&lt;/strong&gt; will still appear as &lt;strong&gt;System.Int32[]&lt;/strong&gt;.
To get your new meaning of .ToString(), you just have to call it in the static helper
method way detailed above.
&lt;/p&gt;
&lt;p&gt;
For a generic array of T, you will likely want to provide your own &lt;em&gt;Converter&lt;/em&gt; if
T's .ToString() method does not display the information you want to show in the CSV
string. Below is a lame&amp;nbsp;example of a converter. It takes the &lt;em&gt;int&lt;/em&gt; value,
converts it to the &lt;em&gt;char&lt;/em&gt; value.
&lt;/p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red43\green145\blue175;\red225\green225\blue138;\red223\green223\blue191;}??\fs18 \cf1\cb2\highlight2 \tab \tab \tab \cf3 Converter\cf1 &amp;lt;\cf4 {\b int}\cf1 , \cf4 {\b string}\cf1 &amp;gt; \cf5 converter\cf1  = (\cf5 i\cf1 ) =&amp;gt;\par ??\tab \tab \tab \{\par ??\tab \tab \tab \tab \cf4 {\b return}\cf1  ((\cf4 {\b char}\cf1 )\cf5 i\cf1 ).\cf5 ToString\cf1 ();\par ??\tab \tab \tab \};\par ??\tab \tab \tab \cf5 csv\cf1  = \cf5 array\cf1 .\cf5 ToCsv\cf1 (\cf5 converter\cf1 );}
--&gt;
&lt;div style="FONT-SIZE: 9pt; BACKGROUND: #3f3f3f; WIDTH: 467px; COLOR: #dcdccc; FONT-FAMILY: consolas; HEIGHT: 72px"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 21&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Converter&lt;/span&gt;&amp;lt;&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;int&lt;/span&gt;, &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt;&amp;gt; &lt;span style="COLOR: #dfdfbf"&gt;converter&lt;/span&gt; =
(&lt;span style="COLOR: #dfdfbf"&gt;i&lt;/span&gt;) =&amp;gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 22&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 23&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;return&lt;/span&gt; ((&lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;char&lt;/span&gt;)&lt;span style="COLOR: #dfdfbf"&gt;i&lt;/span&gt;).&lt;span style="COLOR: #dfdfbf"&gt;ToString&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 24&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
};
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 25&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="FONT-WEIGHT: bold; COLOR: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="COLOR: #dfdfbf"&gt;csv&lt;/span&gt; = &lt;span style="COLOR: #dfdfbf"&gt;array&lt;/span&gt;.&lt;span style="COLOR: #dfdfbf"&gt;ToCsv&lt;/span&gt;(&lt;span style="COLOR: #dfdfbf"&gt;converter&lt;/span&gt;);
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
I think something so simple, and definitely re-usable, would benefit any developer.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=08b6d0c7-0e40-4390-af14-a4f2f872ff1a" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,08b6d0c7-0e40-4390-af14-a4f2f872ff1a.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>LINQ</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=01df2e81-97da-4179-a4b0-a7c6178f5599</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,01df2e81-97da-4179-a4b0-a7c6178f5599.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,01df2e81-97da-4179-a4b0-a7c6178f5599.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=01df2e81-97da-4179-a4b0-a7c6178f5599</wfw:commentRss>
      <slash:comments>8</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Our friends at Microsoft may have slipped one in on us. After installing the 3.5 Framework
Service Pack 1, it appears that you no longer need the [DataContract] or [DataMember]
attributes on your DataContracts and DataMembers. I'm not sure what the motivation
was for this "enhancement", but it caused some trouble for me the other day.
</p>
        <p>
For this example I will be using the base project VS2008 gives you when you create
a new WCF Service Library. I am simply adding a NestedType to the CompositeType given
in the base project.
</p>
        <p>
Before installing SP1, having code as it appears below would cause an error during
Metadata Exchange that reads something like "Metadata contains a reference that cannot
be resolved". Notice that <em>CompositeType</em>'s <em>NestedObject</em> is marked
as [DataMember] and also notice that the NestedType class is not marked as [DataContract]
and has no [DataMember] attributes. Adding [DataContract] on <em>NestedType</em> and
[DataMember] on <em>IsVisible</em> will clear this error and everything will work
as expected.  
</p>
        <!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red43\green145\blue175;\red225\green225\blue138;\red223\green223\blue191;\red200\green145\blue145;}??\fs18 \cf1\cb2\highlight2 \tab [\cf3 DataContract\cf1 ]\par ??\tab \cf4 {\b public}\cf1  \cf4 {\b class}\cf1  \cf3 CompositeType\par ??\cf1 \tab \{\par ??\tab \tab \cf4 {\b bool}\cf1  \cf5 boolValue\cf1  = \cf4 {\b true}\cf1 ;\par ??\tab \tab \cf4 {\b string}\cf1  \cf5 stringValue\cf1  = \cf6 "Hello "\cf1 ;\par ??\tab \tab \cf3 NestedType\cf1  \cf5 nestedObject\cf1  = \cf4 {\b new}\cf1  \cf3 NestedType\cf1 ();\par ??\par ??\tab \tab [\cf3 DataMember\cf1 ]\par ??\tab \tab \cf4 {\b public}\cf1  \cf4 {\b bool}\cf1  \cf5 BoolValue\par ??\cf1 \tab \tab \{\par ??\tab \tab \tab \cf4 {\b get}\cf1  \{ \cf4 {\b return}\cf1  \cf5 boolValue\cf1 ; \}\par ??\tab \tab \tab \cf4 {\b set}\cf1  \{ \cf5 boolValue\cf1  = \cf4 {\b value}\cf1 ; \}\par ??\tab \tab \}\par ??\par ??\tab \tab [\cf3 DataMember\cf1 ]\par ??\tab \tab \cf4 {\b public}\cf1  \cf4 {\b string}\cf1  \cf5 StringValue\par ??\cf1 \tab \tab \{\par ??\tab \tab \tab \cf4 {\b get}\cf1  \{ \cf4 {\b return}\cf1  \cf5 stringValue\cf1 ; \}\par ??\tab \tab \tab \cf4 {\b set}\cf1  \{ \cf5 stringValue\cf1  = \cf4 {\b value}\cf1 ; \}\par ??\tab \tab \}\par ??\par ??\tab \tab [\cf3 DataMember\cf1 ]\par ??\tab \tab \cf4 {\b public}\cf1  \cf3 NestedType\cf1  \cf5 NestedObject\par ??\cf1 \tab \tab \{\par ??\tab \tab \tab \cf4 {\b get}\cf1  \{ \cf4 {\b return}\cf1  \cf5 nestedObject\cf1 ; \}\par ??\tab \tab \tab \cf4 {\b set}\cf1  \{ \cf5 nestedObject\cf1  = \cf4 {\b value}\cf1 ; \}\par ??\tab \tab \}\par ??\tab \}\par ??\par ??\tab \cf4 {\b public}\cf1  \cf4 {\b class}\cf1  \cf3 NestedType\par ??\cf1 \tab \{\par ??\tab \tab \cf4 {\b bool}\cf1  \cf5 isVisible\cf1  = \cf4 {\b false}\cf1 ;\par ??\par ??\tab \tab \cf4 {\b public}\cf1  \cf4 {\b bool}\cf1  \cf5 IsVisible\par ??\cf1 \tab \tab \{\par ??\tab \tab \tab \cf4 {\b get}\cf1  \{ \cf4 {\b return}\cf1  \cf5 isVisible\cf1 ; \}\par ??\tab \tab \tab \cf4 {\b set}\cf1  \{ \cf5 isVisible\cf1  = \cf4 {\b value}\cf1 ; \}\par ??\tab \tab \}\par ??\tab \}}
-->
        <div style="overflow-y: scroll; font-size: 9pt; background: #3f3f3f; width: 600px; color: #dcdccc; font-family: consolas; height: 200px">
          <p style="margin: 0px">
            <span style="color: #85ac8d">   24</span>     [<span style="color: #2b91af">DataContract</span>]
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   25</span>     <span style="font-weight: bold; color: #e1e18a">public</span><span style="font-weight: bold; color: #e1e18a">class</span><span style="color: #2b91af">CompositeType</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   26</span>     {
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   27</span>         <span style="font-weight: bold; color: #e1e18a">bool</span><span style="color: #dfdfbf">boolValue</span> = <span style="font-weight: bold; color: #e1e18a">true</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   28</span>         <span style="font-weight: bold; color: #e1e18a">string</span><span style="color: #dfdfbf">stringValue</span> = <span style="color: #c89191">"Hello
"</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   29</span>         <span style="color: #2b91af">NestedType</span><span style="color: #dfdfbf">nestedObject</span> = <span style="font-weight: bold; color: #e1e18a">new</span><span style="color: #2b91af">NestedType</span>();
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   30</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   31</span>        
[<span style="color: #2b91af">DataMember</span>]
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   32</span>         <span style="font-weight: bold; color: #e1e18a">public</span><span style="font-weight: bold; color: #e1e18a">bool</span><span style="color: #dfdfbf">BoolValue</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   33</span>        
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   34</span>             <span style="font-weight: bold; color: #e1e18a">get</span> { <span style="font-weight: bold; color: #e1e18a">return</span><span style="color: #dfdfbf">boolValue</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   35</span>             <span style="font-weight: bold; color: #e1e18a">set</span> { <span style="color: #dfdfbf">boolValue</span> = <span style="font-weight: bold; color: #e1e18a">value</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   36</span>        
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   37</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   38</span>        
[<span style="color: #2b91af">DataMember</span>]
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   39</span>         <span style="font-weight: bold; color: #e1e18a">public</span><span style="font-weight: bold; color: #e1e18a">string</span><span style="color: #dfdfbf">StringValue</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   40</span>        
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   41</span>             <span style="font-weight: bold; color: #e1e18a">get</span> { <span style="font-weight: bold; color: #e1e18a">return</span><span style="color: #dfdfbf">stringValue</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   42</span>             <span style="font-weight: bold; color: #e1e18a">set</span> { <span style="color: #dfdfbf">stringValue</span> = <span style="font-weight: bold; color: #e1e18a">value</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   43</span>        
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   44</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   45</span>        
[<span style="color: #2b91af">DataMember</span>]
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   46</span>         <span style="font-weight: bold; color: #e1e18a">public</span><span style="color: #2b91af">NestedType</span><span style="color: #dfdfbf">NestedObject</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   47</span>        
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   48</span>             <span style="font-weight: bold; color: #e1e18a">get</span> { <span style="font-weight: bold; color: #e1e18a">return</span><span style="color: #dfdfbf">nestedObject</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   49</span>             <span style="font-weight: bold; color: #e1e18a">set</span> { <span style="color: #dfdfbf">nestedObject</span> = <span style="font-weight: bold; color: #e1e18a">value</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   50</span>        
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   51</span>     }
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   52</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   53</span>     <span style="font-weight: bold; color: #e1e18a">public</span><span style="font-weight: bold; color: #e1e18a">class</span><span style="color: #2b91af">NestedType</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   54</span>     {
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   55</span>         <span style="font-weight: bold; color: #e1e18a">bool</span><span style="color: #dfdfbf">isVisible</span> = <span style="font-weight: bold; color: #e1e18a">false</span>;
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   56</span> 
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   57</span>         <span style="font-weight: bold; color: #e1e18a">public</span><span style="font-weight: bold; color: #e1e18a">bool</span><span style="color: #dfdfbf">IsVisible</span></p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   58</span>        
{
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   59</span>             <span style="font-weight: bold; color: #e1e18a">get</span> { <span style="font-weight: bold; color: #e1e18a">return</span><span style="color: #dfdfbf">isVisible</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   60</span>             <span style="font-weight: bold; color: #e1e18a">set</span> { <span style="color: #dfdfbf">isVisible</span> = <span style="font-weight: bold; color: #e1e18a">value</span>;
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   61</span>        
}
</p>
          <p style="margin: 0px">
            <span style="color: #85ac8d">   62</span>     }
</p>
        </div>
        <p>
 
</p>
        <p>
The same code in use after SP1 will not cause this error. WCF will interpret from <em>CompositeType</em>'s
[DataContract] attribute and <em>NestedObject</em>'s [DataMember] attribute that you
meant to put [DataContract] on <em>NestedType</em>. So what's the big deal, right?
WCF is doing me a solid by guessing at what I meant to do. To me, this violates the
repeated opt-in theme present in WCF. For every other important decision, the developer
must write code to opt-in to a feature. For example, TransactionFlow defaults to false
so we don't use the client's incoming transaction with explicitly writing code that
says to do so. 
</p>
        <p>
This is clearly not on the same level as TransactionFlow. But why does it assume something
about my objects? Why does it assume that every member of my object should be a DataMember?
</p>
        <p>
I noticed this new "feature" when troubleshooting some code that had different namespace
names specified in the DataContract attribute. Since the <em>NestedType</em> did not
have a [DataContract] attribute, the namespace was using the original namespace name.
The equivalent of <em>CompositeType </em>came through correctly, but the <em>NestedObject </em>had
no value.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=01df2e81-97da-4179-a4b0-a7c6178f5599" />
      </body>
      <title>3.5 Service Pack 1 - WCF Enhancement?</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,01df2e81-97da-4179-a4b0-a7c6178f5599.aspx</guid>
      <link>http://offroadcoder.com/2008/08/24/35ServicePack1WCFEnhancement.aspx</link>
      <pubDate>Sun, 24 Aug 2008 01:57:49 GMT</pubDate>
      <description>&lt;p&gt;
Our friends at Microsoft may have slipped one in on us. After installing the 3.5 Framework
Service Pack 1, it appears that you no longer need the [DataContract] or [DataMember]
attributes on your DataContracts and DataMembers. I'm not sure what the motivation
was for this "enhancement", but it caused some trouble for me the other day.
&lt;/p&gt;
&lt;p&gt;
For this example I will be using the base project VS2008 gives you when you create
a new WCF Service Library. I am simply adding a NestedType to the CompositeType given
in the base project.
&lt;/p&gt;
&lt;p&gt;
Before installing SP1, having code as it appears below would cause an error during
Metadata Exchange that reads something like "Metadata contains a reference that cannot
be resolved". Notice that &lt;em&gt;CompositeType&lt;/em&gt;'s &lt;em&gt;NestedObject&lt;/em&gt; is marked
as [DataMember] and also notice that the NestedType class is not marked as [DataContract]
and has no [DataMember] attributes. Adding [DataContract] on &lt;em&gt;NestedType&lt;/em&gt; and
[DataMember] on &lt;em&gt;IsVisible&lt;/em&gt; will clear this error and everything will work
as expected.&amp;nbsp; 
&lt;/p&gt;
&lt;!--
{\rtf1\ansi\ansicpg\lang1024\noproof65001\uc1 \deff0{\fonttbl{\f0\fnil\fcharset0\fprq1 Consolas;}}{\colortbl;??\red220\green220\blue204;\red63\green63\blue63;\red43\green145\blue175;\red225\green225\blue138;\red223\green223\blue191;\red200\green145\blue145;}??\fs18 \cf1\cb2\highlight2 \tab [\cf3 DataContract\cf1 ]\par ??\tab \cf4 {\b public}\cf1  \cf4 {\b class}\cf1  \cf3 CompositeType\par ??\cf1 \tab \{\par ??\tab \tab \cf4 {\b bool}\cf1  \cf5 boolValue\cf1  = \cf4 {\b true}\cf1 ;\par ??\tab \tab \cf4 {\b string}\cf1  \cf5 stringValue\cf1  = \cf6 "Hello "\cf1 ;\par ??\tab \tab \cf3 NestedType\cf1  \cf5 nestedObject\cf1  = \cf4 {\b new}\cf1  \cf3 NestedType\cf1 ();\par ??\par ??\tab \tab [\cf3 DataMember\cf1 ]\par ??\tab \tab \cf4 {\b public}\cf1  \cf4 {\b bool}\cf1  \cf5 BoolValue\par ??\cf1 \tab \tab \{\par ??\tab \tab \tab \cf4 {\b get}\cf1  \{ \cf4 {\b return}\cf1  \cf5 boolValue\cf1 ; \}\par ??\tab \tab \tab \cf4 {\b set}\cf1  \{ \cf5 boolValue\cf1  = \cf4 {\b value}\cf1 ; \}\par ??\tab \tab \}\par ??\par ??\tab \tab [\cf3 DataMember\cf1 ]\par ??\tab \tab \cf4 {\b public}\cf1  \cf4 {\b string}\cf1  \cf5 StringValue\par ??\cf1 \tab \tab \{\par ??\tab \tab \tab \cf4 {\b get}\cf1  \{ \cf4 {\b return}\cf1  \cf5 stringValue\cf1 ; \}\par ??\tab \tab \tab \cf4 {\b set}\cf1  \{ \cf5 stringValue\cf1  = \cf4 {\b value}\cf1 ; \}\par ??\tab \tab \}\par ??\par ??\tab \tab [\cf3 DataMember\cf1 ]\par ??\tab \tab \cf4 {\b public}\cf1  \cf3 NestedType\cf1  \cf5 NestedObject\par ??\cf1 \tab \tab \{\par ??\tab \tab \tab \cf4 {\b get}\cf1  \{ \cf4 {\b return}\cf1  \cf5 nestedObject\cf1 ; \}\par ??\tab \tab \tab \cf4 {\b set}\cf1  \{ \cf5 nestedObject\cf1  = \cf4 {\b value}\cf1 ; \}\par ??\tab \tab \}\par ??\tab \}\par ??\par ??\tab \cf4 {\b public}\cf1  \cf4 {\b class}\cf1  \cf3 NestedType\par ??\cf1 \tab \{\par ??\tab \tab \cf4 {\b bool}\cf1  \cf5 isVisible\cf1  = \cf4 {\b false}\cf1 ;\par ??\par ??\tab \tab \cf4 {\b public}\cf1  \cf4 {\b bool}\cf1  \cf5 IsVisible\par ??\cf1 \tab \tab \{\par ??\tab \tab \tab \cf4 {\b get}\cf1  \{ \cf4 {\b return}\cf1  \cf5 isVisible\cf1 ; \}\par ??\tab \tab \tab \cf4 {\b set}\cf1  \{ \cf5 isVisible\cf1  = \cf4 {\b value}\cf1 ; \}\par ??\tab \tab \}\par ??\tab \}}
--&gt;
&lt;div style="overflow-y: scroll; font-size: 9pt; background: #3f3f3f; width: 600px; color: #dcdccc; font-family: consolas; height: 200px"&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 24&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="color: #2b91af"&gt;DataContract&lt;/span&gt;]
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 25&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="font-weight: bold; color: #e1e18a"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;CompositeType&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 26&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 27&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;bool&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;boolValue&lt;/span&gt; = &lt;span style="font-weight: bold; color: #e1e18a"&gt;true&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 28&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;stringValue&lt;/span&gt; = &lt;span style="color: #c89191"&gt;"Hello
"&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 29&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #2b91af"&gt;NestedType&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;nestedObject&lt;/span&gt; = &lt;span style="font-weight: bold; color: #e1e18a"&gt;new&lt;/span&gt; &lt;span style="color: #2b91af"&gt;NestedType&lt;/span&gt;();
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 30&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 31&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="color: #2b91af"&gt;DataMember&lt;/span&gt;]
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 32&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="font-weight: bold; color: #e1e18a"&gt;bool&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;BoolValue&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 33&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 34&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;get&lt;/span&gt; { &lt;span style="font-weight: bold; color: #e1e18a"&gt;return&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;boolValue&lt;/span&gt;;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 35&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;set&lt;/span&gt; { &lt;span style="color: #dfdfbf"&gt;boolValue&lt;/span&gt; = &lt;span style="font-weight: bold; color: #e1e18a"&gt;value&lt;/span&gt;;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 36&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 37&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 38&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="color: #2b91af"&gt;DataMember&lt;/span&gt;]
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 39&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="font-weight: bold; color: #e1e18a"&gt;string&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;StringValue&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 40&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 41&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;get&lt;/span&gt; { &lt;span style="font-weight: bold; color: #e1e18a"&gt;return&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;stringValue&lt;/span&gt;;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 42&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;set&lt;/span&gt; { &lt;span style="color: #dfdfbf"&gt;stringValue&lt;/span&gt; = &lt;span style="font-weight: bold; color: #e1e18a"&gt;value&lt;/span&gt;;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 43&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 44&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 45&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="color: #2b91af"&gt;DataMember&lt;/span&gt;]
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 46&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="color: #2b91af"&gt;NestedType&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;NestedObject&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 47&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 48&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;get&lt;/span&gt; { &lt;span style="font-weight: bold; color: #e1e18a"&gt;return&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;nestedObject&lt;/span&gt;;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 49&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;set&lt;/span&gt; { &lt;span style="color: #dfdfbf"&gt;nestedObject&lt;/span&gt; = &lt;span style="font-weight: bold; color: #e1e18a"&gt;value&lt;/span&gt;;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 50&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 51&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 52&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 53&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="font-weight: bold; color: #e1e18a"&gt;class&lt;/span&gt; &lt;span style="color: #2b91af"&gt;NestedType&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 54&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 55&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;bool&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;isVisible&lt;/span&gt; = &lt;span style="font-weight: bold; color: #e1e18a"&gt;false&lt;/span&gt;;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 56&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 57&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;public&lt;/span&gt; &lt;span style="font-weight: bold; color: #e1e18a"&gt;bool&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;IsVisible&lt;/span&gt;
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 58&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 59&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;get&lt;/span&gt; { &lt;span style="font-weight: bold; color: #e1e18a"&gt;return&lt;/span&gt; &lt;span style="color: #dfdfbf"&gt;isVisible&lt;/span&gt;;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 60&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="font-weight: bold; color: #e1e18a"&gt;set&lt;/span&gt; { &lt;span style="color: #dfdfbf"&gt;isVisible&lt;/span&gt; = &lt;span style="font-weight: bold; color: #e1e18a"&gt;value&lt;/span&gt;;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 61&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="margin: 0px"&gt;
&lt;span style="color: #85ac8d"&gt;&amp;nbsp;&amp;nbsp; 62&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;/div&gt;
&lt;p&gt;
&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
The same code in use after SP1 will not cause this error. WCF will interpret from &lt;em&gt;CompositeType&lt;/em&gt;'s
[DataContract] attribute and &lt;em&gt;NestedObject&lt;/em&gt;'s [DataMember] attribute that you
meant to put [DataContract] on &lt;em&gt;NestedType&lt;/em&gt;. So what's the big deal, right?
WCF is doing me a solid by guessing at what I meant to do. To me, this violates the
repeated opt-in theme present in WCF. For every other important decision, the developer
must write code to opt-in to a feature. For example, TransactionFlow defaults to false
so we don't use the client's incoming transaction with explicitly writing code that
says to do so. 
&lt;/p&gt;
&lt;p&gt;
This is clearly not on the same level as TransactionFlow. But why does it assume something
about my objects? Why does it assume that every member of my object should be a DataMember?
&lt;/p&gt;
&lt;p&gt;
I noticed this new "feature" when troubleshooting some code that had different namespace
names specified in the DataContract attribute. Since the &lt;em&gt;NestedType&lt;/em&gt; did not
have a [DataContract] attribute, the namespace was using the original namespace name.
The equivalent of &lt;em&gt;CompositeType &lt;/em&gt;came through correctly, but the &lt;em&gt;NestedObject &lt;/em&gt;had
no value.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=01df2e81-97da-4179-a4b0-a7c6178f5599" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,01df2e81-97da-4179-a4b0-a7c6178f5599.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=f6cca0b0-5d91-48bf-a644-338e2b781d30</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,f6cca0b0-5d91-48bf-a644-338e2b781d30.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,f6cca0b0-5d91-48bf-a644-338e2b781d30.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f6cca0b0-5d91-48bf-a644-338e2b781d30</wfw:commentRss>
      <slash:comments>7</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Enterprise applications store their data in a relational database. Our code reads
the data stored in tables with many complex joins and business rule laden queries.
We take the results of those queries and construct an equally complex business entity
that is used by our application logic. Most developers, myself excluded, hate working
with the database. Writing, modifying, or even seeing T-SQL causes some developers
to itch. LINQ to SQL serves as a partially effective Hydrocortisone to relieve the
itch. But they still need to maintain the schema, write SQL-mindful LINQ queries,
and deal with the constant DataContext updates. 
</p>
        <p>
  
</p>
        <p>
Imagine a world where you no longer need to translate your complex business entities
to and from relational tables.  A world where there is no database backing store.
A world where we create our business entities and store them in memory. Even better,
in memory on a shared resource. Does it sound like an inconceivable futuristic developer
heaven? Well it probably is, but this is really cool stuff in the works. 
</p>
        <p>
  
</p>
        <p>
Enter the Microsoft project code-named "<a href="http://msdn.microsoft.com/en-us/data/cc655792.aspx">Velocity</a>."
The blurb on the overview page reads: 
</p>
        <blockquote>
          <p>
            <font face="Arial Rounded MT Bold" color="#000080" size="2">"Velocity" is a distributed
in-memory application cache platform for developing scalable, high-performance applications.
"Velocity" can be used to cache any CLR object and provides access through simple
APIs. The primary goals for "Velocity" are performance, scalability and availability.</font>
          </p>
        </blockquote>
        <p>
I have been working with the <a href="http://digipede.net">Digipede Network</a>, the
leading grid computing software solution, for a few months. The Velocity architecture
sounds remarkably similar to Digipede's. I have seen the great benefits of the Digipede
Network and have high expectations for Velocity.
</p>
        <p>
The Digipede Network, for those of you that haven't seen it yet, consists of a central
Digipede Server and one or many Digipede Agents. The server receives client requests
and assigns tasks to the agents. The client uses the Digipede API to communicate with
the server. The API pretty much wraps client-to-server and server-to-client WSE2 web
service calls. This architecture allows you to take almost any CPU-intensive process
and spread the workload among tens or hundreds of commodity or server grade machines.
The result is a very high performing and easily scaled system with few code changes
from what you do today. 
</p>
        <p>
Digipede Network Diagram:
</p>
        <p>
          <a href="http://www.digipede.net/products/technology.html" target="_blank">
            <img height="453" alt="Digipede Network Diagram" src="http://www.digipede.net/images/how_it_works.gif" width="518" border="0" />
          </a>
        </p>
        <p>
Digipede only works in this configuration, while <a href="http://msdn.microsoft.com/en-us/library/cc645013.aspx" target="_blank">Velocity
has two proposed deployment models</a>. You can have a "caching tier", similar to
Digipede's Server and Agent configuration, or you can house Velocity as a Caching
Service directly in IIS7. I don't know how communications will be handled between
the client API and the "caching tier", but I assume it will be some sort of service
calls (WCF perhaps). All CLR objects stored in the Velocity cache must be marked [Serializable]
just as task worker classes must be to work with Digipede.
</p>
        <p>
The Velocity API looks simple enough too. It exposes intuitive Get() and Put() methods
where you call the cache by name. I can see how versioning of the cached objects might
get tricky. Your application will also need a new configSection that specifies the
deployment mode, locality, and also contains the list of cache hosts. As this is a
distributed solution, the standard virtual machine playground doesn't work too well
to really test this out.
</p>
        <p>
This looks promising, and I'll be following the progress of the project closely.
</p>
        <p>
          <a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=B24C3708-EEFF-4055-A867-19B5851E7CD2" target="_blank">Download
Velocity</a>
        </p>
        <p>
          <a href="http://code.msdn.microsoft.com/velocity" target="_blank">Download the Velocity
CPT 1 samples</a>
        </p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=f6cca0b0-5d91-48bf-a644-338e2b781d30" />
      </body>
      <title>Performance = Data Mass x Velocity ^2</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,f6cca0b0-5d91-48bf-a644-338e2b781d30.aspx</guid>
      <link>http://offroadcoder.com/2008/06/29/PerformanceDataMassXVelocity2.aspx</link>
      <pubDate>Sun, 29 Jun 2008 04:11:00 GMT</pubDate>
      <description>&lt;p&gt;
Enterprise applications store their data in a relational database. Our code reads
the data stored in tables with many complex joins and business rule laden queries.
We take the results of those queries and construct an equally complex business entity
that is used by our application logic. Most developers, myself excluded, hate working
with the database. Writing, modifying, or even seeing T-SQL causes some developers
to itch. LINQ to SQL serves as a partially effective Hydrocortisone to relieve the
itch. But they still need to maintain the schema, write SQL-mindful LINQ queries,
and deal with the constant DataContext updates. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Imagine a world where you no longer need to translate your complex business entities
to and from relational tables.&amp;nbsp; A world where there is no database backing store.
A world where we create our business entities and store them in memory. Even better,
in memory on a shared resource. Does it sound like an inconceivable futuristic developer
heaven? Well it probably is, but this is really cool stuff in the works. 
&lt;p&gt;
&amp;nbsp; 
&lt;p&gt;
Enter the Microsoft project code-named "&lt;a href="http://msdn.microsoft.com/en-us/data/cc655792.aspx"&gt;Velocity&lt;/a&gt;."
The blurb on the overview page reads: &lt;blockquote&gt; 
&lt;p&gt;
&lt;font face="Arial Rounded MT Bold" color=#000080 size=2&gt;"Velocity" is a distributed
in-memory application cache platform for developing scalable, high-performance applications.
"Velocity" can be used to cache any CLR object and provides access through simple
APIs. The primary goals for "Velocity" are performance, scalability and availability.&lt;/font&gt;
&lt;/p&gt;
&lt;/blockquote&gt; 
&lt;p&gt;
I have been working with the &lt;a href="http://digipede.net"&gt;Digipede Network&lt;/a&gt;, the
leading grid computing software solution, for a few months. The Velocity architecture
sounds remarkably similar to Digipede's. I have seen the great benefits of the Digipede
Network and have high expectations for Velocity.
&lt;/p&gt;
&lt;p&gt;
The Digipede Network, for those of you that haven't seen it yet, consists of a central
Digipede Server and one or many Digipede Agents. The server receives client requests
and assigns tasks to the agents. The client uses the Digipede API to communicate with
the server. The API pretty much wraps client-to-server and server-to-client WSE2 web
service calls. This architecture allows you to take almost any CPU-intensive process
and spread the workload among tens or hundreds of commodity or server grade machines.
The result is a very high performing and easily scaled system with few code changes
from what you do today. 
&lt;/p&gt;
&lt;p&gt;
Digipede Network Diagram:
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.digipede.net/products/technology.html" target=_blank&gt;&lt;img height=453 alt="Digipede Network Diagram" src="http://www.digipede.net/images/how_it_works.gif" width=518 border=0&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
Digipede only works in this configuration, while &lt;a href="http://msdn.microsoft.com/en-us/library/cc645013.aspx" target=_blank&gt;Velocity
has two proposed deployment models&lt;/a&gt;. You can have a "caching tier", similar to
Digipede's Server and Agent configuration, or you can house Velocity as a Caching
Service directly in IIS7. I don't know how communications will be handled between
the client API and the "caching tier", but I assume it will be some sort of service
calls (WCF perhaps). All CLR objects stored in the Velocity cache must be marked [Serializable]
just as task worker classes must be to work with Digipede.
&lt;/p&gt;
&lt;p&gt;
The Velocity API looks simple enough too. It exposes intuitive Get() and Put() methods
where you call the cache by name. I can see how versioning of the cached objects might
get tricky. Your application will also need a new configSection that specifies the
deployment mode, locality, and also contains the list of cache hosts. As this is a
distributed solution, the standard virtual machine playground doesn't work too well
to really test this out.
&lt;/p&gt;
&lt;p&gt;
This looks promising, and I'll be following the progress of the project closely.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://www.microsoft.com/downloads/details.aspx?FamilyId=B24C3708-EEFF-4055-A867-19B5851E7CD2" target=_blank&gt;Download
Velocity&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://code.msdn.microsoft.com/velocity" target=_blank&gt;Download the Velocity
CPT 1 samples&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=f6cca0b0-5d91-48bf-a644-338e2b781d30" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,f6cca0b0-5d91-48bf-a644-338e2b781d30.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=0c636536-67bd-4395-849c-5554c1ee20f2</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,0c636536-67bd-4395-849c-5554c1ee20f2.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,0c636536-67bd-4395-849c-5554c1ee20f2.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0c636536-67bd-4395-849c-5554c1ee20f2</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Juval Löwy mentioned the <a href="http://msdn.microsoft.com/en-us/library/ms732023.aspx">Microsoft
Service Trace Viewer</a> in a <a href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032379028&amp;EventCategory=5&amp;culture=en-US&amp;CountryCode=US">webcast</a> today.
If you ever wondered exactly what WCF does under all of those covers, check this out.
</p>
        <p>
First things first. Enable tracing on the client and host applications using the WCF
Configuration Editor. Enable the verbose trace level and check all of the listener
settings. This will add all of the necessary &lt;system.diagnostics&gt; settings in
your config file. The next time you start each of the applications, a .svclog file
will be created that will be used by the Service Trace Viewer.
</p>
        <p>
          <img src="http://gotjeep.net/Blogs/content/binary/EditWCFConfigTracing.png" border="0" />
        </p>
        <p>
Start your host, start your client, run through the test cases that you want to analyze
in the viewer. After your test run is complete, open the viewer, located at C:\Program
Files\Microsoft SDKs\Windows\v6.0A\bin\SvcTraceViewer.exe. "Open" the host.svclog
file, and then "Add" the client.svclog file. Both "Open" and "Add" are menu items
under "File".
</p>
        <p>
Start on the Activity tab, look through the host and client activities that occurred.
Everything from ServiceHost construction through ServiceHost closing shows up. This
is very cool, especially when analyzing the differences between different security,
session, and reliability settings.
</p>
        <p>
          <img src="http://gotjeep.net/Blogs/content/binary/SVTActivityTab.png" border="0" />
        </p>
        <p>
When you are done looking through the activities, check out the Graph tab. Here you
can look at the interactions between the client and host, as well as looking at the
details of each activity (at the top right). At the bottom right, you will also notice
the formatted and xml details of this activity.
</p>
        <p>
          <img src="http://gotjeep.net/Blogs/content/binary/STV.png" border="0" />
        </p>
        <p>
This is a very cool tool for both debugging and training. Below is my lame test projects,
if you want to skip past the configuration and check out the tool. My .svclog files
are located in the Client and Host folders.
</p>
        <p>
          <a href="http://gotjeep.net/Blogs/content/binary/SvtTest.zip">SvtTest.zip (190.32
KB)</a>
        </p>
        <p>
Enjoy! Thanks to Juval for the direction.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=0c636536-67bd-4395-849c-5554c1ee20f2" />
      </body>
      <title>Service Trace Viewer</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,0c636536-67bd-4395-849c-5554c1ee20f2.aspx</guid>
      <link>http://offroadcoder.com/2008/06/19/ServiceTraceViewer.aspx</link>
      <pubDate>Thu, 19 Jun 2008 02:23:30 GMT</pubDate>
      <description>
		&lt;p&gt;
Juval Löwy mentioned the &lt;a href="http://msdn.microsoft.com/en-us/library/ms732023.aspx"&gt;Microsoft
Service Trace Viewer&lt;/a&gt; in a &lt;a href="http://msevents.microsoft.com/CUI/WebCastEventDetails.aspx?EventID=1032379028&amp;amp;EventCategory=5&amp;amp;culture=en-US&amp;amp;CountryCode=US"&gt;webcast&lt;/a&gt; today.
If you ever wondered exactly what WCF does under all of those covers, check this out.
&lt;/p&gt;
&lt;p&gt;
First things first. Enable tracing on the client and host applications using the WCF
Configuration Editor. Enable the verbose trace level and check all of the listener
settings. This will add all of the necessary &amp;lt;system.diagnostics&amp;gt; settings in
your config file. The next time you start each of the applications, a .svclog file
will be created that will be used by the Service Trace Viewer.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://gotjeep.net/Blogs/content/binary/EditWCFConfigTracing.png" border="0" /&gt; 
&lt;/p&gt;
&lt;p&gt;
Start your host, start your client, run through the test cases that you want to analyze
in the viewer. After your test run is complete, open the viewer, located at C:\Program
Files\Microsoft SDKs\Windows\v6.0A\bin\SvcTraceViewer.exe. "Open" the host.svclog
file, and then "Add" the client.svclog file. Both "Open" and "Add" are menu items
under "File".
&lt;/p&gt;
&lt;p&gt;
Start on the Activity tab, look through the host and client activities that occurred.
Everything from ServiceHost construction through ServiceHost closing shows up. This
is very cool, especially when analyzing the differences between different security,
session, and reliability settings.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://gotjeep.net/Blogs/content/binary/SVTActivityTab.png" border="0" /&gt; 
&lt;/p&gt;
&lt;p&gt;
When you are done looking through the activities, check out the Graph tab. Here you
can look at the interactions between the client and host, as well as looking at the
details of each activity (at the top right). At the bottom right, you will also notice
the formatted and xml details of this activity.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://gotjeep.net/Blogs/content/binary/STV.png" border="0" /&gt; 
&lt;/p&gt;
&lt;p&gt;
This is a very cool tool for both debugging and training. Below is my lame test projects,
if you want to skip past the configuration and check out the tool. My .svclog files
are located in the Client and Host folders.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://gotjeep.net/Blogs/content/binary/SvtTest.zip"&gt;SvtTest.zip (190.32
KB)&lt;/a&gt; 
&lt;/p&gt;
&lt;p&gt;
Enjoy! Thanks to Juval for the direction.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=0c636536-67bd-4395-849c-5554c1ee20f2" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,0c636536-67bd-4395-849c-5554c1ee20f2.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>Dev Tools</category>
      <category>Visual Studio</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=60081b96-9f12-47f4-a102-ef220b2abc79</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,60081b96-9f12-47f4-a102-ef220b2abc79.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,60081b96-9f12-47f4-a102-ef220b2abc79.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=60081b96-9f12-47f4-a102-ef220b2abc79</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I was looking for guidance on this topic, and came up with nothing. I'm sure people
are doing this, but can't find any info. For anyone looking like I was, here's how
to do it.
</p>
        <p>
It's much simpler than I imagined, thanks to WCF. You can programmatically create
your endpoint, binding, and channel inside your service. This would require that the
address be hard-coded and require a recompile to change the address or binding. As
long as your host's app.config or web.config has a client endpoint specifying the
contract, you don't have to go through all that work. Your service is simply a client
of another service, so your code looks just like that of a client of your service.
Furthermore, changing the address or binding is as simple as changing config file
values.
</p>
        <p>
Service code:<br /><br /></p>
        <div style="BORDER-RIGHT: #896894 1px solid; BORDER-TOP: #896894 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #896894 1px solid; WIDTH: 750px; BORDER-BOTTOM: #896894 1px solid; HEIGHT: 300px">
          <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    1</span> <span style="COLOR: blue">using</span> System;
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    2</span> <span style="COLOR: blue">using</span> System.ServiceModel;
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    3</span> <span style="COLOR: blue">using</span> DataContracts;
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    4</span> <span style="COLOR: blue">namespace</span> ServiceImplementation
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    5</span> {
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    6</span>    
[<span style="COLOR: #2b91af">ServiceContract</span>]
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    7</span>     <span style="COLOR: blue">public</span><span style="COLOR: blue">interface</span><span style="COLOR: #2b91af">IEmailService</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    8</span>    
{
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">    9</span>    
    [<span style="COLOR: #2b91af">OperationContract</span>]
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   10</span>         <span style="COLOR: blue">void</span> Send(DataContracts.<span style="COLOR: #2b91af">MailMessage</span> msg);
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   11</span>     }
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   12</span> 
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   13</span>     <span style="COLOR: blue">public</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">EmailService</span> : <span style="COLOR: #2b91af">IEmailService</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   14</span>     {
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   15</span>        
[<span style="COLOR: #2b91af">OperationBehavior</span>]
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   16</span>         <span style="COLOR: blue">public</span><span style="COLOR: blue">void</span> Send(DataContracts.<span style="COLOR: #2b91af">MailMessage</span> msg)
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   17</span>        
{
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   18</span>        
    <span style="COLOR: green">// Open client proxy for legacy web
service</span></p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   19</span>        
    <span style="COLOR: blue">using</span> (<span style="COLOR: #2b91af">LegacyEmailServiceClient</span> proxy
=
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   20</span>        
        <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">LegacyEmailServiceClient</span>())
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   21</span>        
    {
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   22</span>        
        proxy.SendEmail(msg.To, 
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   23</span>        
            msg.CC, 
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   24</span>        
            msg.Bcc, 
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   25</span>        
            msg.Body, 
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   26</span>        
            msg.Attachments);
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   27</span>        
    }
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   28</span>        
}
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   29</span>     }
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   30</span> }
</p>
            <p style="MARGIN: 0px">
              <span style="COLOR: #2b91af">   31</span> 
</p>
          </div>
          <!--EndFragment-->
        </div>
        <br />
        <br />
Host's app.config:<br /><br /><div style="BORDER-RIGHT: #896894 1px solid; BORDER-TOP: #896894 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #896894 1px solid; WIDTH: 750px; BORDER-BOTTOM: #896894 1px solid; HEIGHT: 300px"><div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    1</span> <span style="COLOR: blue">&lt;?</span><span style="COLOR: #a31515">xml</span><span style="COLOR: blue"></span><span style="COLOR: red">version</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">1.0</span>"<span style="COLOR: blue"></span><span style="COLOR: red">encoding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">utf-8</span>"<span style="COLOR: blue">?&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    2</span> <span style="COLOR: blue">&lt;</span><span style="COLOR: #a31515">configuration</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    3</span> <span style="COLOR: blue"> 
&lt;</span><span style="COLOR: #a31515">system.serviceModel</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    4</span> <span style="COLOR: blue"> 
  &lt;</span><span style="COLOR: #a31515">bindings</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    5</span> <span style="COLOR: blue"> 
    &lt;</span><span style="COLOR: #a31515">basicHttpBinding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    6</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">binding</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">BasicHttpBinding_Common</span>"<span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    7</span> <span style="COLOR: blue"> 
        &lt;</span><span style="COLOR: #a31515">security</span><span style="COLOR: blue"></span><span style="COLOR: red">mode</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">None</span>"<span style="COLOR: blue">/&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    8</span> <span style="COLOR: blue"> 
      &lt;/</span><span style="COLOR: #a31515">binding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    9</span> <span style="COLOR: blue"> 
    &lt;/</span><span style="COLOR: #a31515">basicHttpBinding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   10</span> <span style="COLOR: blue"> 
    &lt;</span><span style="COLOR: #a31515">netTcpBinding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   11</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">binding</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">NetTcpBinding_Common</span>"<span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   12</span> <span style="COLOR: blue"> 
        &lt;</span><span style="COLOR: #a31515">security</span><span style="COLOR: blue"></span><span style="COLOR: red">mode</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">None</span>"<span style="COLOR: blue">/&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   13</span> <span style="COLOR: blue"> 
      &lt;/</span><span style="COLOR: #a31515">binding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   14</span> <span style="COLOR: blue"> 
    &lt;/</span><span style="COLOR: #a31515">netTcpBinding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   15</span> <span style="COLOR: blue"> 
  &lt;/</span><span style="COLOR: #a31515">bindings</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   16</span> <span style="COLOR: blue"> 
  &lt;</span><span style="COLOR: #a31515">client</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   17</span> <span style="COLOR: blue"> 
    &lt;</span><span style="COLOR: #a31515">endpoint</span><span style="COLOR: blue"></span><span style="COLOR: red">address</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">http://www.gotjeep.net/legacy/email.asmx</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   18</span> <span style="COLOR: blue"> 
        </span><span style="COLOR: red">binding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">basicHttpBinding</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   19</span> <span style="COLOR: blue"> 
              </span><span style="COLOR: red">bindingConfiguration</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">BasicHttpBinding_Common</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   20</span> <span style="COLOR: blue"> 
        </span><span style="COLOR: red">contract</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">LegacyEmailServiceClient</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   21</span> <span style="COLOR: blue"> 
              </span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">LegacyEmailServiceClient</span>"<span style="COLOR: blue"> /&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   22</span> <span style="COLOR: blue"> 
  &lt;/</span><span style="COLOR: #a31515">client</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   23</span> <span style="COLOR: blue"> 
  &lt;</span><span style="COLOR: #a31515">services</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   24</span> <span style="COLOR: blue"> 
    &lt;</span><span style="COLOR: #a31515">service</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">ServiceImplementation.EmailService</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   25</span> <span style="COLOR: blue"> 
            </span><span style="COLOR: red">behaviorConfiguration</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">returnFaults</span>"<span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   26</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">host</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   27</span> <span style="COLOR: blue"> 
        &lt;</span><span style="COLOR: #a31515">baseAddresses</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   28</span> <span style="COLOR: blue"> 
          &lt;</span><span style="COLOR: #a31515">add</span><span style="COLOR: blue"></span><span style="COLOR: red">baseAddress</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">http://localhost:8080/EmailService</span>"<span style="COLOR: blue"> /&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   29</span> <span style="COLOR: blue"> 
          &lt;</span><span style="COLOR: #a31515">add</span><span style="COLOR: blue"></span><span style="COLOR: red">baseAddress</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">net.tcp://localhost:8088/EmailService</span>"<span style="COLOR: blue"> /&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   30</span> <span style="COLOR: blue"> 
        &lt;/</span><span style="COLOR: #a31515">baseAddresses</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   31</span> <span style="COLOR: blue"> 
      &lt;/</span><span style="COLOR: #a31515">host</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   32</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">endpoint</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">NetTcpBinding_EmailService</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   33</span> <span style="COLOR: blue"> 
                </span><span style="COLOR: red">binding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">netTcpBinding</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   34</span> <span style="COLOR: blue"> 
                </span><span style="COLOR: red">bindingConfiguration</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">NetTcpBinding_Common</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   35</span> <span style="COLOR: blue"> 
                </span><span style="COLOR: red">contract</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">ServiceImplementation.IEmailService</span>"<span style="COLOR: blue">/&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   36</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">endpoint</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">BasicHttpBinding_EmailService</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   37</span> <span style="COLOR: blue"> 
                </span><span style="COLOR: red">binding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">basicHttpBinding</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   38</span> <span style="COLOR: blue"> 
                </span><span style="COLOR: red">bindingConfiguration</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">BasicHttpBinding_Common</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   39</span> <span style="COLOR: blue"> 
                </span><span style="COLOR: red">contract</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">ServiceImplementation.IEmailService</span>"<span style="COLOR: blue">/&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   40</span> <span style="COLOR: blue"> 
    &lt;/</span><span style="COLOR: #a31515">service</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   41</span> <span style="COLOR: blue"> 
  &lt;/</span><span style="COLOR: #a31515">services</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   42</span> <span style="COLOR: blue"> 
  &lt;</span><span style="COLOR: #a31515">behaviors</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   43</span> <span style="COLOR: blue"> 
    &lt;</span><span style="COLOR: #a31515">serviceBehaviors</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   44</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">behavior</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">returnFaults</span>"<span style="COLOR: blue"> &gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   45</span> <span style="COLOR: blue"> 
        &lt;</span><span style="COLOR: #a31515">serviceMetadata</span><span style="COLOR: blue"></span><span style="COLOR: red">httpGetEnabled</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">true</span>"<span style="COLOR: blue"> /&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   46</span> <span style="COLOR: blue"> 
      &lt;/</span><span style="COLOR: #a31515">behavior</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   47</span> <span style="COLOR: blue"> 
    &lt;/</span><span style="COLOR: #a31515">serviceBehaviors</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   48</span> <span style="COLOR: blue"> 
  &lt;/</span><span style="COLOR: #a31515">behaviors</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   49</span> <span style="COLOR: blue"> 
&lt;/</span><span style="COLOR: #a31515">system.serviceModel</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   50</span> <span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">configuration</span><span style="COLOR: blue">&gt;</span></p></div><!--EndFragment--></div><p></p><img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=60081b96-9f12-47f4-a102-ef220b2abc79" /></body>
      <title>Calling services from services</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,60081b96-9f12-47f4-a102-ef220b2abc79.aspx</guid>
      <link>http://offroadcoder.com/2008/03/27/CallingServicesFromServices.aspx</link>
      <pubDate>Thu, 27 Mar 2008 02:08:46 GMT</pubDate>
      <description>&lt;p&gt;
I was looking for guidance on this topic, and came up with nothing. I'm sure people
are doing this, but can't find any info. For anyone looking like I was, here's how
to do it.
&lt;/p&gt;
&lt;p&gt;
It's much simpler than I imagined, thanks to WCF. You can programmatically create
your endpoint, binding, and channel inside your service. This would require that the
address be hard-coded and require a recompile to change the address or binding. As
long as your host's app.config or web.config has a client endpoint specifying the
contract, you don't have to go through all that work. Your service is simply a client
of another service, so your code looks just like that of a client of your service.
Furthermore, changing the address or binding is as simple as changing config file
values.
&lt;/p&gt;
&lt;p&gt;
Service code:&lt;br&gt;
&lt;br&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: #896894 1px solid; BORDER-TOP: #896894 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #896894 1px solid; WIDTH: 750px; BORDER-BOTTOM: #896894 1px solid; HEIGHT: 300px"&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System.ServiceModel;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; DataContracts;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; ServiceImplementation
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="COLOR: #2b91af"&gt;ServiceContract&lt;/span&gt;]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;interface&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IEmailService&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Send(DataContracts.&lt;span style="COLOR: #2b91af"&gt;MailMessage&lt;/span&gt; msg);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;EmailService&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;IEmailService&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="COLOR: #2b91af"&gt;OperationBehavior&lt;/span&gt;]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Send(DataContracts.&lt;span style="COLOR: #2b91af"&gt;MailMessage&lt;/span&gt; msg)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: green"&gt;// Open client proxy for legacy web
service&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;LegacyEmailServiceClient&lt;/span&gt; proxy
=
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;LegacyEmailServiceClient&lt;/span&gt;())
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;21&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;22&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; proxy.SendEmail(msg.To, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;23&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; msg.CC, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;24&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; msg.Bcc, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;25&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; msg.Body, 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;26&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; msg.Attachments);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;27&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;28&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;29&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;30&lt;/span&gt;&amp;nbsp;}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;31&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;
&lt;/div&gt;
&lt;br&gt;
&lt;br&gt;
Host's app.config:&lt;br&gt;
&lt;br&gt;
&lt;div style="BORDER-RIGHT: #896894 1px solid; BORDER-TOP: #896894 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #896894 1px solid; WIDTH: 750px; BORDER-BOTTOM: #896894 1px solid; HEIGHT: 300px"&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;xml&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;version&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;1.0&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;encoding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;utf-8&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;?&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;system.serviceModel&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;bindings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;basicHttpBinding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;BasicHttpBinding_Common&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;security&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;mode&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;None&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;basicHttpBinding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;netTcpBinding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;NetTcpBinding_Common&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;security&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;mode&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;None&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;netTcpBinding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;bindings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;client&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;address&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;http://www.gotjeep.net/legacy/email.asmx&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;basicHttpBinding&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;BasicHttpBinding_Common&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;contract&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;LegacyEmailServiceClient&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;21&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;LegacyEmailServiceClient&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;22&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;client&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;23&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;services&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;24&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;service&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;ServiceImplementation.EmailService&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;25&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;behaviorConfiguration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;returnFaults&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;26&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;host&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;27&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;baseAddresses&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;28&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;baseAddress&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;http://localhost:8080/EmailService&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;29&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;add&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;baseAddress&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;net.tcp://localhost:8088/EmailService&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;30&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;baseAddresses&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;31&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;host&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;32&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;NetTcpBinding_EmailService&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;33&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;netTcpBinding&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;34&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;NetTcpBinding_Common&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;35&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;contract&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;ServiceImplementation.IEmailService&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;36&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;BasicHttpBinding_EmailService&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;37&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;basicHttpBinding&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;38&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;BasicHttpBinding_Common&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;39&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;contract&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;ServiceImplementation.IEmailService&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;40&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;service&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;41&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;services&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;42&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;behaviors&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;43&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;44&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;behavior&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;returnFaults&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;45&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serviceMetadata&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;httpGetEnabled&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;true&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;46&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;behavior&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;47&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;serviceBehaviors&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;48&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;behaviors&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;49&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;system.serviceModel&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;50&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=60081b96-9f12-47f4-a102-ef220b2abc79" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,60081b96-9f12-47f4-a102-ef220b2abc79.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=dd494296-3fec-4770-b381-75f0a4e3fae5</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,dd494296-3fec-4770-b381-75f0a4e3fae5.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,dd494296-3fec-4770-b381-75f0a4e3fae5.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=dd494296-3fec-4770-b381-75f0a4e3fae5</wfw:commentRss>
      <slash:comments>9</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
If you haven't heard me praise Juval Löwy's book <a href="http://www.amazon.com/Programming-WCF-Services-Juval-Lowy/dp/0596526997/sr=1-2/qid=1160362131/ref=sr_1_2/104-3785412-4763969?ie=UTF8&amp;s=books">Programming
WCF Services</a> or Michele Leroux Bustamante's book <a href="http://www.amazon.com/Learning-WCF-Hands-Michele-Bustamante/dp/0596101627/ref=pd_bbs_sr_1?ie=UTF8&amp;s=books&amp;qid=1206496842&amp;sr=8-1">Learning
WCF: A Hands-on Guide</a> yet... these books are the best WCF books available. Every
question I have had has been answered by these two books. In fact, most of the forum
and newsgroup resolutions out there come from one or both of these books. If you haven't
already, check out their <a href="http://idesign.net/idesign/DesktopDefault.aspx?tabindex=5&amp;tabid=11">IDesign
Code Library</a> and and the <a href="http://idesign.net/idesign/download/IDesign%20WCF%20Coding%20Standard.zip">IDesign
WCF Coding Standard</a> at <a href="http://www.idesign.net/">www.IDesign.net</a>.
</p>
        <p>
OK, problem and resolution of the day... how do I generate a proxy file with the same
collection class as my service implementation. My service uses List&lt;T&gt;. WCF
converts this to be a more interoperable array of T. When you generate the proxy,
it is generated with T[]. To be able to enjoy the same collection features as
the service, you only need a few more parameters on svcutil.
</p>
        <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
          <span style="COLOR: #2b91af">
            <div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New">
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">    7</span>    
[<span style="COLOR: #2b91af">ServiceContract</span>]
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">    8</span>     <span style="COLOR: blue">public</span><span style="COLOR: blue">interface</span><span style="COLOR: #2b91af">IEmailService</span></p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">    9</span>    
{
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   10</span>        
[<span style="COLOR: #2b91af">OperationContract</span>]
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   11</span>         <span style="COLOR: blue">string</span> MyOperation1(<span style="COLOR: blue">string</span> myValue);
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   12</span> 
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   13</span>        
[<span style="COLOR: #2b91af">OperationContract</span>]
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   14</span>         <span style="COLOR: #2b91af">List</span>&lt;<span style="COLOR: #2b91af">String</span>&gt;
MyOperation2(<span style="COLOR: blue">string</span> myValue);
</p>
              <p style="MARGIN: 0px">
                <span style="COLOR: #2b91af">   15</span>     }<font face="Verdana"></font></p>
            </div>
          </span>
        </div>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <font size="2">
            <p>
              <font size="2">
                <font size="2">
                </font>
              </font>
            </p>
          </font>
          <font size="2">
          </font>
        </blockquote>
        <p dir="ltr">
          <em>Example 1: Generate proxy with T[]</em>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Courier New" color="#000080">svcutil http://localhost:8080/EmailService
/out:EmailServiceProxy.cs /noconfig</font>
          </p>
          <font size="2">
            <font size="2">
              <p>
[System.ServiceModel.
</p>
            </font>
            <font color="#2b91af" size="2">OperationContractAttribute</font>
            <font size="2">(Action=</font>
            <font color="#a31515" size="2">"http://tempuri.org/IEmailService/MyOperation2"</font>
            <font size="2">,
ReplyAction=</font>
            <font color="#a31515" size="2">"http://tempuri.org/IEmailService/MyOperation2Response"</font>
            <font size="2">)]<br /><font color="#0000ff" size="2">string</font><font size="2">[] MyOperation2(</font><font color="#0000ff" size="2">string</font><font size="2"> myValue);</font></font>
          </font>
        </blockquote>
        <p>
          <em>Example 2: Generate proxy with List&lt;T&gt;</em>
        </p>
        <blockquote dir="ltr" style="MARGIN-RIGHT: 0px">
          <p>
            <font face="Courier New" color="#000080">svcutil http://localhost:8080/EmailService
/out:EmailServiceProxy.cs /noconfig /ct:System.Collections.Generic.List`1</font>
          </p>
          <p dir="ltr">
[System.ServiceModel.<font color="#2b91af" size="2">OperationContractAttribute</font><font size="2">(Action=</font><font color="#a31515" size="2">"http://tempuri.org/IEmailService/MyOperation2"</font><font size="2">,
ReplyAction=</font><font color="#a31515" size="2">"http://tempuri.org/IEmailService/MyOperation2Response"</font><font size="2">)]<br />
System.Collections.Generic.</font><font color="#2b91af" size="2">List</font><font size="2">&lt;</font><font color="#0000ff" size="2">string</font><font size="2">&gt;
MyOperation2(</font><font color="#0000ff" size="2">string</font><font size="2"> myValue);</font><font size="2"></font></p>
        </blockquote>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=dd494296-3fec-4770-b381-75f0a4e3fae5" />
      </body>
      <title>Choosing your client proxy collection class</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,dd494296-3fec-4770-b381-75f0a4e3fae5.aspx</guid>
      <link>http://offroadcoder.com/2008/03/26/ChoosingYourClientProxyCollectionClass.aspx</link>
      <pubDate>Wed, 26 Mar 2008 02:22:22 GMT</pubDate>
      <description>&lt;p&gt;
If you haven't heard me praise Juval Löwy's book &lt;a href="http://www.amazon.com/Programming-WCF-Services-Juval-Lowy/dp/0596526997/sr=1-2/qid=1160362131/ref=sr_1_2/104-3785412-4763969?ie=UTF8&amp;amp;s=books"&gt;Programming
WCF Services&lt;/a&gt; or Michele Leroux Bustamante's book &lt;a href="http://www.amazon.com/Learning-WCF-Hands-Michele-Bustamante/dp/0596101627/ref=pd_bbs_sr_1?ie=UTF8&amp;amp;s=books&amp;amp;qid=1206496842&amp;amp;sr=8-1"&gt;Learning
WCF: A Hands-on Guide&lt;/a&gt; yet... these books are the best WCF books available. Every
question I have had has been answered by these two books. In fact, most of the forum
and newsgroup resolutions out there come from one or both of these books. If you haven't
already, check out their &lt;a href="http://idesign.net/idesign/DesktopDefault.aspx?tabindex=5&amp;amp;tabid=11"&gt;IDesign
Code Library&lt;/a&gt; and and the &lt;a href="http://idesign.net/idesign/download/IDesign%20WCF%20Coding%20Standard.zip"&gt;IDesign
WCF Coding Standard&lt;/a&gt; at &lt;a href="http://www.idesign.net/"&gt;www.IDesign.net&lt;/a&gt;.
&lt;/p&gt;
&lt;p&gt;
OK, problem and resolution of the day... how do I generate a proxy file with the same
collection class as my service implementation. My service uses List&amp;lt;T&amp;gt;. WCF
converts this to be a more interoperable array of T. When you generate the proxy,
it is generated with T[].&amp;nbsp;To be able to enjoy the same collection features as
the service, you only need a few more parameters on svcutil.
&lt;/p&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;&lt;span style="COLOR: #2b91af"&gt; 
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="COLOR: #2b91af"&gt;ServiceContract&lt;/span&gt;]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;interface&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;IEmailService&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; MyOperation1(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; myValue);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
[&lt;span style="COLOR: #2b91af"&gt;OperationContract&lt;/span&gt;]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;List&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;String&lt;/span&gt;&amp;gt;
MyOperation2(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; myValue);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;font face=Verdana&gt; &lt;/font&gt;
&lt;/span&gt;&gt;
&lt;/div&gt;
&gt;&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;font size=2&gt; 
&lt;p&gt;
&lt;font size=2&gt;&lt;font size=2&gt;
&lt;/p&gt;
&lt;/font&gt;&gt;&lt;font size=2&gt;&lt;/font&gt;&lt;/blockquote&gt; 
&lt;p dir=ltr&gt;
&lt;em&gt;Example 1: Generate proxy with T[]&lt;/em&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;font face="Courier New" color=#000080&gt;svcutil http://localhost:8080/EmailService
/out:EmailServiceProxy.cs /noconfig&lt;/font&gt;
&lt;/p&gt;
&lt;font size=2&gt;&lt;font size=2&gt; 
&lt;p&gt;
[System.ServiceModel.
&lt;/font&gt;&lt;font color=#2b91af size=2&gt;OperationContractAttribute&lt;/font&gt;&lt;font size=2&gt;(Action=&lt;/font&gt;&lt;font color=#a31515 size=2&gt;"http://tempuri.org/IEmailService/MyOperation2"&lt;/font&gt;&lt;font size=2&gt;,
ReplyAction=&lt;/font&gt;&lt;font color=#a31515 size=2&gt;"http://tempuri.org/IEmailService/MyOperation2Response"&lt;/font&gt;&lt;font size=2&gt;)]&lt;br&gt;
&lt;font color=#0000ff size=2&gt;string&lt;/font&gt;&lt;font size=2&gt;[] MyOperation2(&lt;/font&gt;&lt;font color=#0000ff size=2&gt;string&lt;/font&gt;&lt;font size=2&gt; myValue);&lt;/font&gt;&lt;/font&gt;&gt;
&lt;/font&gt;&lt;/blockquote&gt; 
&lt;p&gt;
&lt;em&gt;Example 2: Generate proxy with List&amp;lt;T&amp;gt;&lt;/em&gt;
&lt;/p&gt;
&lt;blockquote dir=ltr style="MARGIN-RIGHT: 0px"&gt; 
&lt;p&gt;
&lt;font face="Courier New" color=#000080&gt;svcutil http://localhost:8080/EmailService
/out:EmailServiceProxy.cs /noconfig /ct:System.Collections.Generic.List`1&lt;/font&gt;
&lt;/p&gt;
&lt;p dir=ltr&gt;
[System.ServiceModel.&lt;font color=#2b91af size=2&gt;OperationContractAttribute&lt;/font&gt;&lt;font size=2&gt;(Action=&lt;/font&gt;&lt;font color=#a31515 size=2&gt;"http://tempuri.org/IEmailService/MyOperation2"&lt;/font&gt;&lt;font size=2&gt;,
ReplyAction=&lt;/font&gt;&lt;font color=#a31515 size=2&gt;"http://tempuri.org/IEmailService/MyOperation2Response"&lt;/font&gt;&lt;font size=2&gt;)]&lt;br&gt;
System.Collections.Generic.&lt;/font&gt;&lt;font color=#2b91af size=2&gt;List&lt;/font&gt;&lt;font size=2&gt;&amp;lt;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;string&lt;/font&gt;&lt;font size=2&gt;&amp;gt;
MyOperation2(&lt;/font&gt;&lt;font color=#0000ff size=2&gt;string&lt;/font&gt;&lt;font size=2&gt; myValue);&lt;/font&gt;&lt;font size=2&gt;
&lt;/p&gt;
&lt;/blockquote&gt;&gt;&gt;&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=dd494296-3fec-4770-b381-75f0a4e3fae5" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,dd494296-3fec-4770-b381-75f0a4e3fae5.aspx</comments>
      <category>.NET Framework</category>
      <category>WCF</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=91bc9016-1219-473d-83fb-04cf34706fd6</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,91bc9016-1219-473d-83fb-04cf34706fd6.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,91bc9016-1219-473d-83fb-04cf34706fd6.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=91bc9016-1219-473d-83fb-04cf34706fd6</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
WCF is seamless, powerful, and (YES) interoperable. Here is a quick walkthrough
detailing steps to call your legacy PHP web services from a WCF client. All of the
binding types and security options are, of course, not available. But for those of
you following the old "security through obscurity" model, this will work fine.
</p>
The procedure is just as simple as a WCF-WCF call: 
<ol><li>
Create client proxy 
</li><li>
Add client endpoint to your client config file 
</li><li>
Write your proxy-consuming client code</li></ol><p><strong>Create the client proxy:</strong></p><p>
Nusoap provides a similar UI when navigating to your PHP web service to that provided
by ASMX services. You can view the WSDL, and copy the URL for svcutil.exe.
</p><p><a href="http://gotjeep.net/Blogs/content/binary/phpservice2.png" target="_blank" alt="PHP Service : Click for full-size image"><img src="http://gotjeep.net/Blogs/content/binary/phpservice2.png" width="200" border="0" /></a><a href="http://gotjeep.net/Blogs/content/binary/phpservice3.png" target="_blank" alt="WSDL : Click for full-size image"><img src="http://gotjeep.net/Blogs/content/binary/phpservice3.png" width="200" border="0" /></a></p><p>
From the Visual Studio 2005 Command Prompt, type:
</p><p><font face="Courier New">svcutil &lt;url&gt; /out:&lt;name&gt;Proxy.cs /noconfig<br />
svcutil http://gotjeep.net/services/ApproachAngleService.php?wsdl /out:ApproachAngleServiceProxy.cs
/noconfig</font></p><p><font face="Courier New"><img src="http://gotjeep.net/Blogs/content/binary/proxy.png" border="0" /></font></p><p>
This generates a file named <em>ApproachAngleServiceProxy.cs</em>.
</p><div style="BORDER-RIGHT: #969894 1px solid; BORDER-TOP: #969894 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #969894 1px solid; WIDTH: 831px; BORDER-BOTTOM: #969894 1px solid; HEIGHT: 200px"><div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    1</span> <span style="COLOR: green">//------------------------------------------------------------------------------</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    2</span> <span style="COLOR: green">//
&lt;auto-generated&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    3</span> <span style="COLOR: green">//   
This code was generated by a tool.</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    4</span> <span style="COLOR: green">//   
Runtime Version:2.0.50727.1433</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    5</span> <span style="COLOR: green">//</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    6</span> <span style="COLOR: green">//   
Changes to this file may cause incorrect behavior and will be lost if</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    7</span> <span style="COLOR: green">//   
the code is regenerated.</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    8</span> <span style="COLOR: green">//
&lt;/auto-generated&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    9</span> <span style="COLOR: green">//------------------------------------------------------------------------------</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   10</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   11</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   12</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   13</span> [System.CodeDom.Compiler.<span style="COLOR: #2b91af">GeneratedCodeAttribute</span>(<span style="COLOR: #a31515">"System.ServiceModel"</span>, <span style="COLOR: #a31515">"3.0.0.0"</span>)]
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   14</span> [System.ServiceModel.<span style="COLOR: #2b91af">ServiceContractAttribute</span>(Namespace=<span style="COLOR: #a31515">"http://www.gotjeep.net/tech"</span>,
ConfigurationName=<span style="COLOR: #a31515">"GotJeepApproachAngleCalculatorPortType"</span>)]
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   15</span> <span style="COLOR: blue">public</span><span style="COLOR: blue">interface</span><span style="COLOR: #2b91af">GotJeepApproachAngleCalculatorPortType</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   16</span> {
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   17</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   18</span>     [System.ServiceModel.<span style="COLOR: #2b91af">OperationContractAttribute</span>(Action=<span style="COLOR: #a31515">"http://www.gotjeep.net/services/approachAngleService.php/CalculateApproachAngle"</span>,
ReplyAction=<span style="COLOR: #a31515">"*"</span>)]
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   19</span>     [System.ServiceModel.<span style="COLOR: #2b91af">XmlSerializerFormatAttribute</span>(Style=System.ServiceModel.<span style="COLOR: #2b91af">OperationFormatStyle</span>.Rpc,
Use=System.ServiceModel.<span style="COLOR: #2b91af">OperationFormatUse</span>.Encoded)]
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   20</span>     [<span style="COLOR: blue">return</span>:
System.ServiceModel.<span style="COLOR: #2b91af">MessageParameterAttribute</span>(Name=<span style="COLOR: #a31515">"return"</span>)]
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   21</span>     <span style="COLOR: blue">decimal</span> CalculateApproachAngle(<span style="COLOR: blue">decimal</span> height, <span style="COLOR: blue">decimal</span> diameter, <span style="COLOR: blue">decimal</span> distance);
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   22</span> }
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   23</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   24</span> [System.CodeDom.Compiler.<span style="COLOR: #2b91af">GeneratedCodeAttribute</span>(<span style="COLOR: #a31515">"System.ServiceModel"</span>, <span style="COLOR: #a31515">"3.0.0.0"</span>)]
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   25</span> <span style="COLOR: blue">public</span><span style="COLOR: blue">interface</span><span style="COLOR: #2b91af">GotJeepApproachAngleCalculatorPortTypeChannel</span> : <span style="COLOR: #2b91af">GotJeepApproachAngleCalculatorPortType</span>,
System.ServiceModel.<span style="COLOR: #2b91af">IClientChannel</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   26</span> {
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   27</span> }
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   28</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   29</span> [System.Diagnostics.<span style="COLOR: #2b91af">DebuggerStepThroughAttribute</span>()]
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   30</span> [System.CodeDom.Compiler.<span style="COLOR: #2b91af">GeneratedCodeAttribute</span>(<span style="COLOR: #a31515">"System.ServiceModel"</span>, <span style="COLOR: #a31515">"3.0.0.0"</span>)]
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   31</span> <span style="COLOR: blue">public</span><span style="COLOR: blue">partial</span><span style="COLOR: blue">class</span><span style="COLOR: #2b91af">GotJeepApproachAngleCalculatorPortTypeClient</span> :
System.ServiceModel.<span style="COLOR: #2b91af">ClientBase</span>&lt;<span style="COLOR: #2b91af">GotJeepApproachAngleCalculatorPortType</span>&gt;, <span style="COLOR: #2b91af">GotJeepApproachAngleCalculatorPortType</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   32</span> {
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   33</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   34</span>     <span style="COLOR: blue">public</span> GotJeepApproachAngleCalculatorPortTypeClient()
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   35</span>     {
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   36</span>     }
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   37</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   38</span>     <span style="COLOR: blue">public</span> GotJeepApproachAngleCalculatorPortTypeClient(<span style="COLOR: blue">string</span> endpointConfigurationName)
: 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   39</span>        
    <span style="COLOR: blue">base</span>(endpointConfigurationName)
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   40</span>     {
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   41</span>     }
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   42</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   43</span>     <span style="COLOR: blue">public</span> GotJeepApproachAngleCalculatorPortTypeClient(<span style="COLOR: blue">string</span> endpointConfigurationName, <span style="COLOR: blue">string</span> remoteAddress)
: 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   44</span>        
    <span style="COLOR: blue">base</span>(endpointConfigurationName,
remoteAddress)
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   45</span>     {
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   46</span>     }
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   47</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   48</span>     <span style="COLOR: blue">public</span> GotJeepApproachAngleCalculatorPortTypeClient(<span style="COLOR: blue">string</span> endpointConfigurationName,
System.ServiceModel.<span style="COLOR: #2b91af">EndpointAddress</span> remoteAddress)
: 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   49</span>        
    <span style="COLOR: blue">base</span>(endpointConfigurationName,
remoteAddress)
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   50</span>     {
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   51</span>     }
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   52</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   53</span>     <span style="COLOR: blue">public</span> GotJeepApproachAngleCalculatorPortTypeClient(System.ServiceModel.Channels.<span style="COLOR: #2b91af">Binding</span> binding,
System.ServiceModel.<span style="COLOR: #2b91af">EndpointAddress</span> remoteAddress)
: 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   54</span>        
    <span style="COLOR: blue">base</span>(binding, remoteAddress)
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   55</span>     {
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   56</span>     }
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   57</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   58</span>     <span style="COLOR: blue">public</span><span style="COLOR: blue">decimal</span> CalculateApproachAngle(<span style="COLOR: blue">decimal</span> height, <span style="COLOR: blue">decimal</span> diameter, <span style="COLOR: blue">decimal</span> distance)
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   59</span>     {
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   60</span>         <span style="COLOR: blue">return</span><span style="COLOR: blue">base</span>.Channel.CalculateApproachAngle(height,
diameter, distance);
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   61</span>     }
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   62</span> }
</p></div><!--EndFragment--></div><p><strong></strong> 
</p><p><strong>Add client endpoint to your config file:</strong></p><p>
You have the option of letting svcutil create your config file or using "Generate
Service Reference", but I prefer to avoid the extra 20+ lines of config file defaults
included by svcutil. It's not hard to write it yourself, and it ensures a much more
readable config file.
</p><div style="BORDER-RIGHT: #969894 1px solid; BORDER-TOP: #969894 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #969894 1px solid; WIDTH: 777px; BORDER-BOTTOM: #969894 1px solid; HEIGHT: 200px"><div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    1</span> <span style="COLOR: blue">&lt;?</span><span style="COLOR: #a31515">xml</span><span style="COLOR: blue"></span><span style="COLOR: red">version</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">1.0</span>"<span style="COLOR: blue"></span><span style="COLOR: red">encoding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">utf-8</span>"<span style="COLOR: blue">?&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    2</span> <span style="COLOR: blue">&lt;</span><span style="COLOR: #a31515">configuration</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    3</span> <span style="COLOR: blue"> 
  &lt;</span><span style="COLOR: #a31515">system.serviceModel</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    4</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">bindings</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    5</span> <span style="COLOR: blue"> 
          &lt;</span><span style="COLOR: #a31515">basicHttpBinding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    6</span> <span style="COLOR: blue"> 
            &lt;</span><span style="COLOR: #a31515">binding</span><span style="COLOR: blue"></span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">GotJeepApproachAngleCalculatorBinding</span>"<span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    7</span> <span style="COLOR: blue"> 
              &lt;</span><span style="COLOR: #a31515">security</span><span style="COLOR: blue"></span><span style="COLOR: red">mode</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">None</span>"<span style="COLOR: blue">/&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    8</span> <span style="COLOR: blue"> 
            &lt;/</span><span style="COLOR: #a31515">binding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    9</span> <span style="COLOR: blue"> 
          &lt;/</span><span style="COLOR: #a31515">basicHttpBinding</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   10</span> <span style="COLOR: blue"> 
      &lt;/</span><span style="COLOR: #a31515">bindings</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   11</span> <span style="COLOR: blue"> 
      &lt;</span><span style="COLOR: #a31515">client</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   12</span> <span style="COLOR: blue"> 
          &lt;</span><span style="COLOR: #a31515">endpoint</span><span style="COLOR: blue"></span><span style="COLOR: red">address</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">http://www.gotjeep.net/services/approachAngleService.php</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   13</span> <span style="COLOR: blue"> 
              </span><span style="COLOR: red">binding</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">basicHttpBinding</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   14</span> <span style="COLOR: blue"> 
              </span><span style="COLOR: red">bindingConfiguration</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">GotJeepApproachAngleCalculatorBinding</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   15</span> <span style="COLOR: blue"> 
              </span><span style="COLOR: red">contract</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">GotJeepApproachAngleCalculatorPortType</span>"
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   16</span> <span style="COLOR: blue"> 
              </span><span style="COLOR: red">name</span><span style="COLOR: blue">=</span>"<span style="COLOR: blue">GotJeepApproachAngleCalculatorPort</span>"<span style="COLOR: blue"> /&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   17</span> <span style="COLOR: blue"> 
      &lt;/</span><span style="COLOR: #a31515">client</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   18</span> <span style="COLOR: blue"> 
  &lt;/</span><span style="COLOR: #a31515">system.serviceModel</span><span style="COLOR: blue">&gt;</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   19</span> <span style="COLOR: blue">&lt;/</span><span style="COLOR: #a31515">configuration</span><span style="COLOR: blue">&gt;</span></p></div><!--EndFragment--></div><p><strong></strong> 
</p><p><strong>Write the client code:</strong></p><div style="BORDER-RIGHT: #969894 1px solid; BORDER-TOP: #969894 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #969894 1px solid; WIDTH: 950px; BORDER-BOTTOM: #969894 1px solid; HEIGHT: 200px"><pre><font color="#0000ff" size="2"><div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    1</span> <span style="COLOR: blue">using</span> System;
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    2</span> 
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    3</span> <span style="COLOR: blue">namespace</span> Client
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    4</span> {
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    5</span>     <span style="COLOR: blue">class</span><span style="COLOR: #2b91af">Program</span></p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    6</span>    
{
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    7</span>    
    <span style="COLOR: blue">static</span><span style="COLOR: blue">void</span> Main(<span style="COLOR: blue">string</span>[]
args)
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    8</span>    
    {
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">    9</span>    
        <span style="COLOR: blue">using</span> (<span style="COLOR: #2b91af">GotJeepApproachAngleCalculatorPortTypeClient</span> proxy
=
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   10</span>        
        <span style="COLOR: blue">new</span><span style="COLOR: #2b91af">GotJeepApproachAngleCalculatorPortTypeClient</span>())
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   11</span>        
    {
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   12</span>        
        <span style="COLOR: blue">decimal</span> result
= proxy.CalculateApproachAngle(25.6m, 33.2m, 17.75m);
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   13</span>        
        <span style="COLOR: #2b91af">Console</span>.WriteLine(<span style="COLOR: #a31515">"decimal
result = proxy.CalculateApproachAngle(25.6m, 33.2m, 17.75m);"</span>);
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   14</span>        
        <span style="COLOR: #2b91af">Console</span>.WriteLine(<span style="COLOR: #a31515">"result
= "</span> + result.ToString(<span style="COLOR: #a31515">"0.00"</span>));
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   15</span>        
    }
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   16</span>        
}
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   17</span>     }
</p><p style="MARGIN: 0px"><span style="COLOR: #2b91af">   18</span> }
</p></div><!--EndFragment--></font><font size="2"></font></pre></div><p><strong></strong> 
</p><p><strong>Check it out:</strong></p><p>
A request-reply call between WCF and a Nusoap PHP web service.
</p><p><img src="http://gotjeep.net/Blogs/content/binary/client.png" border="0" /></p><img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=91bc9016-1219-473d-83fb-04cf34706fd6" /></body>
      <title>Calling your Nusoap PHP web service from WCF</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,91bc9016-1219-473d-83fb-04cf34706fd6.aspx</guid>
      <link>http://offroadcoder.com/2008/03/23/CallingYourNusoapPHPWebServiceFromWCF.aspx</link>
      <pubDate>Sun, 23 Mar 2008 02:25:00 GMT</pubDate>
      <description>&lt;p&gt;
WCF is seamless, powerful, and (YES)&amp;nbsp;interoperable. Here is a quick walkthrough
detailing steps to call your legacy PHP web services from a WCF client. All of the
binding types and security options are, of course, not available. But for those of
you following the old "security through obscurity" model, this will work fine.
&lt;/p&gt;
The procedure is just as simple as a WCF-WCF call: 
&lt;ol&gt;
&lt;li&gt;
Create client proxy 
&lt;li&gt;
Add client endpoint to your client config file 
&lt;li&gt;
Write your proxy-consuming client code&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
&lt;strong&gt;Create the client proxy:&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
Nusoap provides a similar UI when navigating to your PHP web service to that provided
by ASMX services. You can view the WSDL, and copy the URL for svcutil.exe.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://gotjeep.net/Blogs/content/binary/phpservice2.png" target=_blank alt="PHP Service : Click for full-size image"&gt;&lt;img src="http://gotjeep.net/Blogs/content/binary/phpservice2.png" width=200 border=0&gt;&lt;/a&gt;&lt;a href="http://gotjeep.net/Blogs/content/binary/phpservice3.png" target=_blank alt="WSDL : Click for full-size image"&gt;&lt;img src="http://gotjeep.net/Blogs/content/binary/phpservice3.png" width=200 border=0&gt;&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
From the Visual Studio 2005 Command Prompt, type:
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;svcutil &amp;lt;url&amp;gt; /out:&amp;lt;name&amp;gt;Proxy.cs /noconfig&lt;br&gt;
svcutil http://gotjeep.net/services/ApproachAngleService.php?wsdl /out:ApproachAngleServiceProxy.cs
/noconfig&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font face="Courier New"&gt;&lt;img src="http://gotjeep.net/Blogs/content/binary/proxy.png" border=0&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
This generates a file named &lt;em&gt;ApproachAngleServiceProxy.cs&lt;/em&gt;.
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: #969894 1px solid; BORDER-TOP: #969894 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #969894 1px solid; WIDTH: 831px; BORDER-BOTTOM: #969894 1px solid; HEIGHT: 200px"&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: green"&gt;//------------------------------------------------------------------------------&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: green"&gt;//
&amp;lt;auto-generated&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: green"&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;
This code was generated by a tool.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: green"&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;
Runtime Version:2.0.50727.1433&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: green"&gt;//&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: green"&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;
Changes to this file may cause incorrect behavior and will be lost if&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: green"&gt;//&amp;nbsp;&amp;nbsp;&amp;nbsp;
the code is regenerated.&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: green"&gt;//
&amp;lt;/auto-generated&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: green"&gt;//------------------------------------------------------------------------------&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&amp;nbsp;[System.CodeDom.Compiler.&lt;span style="COLOR: #2b91af"&gt;GeneratedCodeAttribute&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"System.ServiceModel"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;"3.0.0.0"&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&amp;nbsp;[System.ServiceModel.&lt;span style="COLOR: #2b91af"&gt;ServiceContractAttribute&lt;/span&gt;(Namespace=&lt;span style="COLOR: #a31515"&gt;"http://www.gotjeep.net/tech"&lt;/span&gt;,
ConfigurationName=&lt;span style="COLOR: #a31515"&gt;"GotJeepApproachAngleCalculatorPortType"&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;interface&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;GotJeepApproachAngleCalculatorPortType&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&amp;nbsp;{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [System.ServiceModel.&lt;span style="COLOR: #2b91af"&gt;OperationContractAttribute&lt;/span&gt;(Action=&lt;span style="COLOR: #a31515"&gt;"http://www.gotjeep.net/services/approachAngleService.php/CalculateApproachAngle"&lt;/span&gt;,
ReplyAction=&lt;span style="COLOR: #a31515"&gt;"*"&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [System.ServiceModel.&lt;span style="COLOR: #2b91af"&gt;XmlSerializerFormatAttribute&lt;/span&gt;(Style=System.ServiceModel.&lt;span style="COLOR: #2b91af"&gt;OperationFormatStyle&lt;/span&gt;.Rpc,
Use=System.ServiceModel.&lt;span style="COLOR: #2b91af"&gt;OperationFormatUse&lt;/span&gt;.Encoded)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;20&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; [&lt;span style="COLOR: blue"&gt;return&lt;/span&gt;:
System.ServiceModel.&lt;span style="COLOR: #2b91af"&gt;MessageParameterAttribute&lt;/span&gt;(Name=&lt;span style="COLOR: #a31515"&gt;"return"&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;21&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;decimal&lt;/span&gt; CalculateApproachAngle(&lt;span style="COLOR: blue"&gt;decimal&lt;/span&gt; height, &lt;span style="COLOR: blue"&gt;decimal&lt;/span&gt; diameter, &lt;span style="COLOR: blue"&gt;decimal&lt;/span&gt; distance);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;22&lt;/span&gt;&amp;nbsp;}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;23&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;24&lt;/span&gt;&amp;nbsp;[System.CodeDom.Compiler.&lt;span style="COLOR: #2b91af"&gt;GeneratedCodeAttribute&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"System.ServiceModel"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;"3.0.0.0"&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;25&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;interface&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;GotJeepApproachAngleCalculatorPortTypeChannel&lt;/span&gt; : &lt;span style="COLOR: #2b91af"&gt;GotJeepApproachAngleCalculatorPortType&lt;/span&gt;,
System.ServiceModel.&lt;span style="COLOR: #2b91af"&gt;IClientChannel&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;26&lt;/span&gt;&amp;nbsp;{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;27&lt;/span&gt;&amp;nbsp;}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;28&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;29&lt;/span&gt;&amp;nbsp;[System.Diagnostics.&lt;span style="COLOR: #2b91af"&gt;DebuggerStepThroughAttribute&lt;/span&gt;()]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;30&lt;/span&gt;&amp;nbsp;[System.CodeDom.Compiler.&lt;span style="COLOR: #2b91af"&gt;GeneratedCodeAttribute&lt;/span&gt;(&lt;span style="COLOR: #a31515"&gt;"System.ServiceModel"&lt;/span&gt;, &lt;span style="COLOR: #a31515"&gt;"3.0.0.0"&lt;/span&gt;)]
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;31&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;partial&lt;/span&gt; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;GotJeepApproachAngleCalculatorPortTypeClient&lt;/span&gt; :
System.ServiceModel.&lt;span style="COLOR: #2b91af"&gt;ClientBase&lt;/span&gt;&amp;lt;&lt;span style="COLOR: #2b91af"&gt;GotJeepApproachAngleCalculatorPortType&lt;/span&gt;&amp;gt;, &lt;span style="COLOR: #2b91af"&gt;GotJeepApproachAngleCalculatorPortType&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;32&lt;/span&gt;&amp;nbsp;{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;33&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;34&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; GotJeepApproachAngleCalculatorPortTypeClient()
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;35&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;36&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;37&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;38&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; GotJeepApproachAngleCalculatorPortTypeClient(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; endpointConfigurationName)
: 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;39&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;(endpointConfigurationName)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;40&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;41&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;42&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;43&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; GotJeepApproachAngleCalculatorPortTypeClient(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; endpointConfigurationName, &lt;span style="COLOR: blue"&gt;string&lt;/span&gt; remoteAddress)
: 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;44&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;(endpointConfigurationName,
remoteAddress)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;45&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;46&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;47&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;48&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; GotJeepApproachAngleCalculatorPortTypeClient(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt; endpointConfigurationName,
System.ServiceModel.&lt;span style="COLOR: #2b91af"&gt;EndpointAddress&lt;/span&gt; remoteAddress)
: 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;49&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;(endpointConfigurationName,
remoteAddress)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;50&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;51&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;52&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;53&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; GotJeepApproachAngleCalculatorPortTypeClient(System.ServiceModel.Channels.&lt;span style="COLOR: #2b91af"&gt;Binding&lt;/span&gt; binding,
System.ServiceModel.&lt;span style="COLOR: #2b91af"&gt;EndpointAddress&lt;/span&gt; remoteAddress)
: 
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;54&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;(binding, remoteAddress)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;55&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;56&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;57&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;58&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;public&lt;/span&gt; &lt;span style="COLOR: blue"&gt;decimal&lt;/span&gt; CalculateApproachAngle(&lt;span style="COLOR: blue"&gt;decimal&lt;/span&gt; height, &lt;span style="COLOR: blue"&gt;decimal&lt;/span&gt; diameter, &lt;span style="COLOR: blue"&gt;decimal&lt;/span&gt; distance)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;59&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;60&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;return&lt;/span&gt; &lt;span style="COLOR: blue"&gt;base&lt;/span&gt;.Channel.CalculateApproachAngle(height,
diameter, distance);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;61&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;62&lt;/span&gt;&amp;nbsp;}
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Add client endpoint to your config file:&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
You have the option of letting svcutil create your config file or using "Generate
Service Reference", but I prefer to avoid the extra 20+ lines of config file defaults
included by svcutil. It's not hard to write it yourself, and it ensures a much more
readable config file.
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: #969894 1px solid; BORDER-TOP: #969894 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #969894 1px solid; WIDTH: 777px; BORDER-BOTTOM: #969894 1px solid; HEIGHT: 200px"&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;lt;?&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;xml&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;version&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;1.0&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;encoding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;utf-8&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;?&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;system.serviceModel&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;bindings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;basicHttpBinding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;GotJeepApproachAngleCalculatorBinding&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;security&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;mode&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;None&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;/&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;basicHttpBinding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;bindings&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;client&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;endpoint&lt;/span&gt;&lt;span style="COLOR: blue"&gt; &lt;/span&gt;&lt;span style="COLOR: red"&gt;address&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;http://www.gotjeep.net/services/approachAngleService.php&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;binding&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;basicHttpBinding&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;bindingConfiguration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;GotJeepApproachAngleCalculatorBinding&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;contract&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;GotJeepApproachAngleCalculatorPortType&lt;/span&gt;"
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span style="COLOR: red"&gt;name&lt;/span&gt;&lt;span style="COLOR: blue"&gt;=&lt;/span&gt;"&lt;span style="COLOR: blue"&gt;GotJeepApproachAngleCalculatorPort&lt;/span&gt;"&lt;span style="COLOR: blue"&gt; /&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;client&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;nbsp;
&amp;nbsp; &amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;system.serviceModel&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;19&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;&amp;lt;/&lt;/span&gt;&lt;span style="COLOR: #a31515"&gt;configuration&lt;/span&gt;&lt;span style="COLOR: blue"&gt;&amp;gt;&lt;/span&gt;
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Write the client code:&lt;/strong&gt;
&lt;/p&gt;
&lt;div style="BORDER-RIGHT: #969894 1px solid; BORDER-TOP: #969894 1px solid; OVERFLOW-Y: auto; BORDER-LEFT: #969894 1px solid; WIDTH: 950px; BORDER-BOTTOM: #969894 1px solid; HEIGHT: 200px"&gt;&lt;pre&gt;&lt;font color=#0000ff size=2&gt;
&lt;div style="FONT-SIZE: 10pt; BACKGROUND: white; COLOR: black; FONT-FAMILY: Courier New"&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;using&lt;/span&gt; System;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;2&lt;/span&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3&lt;/span&gt;&amp;nbsp;&lt;span style="COLOR: blue"&gt;namespace&lt;/span&gt; Client
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;4&lt;/span&gt;&amp;nbsp;{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;class&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;Program&lt;/span&gt;
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;6&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
{
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;static&lt;/span&gt; &lt;span style="COLOR: blue"&gt;void&lt;/span&gt; Main(&lt;span style="COLOR: blue"&gt;string&lt;/span&gt;[]
args)
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;8&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;9&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;using&lt;/span&gt; (&lt;span style="COLOR: #2b91af"&gt;GotJeepApproachAngleCalculatorPortTypeClient&lt;/span&gt; proxy
=
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;10&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;new&lt;/span&gt; &lt;span style="COLOR: #2b91af"&gt;GotJeepApproachAngleCalculatorPortTypeClient&lt;/span&gt;())
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;11&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;12&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: blue"&gt;decimal&lt;/span&gt; result
= proxy.CalculateApproachAngle(25.6m, 33.2m, 17.75m);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;13&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: #a31515"&gt;"decimal
result = proxy.CalculateApproachAngle(25.6m, 33.2m, 17.75m);"&lt;/span&gt;);
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;14&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="COLOR: #2b91af"&gt;Console&lt;/span&gt;.WriteLine(&lt;span style="COLOR: #a31515"&gt;"result
= "&lt;/span&gt; + result.ToString(&lt;span style="COLOR: #a31515"&gt;"0.00"&lt;/span&gt;));
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;15&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;16&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;
}
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;17&lt;/span&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }
&lt;/p&gt;
&lt;p style="MARGIN: 0px"&gt;
&lt;span style="COLOR: #2b91af"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;18&lt;/span&gt;&amp;nbsp;}
&lt;/p&gt;
&lt;/div&gt;
&lt;!--EndFragment--&gt;&lt;/font&gt;&lt;font size=2&gt;&lt;/font&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;p&gt;
&lt;strong&gt;&lt;/strong&gt;&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;Check it out:&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
A request-reply call between WCF and a Nusoap PHP web service.
&lt;/p&gt;
&lt;p&gt;
&lt;img src="http://gotjeep.net/Blogs/content/binary/client.png" border=0&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=91bc9016-1219-473d-83fb-04cf34706fd6" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,91bc9016-1219-473d-83fb-04cf34706fd6.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>WCF</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=a79d6f30-2b6b-4707-85e0-3f4560b4f09e</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,a79d6f30-2b6b-4707-85e0-3f4560b4f09e.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,a79d6f30-2b6b-4707-85e0-3f4560b4f09e.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a79d6f30-2b6b-4707-85e0-3f4560b4f09e</wfw:commentRss>
      <slash:comments>6</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
In a <a href="http://gotjeep.net/Blogs/PermaLink,guid,e29199af-6868-44d5-bd16-873aa770d39a.aspx">previous
post about the AJAX Extensions</a>, I detailed the copy commands to retrieve the DLLs
from the GAC. Same thing, this time for the ASP.NET 3.5 Extensions. If you are demoing
CTP material in a hosted environment, you will likely need these in your app's bin
to avoid the inevitable configuration error.
</p>
        <p>
copy "C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.6.0.0__31bf3856ad364e35"
C:\dev\MMVCApp\bin<br />
copy "C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions.Design\3.6.0.0__31bf3856ad364e35"
C:\dev\MMVCApp\bin
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=a79d6f30-2b6b-4707-85e0-3f4560b4f09e" />
      </body>
      <title>Getting your ASP.NET Futures DLLs out of the GAC</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,a79d6f30-2b6b-4707-85e0-3f4560b4f09e.aspx</guid>
      <link>http://offroadcoder.com/2008/01/21/GettingYourASPNETFuturesDLLsOutOfTheGAC.aspx</link>
      <pubDate>Mon, 21 Jan 2008 03:25:40 GMT</pubDate>
      <description>&lt;p&gt;
In a &lt;a href="http://gotjeep.net/Blogs/PermaLink,guid,e29199af-6868-44d5-bd16-873aa770d39a.aspx"&gt;previous
post about the AJAX Extensions&lt;/a&gt;, I detailed the copy commands to retrieve the DLLs
from the GAC. Same thing, this time for the ASP.NET 3.5 Extensions. If you are demoing
CTP material in a hosted environment, you will likely need these in your app's bin
to avoid the inevitable configuration error.
&lt;/p&gt;
&lt;p&gt;
copy "C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\3.6.0.0__31bf3856ad364e35"
C:\dev\MMVCApp\bin&lt;br&gt;
copy "C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions.Design\3.6.0.0__31bf3856ad364e35"
C:\dev\MMVCApp\bin
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=a79d6f30-2b6b-4707-85e0-3f4560b4f09e" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,a79d6f30-2b6b-4707-85e0-3f4560b4f09e.aspx</comments>
      <category>.NET Framework</category>
      <category>ASP.NET</category>
      <category>ASP.NET MVC</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=a1477bfd-e498-42d3-b190-b84f7d27c259</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,a1477bfd-e498-42d3-b190-b84f7d27c259.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,a1477bfd-e498-42d3-b190-b84f7d27c259.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=a1477bfd-e498-42d3-b190-b84f7d27c259</wfw:commentRss>
      <slash:comments>3</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
A great series of blog posts by Scott Guthrie about the ASP.NET <a href="http://en.wikipedia.org/wiki/Model-view-controller">MVC</a> Framework
coming soon as part of the <a href="http://weblogs.asp.net/scottgu/archive/2007/11/29/net-web-product-roadmap-asp-net-silverlight-iis7.aspx">ASP.NET
3.5 Extensions release</a>. 
</p>
        <p>
Upon hearing the news, a few friends started questioning its intent, usefulness, and
longevity. Many of us have been using or contemplating conversion to the <a href="http://msdn.microsoft.com/msdnmag/issues/06/08/DesignPatterns/">MVP
pattern</a>, most recently using <a href="http://www.codeplex.com/websf">WCSF</a>.
The recent split of the MVP pattern by Fowler has caused many believers to question
their faith. While many are still "proving" MVP, MVC has been around for nearly 30
years. <a href="http://www.polymorphicpodcast.com/shows/aspnetmvc/">Some believe</a> that
MVP and MVC can co-exist. <a href="http://www.pnpguidance.net/Category/WebClientSoftwareFactory.aspx">Here</a> is
a comparison of MVP and MVC that concludes by painting an optimistic picture
of MVP and MVC contributing to each other.
</p>
        <p>
ASP.NET MVC appears to be the answer to my unit testing, REST, and code separation
prayers. Thank you ScottGu and team!
</p>
        <p>
          <a href="http://weblogs.asp.net/scottgu/archive/2007/12/09/asp-net-3-5-extensions-ctp-preview-released.aspx">Check
it out!</a>
        </p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=a1477bfd-e498-42d3-b190-b84f7d27c259" />
      </body>
      <title>ASP.NET MVC</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,a1477bfd-e498-42d3-b190-b84f7d27c259.aspx</guid>
      <link>http://offroadcoder.com/2007/12/19/ASPNETMVC.aspx</link>
      <pubDate>Wed, 19 Dec 2007 02:06:20 GMT</pubDate>
      <description>&lt;p&gt;
A great series of blog posts by Scott Guthrie about the ASP.NET &lt;a href="http://en.wikipedia.org/wiki/Model-view-controller"&gt;MVC&lt;/a&gt; Framework
coming soon as part of the &lt;a href="http://weblogs.asp.net/scottgu/archive/2007/11/29/net-web-product-roadmap-asp-net-silverlight-iis7.aspx"&gt;ASP.NET
3.5 Extensions release&lt;/a&gt;. 
&lt;/p&gt;
&lt;p&gt;
Upon hearing the news, a few friends started questioning its intent, usefulness, and
longevity. Many of us have been using or contemplating conversion to the &lt;a href="http://msdn.microsoft.com/msdnmag/issues/06/08/DesignPatterns/"&gt;MVP
pattern&lt;/a&gt;, most recently using &lt;a href="http://www.codeplex.com/websf"&gt;WCSF&lt;/a&gt;.
The recent split of the MVP pattern by Fowler has caused many believers to question
their faith. While many are still "proving" MVP, MVC has been around for nearly 30
years. &lt;a href="http://www.polymorphicpodcast.com/shows/aspnetmvc/"&gt;Some believe&lt;/a&gt; that
MVP and MVC can co-exist. &lt;a href="http://www.pnpguidance.net/Category/WebClientSoftwareFactory.aspx"&gt;Here&lt;/a&gt; is
a comparison of MVP and MVC that concludes by painting&amp;nbsp;an optimistic picture
of MVP and MVC contributing to each other.
&lt;/p&gt;
&lt;p&gt;
ASP.NET MVC appears to be the answer to my unit testing, REST, and code separation
prayers. Thank you ScottGu and team!
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://weblogs.asp.net/scottgu/archive/2007/12/09/asp-net-3-5-extensions-ctp-preview-released.aspx"&gt;Check
it out!&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=a1477bfd-e498-42d3-b190-b84f7d27c259" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,a1477bfd-e498-42d3-b190-b84f7d27c259.aspx</comments>
      <category>.NET Framework</category>
      <category>AJAX</category>
      <category>ASP.NET</category>
      <category>ASP.NET MVC</category>
      <category>C#</category>
      <category>Javascript</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=db20d8db-df16-40af-b081-448affaeaf9d</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,db20d8db-df16-40af-b081-448affaeaf9d.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,db20d8db-df16-40af-b081-448affaeaf9d.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=db20d8db-df16-40af-b081-448affaeaf9d</wfw:commentRss>
      <slash:comments>6</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://blogs.msdn.com/charlie/archive/2007/11/11/partial-methods.aspx">Here</a> is
a fantastic solution to a common <a href="http://en.wikipedia.org/wiki/Object_relational_mapper">ORMr</a> problem
seen when regenerating code that overwrites changes made to previously generated and
more recently manually-modified code.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=db20d8db-df16-40af-b081-448affaeaf9d" />
      </body>
      <title>Partial Methods</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,db20d8db-df16-40af-b081-448affaeaf9d.aspx</guid>
      <link>http://offroadcoder.com/2007/12/18/PartialMethods.aspx</link>
      <pubDate>Tue, 18 Dec 2007 03:04:16 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://blogs.msdn.com/charlie/archive/2007/11/11/partial-methods.aspx"&gt;Here&lt;/a&gt;&amp;nbsp;is
a fantastic solution to a common &lt;a href="http://en.wikipedia.org/wiki/Object_relational_mapper"&gt;ORMr&lt;/a&gt; problem
seen when regenerating code that overwrites changes made to previously generated and
more recently manually-modified code.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=db20d8db-df16-40af-b081-448affaeaf9d" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,db20d8db-df16-40af-b081-448affaeaf9d.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=41d6d631-cf1b-4cfe-9f92-488314ba3e78</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,41d6d631-cf1b-4cfe-9f92-488314ba3e78.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,41d6d631-cf1b-4cfe-9f92-488314ba3e78.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=41d6d631-cf1b-4cfe-9f92-488314ba3e78</wfw:commentRss>
      <slash:comments>8</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://weblogs.asp.net/scottgu/archive/2007/11/19/visual-studio-2008-and-net-3-5-released.aspx">http://weblogs.asp.net/scottgu/archive/2007/11/19/visual-studio-2008-and-net-3-5-released.aspx</a>
        </p>
        <p>
I'm downloading it now.
</p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=41d6d631-cf1b-4cfe-9f92-488314ba3e78" />
      </body>
      <title>VS 2008 and .NET 3.5 Features</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,41d6d631-cf1b-4cfe-9f92-488314ba3e78.aspx</guid>
      <link>http://offroadcoder.com/2007/11/22/VS2008AndNET35Features.aspx</link>
      <pubDate>Thu, 22 Nov 2007 03:08:56 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://weblogs.asp.net/scottgu/archive/2007/11/19/visual-studio-2008-and-net-3-5-released.aspx"&gt;http://weblogs.asp.net/scottgu/archive/2007/11/19/visual-studio-2008-and-net-3-5-released.aspx&lt;/a&gt;
&lt;/p&gt;
&lt;p&gt;
I'm downloading it now.
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=41d6d631-cf1b-4cfe-9f92-488314ba3e78" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,41d6d631-cf1b-4cfe-9f92-488314ba3e78.aspx</comments>
      <category>.NET Framework</category>
      <category>ASP.NET</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=00fc7c82-6dbd-4def-99ea-28a1eb7303b4</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,00fc7c82-6dbd-4def-99ea-28a1eb7303b4.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=00fc7c82-6dbd-4def-99ea-28a1eb7303b4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
It's only a week away, and there are still spaces left.
</p>
        <p>
          <a href="http://codecamp07.jaxdug.com/">Information</a>   <a href="http://www.clicktoattend.com/?id=119680">Register</a>    <a href="http://codecamp07.jaxdug.com/Sessions/tabid/72/Default.aspx">Sessions</a></p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=00fc7c82-6dbd-4def-99ea-28a1eb7303b4" />
      </body>
      <title>2007 Jacksonville Code Camp</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,00fc7c82-6dbd-4def-99ea-28a1eb7303b4.aspx</guid>
      <link>http://offroadcoder.com/2007/08/17/2007JacksonvilleCodeCamp.aspx</link>
      <pubDate>Fri, 17 Aug 2007 03:42:12 GMT</pubDate>
      <description>&lt;p&gt;
It's only a week away, and there are still spaces left.
&lt;/p&gt;
&lt;p&gt;
&lt;a href="http://codecamp07.jaxdug.com/"&gt;Information&lt;/a&gt;&amp;nbsp;&amp;nbsp; &lt;a href="http://www.clicktoattend.com/?id=119680"&gt;Register&lt;/a&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;a href="http://codecamp07.jaxdug.com/Sessions/tabid/72/Default.aspx"&gt;Sessions&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=00fc7c82-6dbd-4def-99ea-28a1eb7303b4" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,00fc7c82-6dbd-4def-99ea-28a1eb7303b4.aspx</comments>
      <category>.NET Framework</category>
      <category>AJAX</category>
      <category>ASP.NET</category>
      <category>C#</category>
      <category>Database</category>
      <category>General</category>
      <category>Javascript</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=4d4e4b7c-411b-4803-a645-255f102b3665</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,4d4e4b7c-411b-4803-a645-255f102b3665.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:comment>http://offroadcoder.com/CommentView,guid,4d4e4b7c-411b-4803-a645-255f102b3665.aspx</wfw:comment>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=4d4e4b7c-411b-4803-a645-255f102b3665</wfw:commentRss>
      <slash:comments>5</slash:comments>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I frequently store documents in the database for my ASP.NET apps, eliminating web
farm complications with shared drives, permissions, etc.  When uploading
a file, my Document class reads the uploaded file, zips the file with <a href="http://www.icsharpcode.net/OpenSource/SharpZipLib/">SharpZipLib</a>,
and inserts/updates in the database.   When opening a file, I have always
used an ASPX page that uses the Document class to unzip the file, and then changes
the Content-Disposition and ContentType headers, and then does a BinaryWrite
to the Response object to display the file.
</p>
        <p>
I have been using Handlers a lot lately, and figured that it was time to make this
process a little more elegant.  If you've never written a handler, it's quite
simple.  You need to make a web.config change, and add a new class that implementts
IHttpHandler.  All of the work is done in ProcessRequest.  Using the
default .ashx extension for the handler eliminates the need to make any changes in
IIS.  I thought about changing the handler to accept all requests with known
file extensions with the document ID as the filename, like 3383.pdf.  I just
figured that using the default extnesion would be easier.   Laziness
or efficiency, you decide.  Check out the code.
</p>
        <p>
          <strong>In &lt;system.web&gt; in web.config: 
<hr /></strong>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                  <font color="#0000ff" size="2">&lt;</font>
                  <font color="#800000" size="2">httpHandlers</font>
                  <font color="#0000ff" size="2">&gt;</font>
                  <font size="2">
                    <br />
   </font>
                  <font color="#0000ff" size="2">&lt;</font>
                  <font color="#800000" size="2">add</font>
                  <font color="#ff00ff" size="2">
                  </font>
                  <font color="#ff0000" size="2">verb</font>
                  <font color="#0000ff" size="2">="*"</font>
                  <font color="#ff00ff" size="2">
                  </font>
                  <font color="#ff0000" size="2">path</font>
                  <font color="#0000ff" size="2">="DocumentHandler.ashx"</font>
                  <font color="#ff00ff" size="2">
                  </font>
                  <font color="#ff0000" size="2">type</font>
                  <font color="#0000ff" size="2">="TestingWebApp.DocumentHandler,
TestingWebApp"</font>
                  <font color="#ff00ff" size="2">
                  </font>
                  <font color="#0000ff" size="2">/&gt; </font>
                  <font size="2">
                    <br />
                  </font>
                  <font color="#0000ff" size="2">&lt;/</font>
                  <font color="#800000" size="2">httpHandlers</font>
                  <font color="#0000ff" size="2">&gt; 
<p></p></font>
                </span>
              </span>
            </span>
            <p>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <font face="Verdana" size="2">
                  <strong>DocumentHandler.cs: 
<hr /></strong>
                </font>
              </span>
              <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                <font face="Verdana" size="2">
                  <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
                    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">using</span> System;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">using</span> System.Web;<br /><br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">namespace</span> TestingWebApp<br />
{<br />
    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">class</span> DocumentHandler
: IHttpHandler<br />
    {<br />
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> DocumentId 
<br />
        {<br />
            get<br />
            {<br />
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">if</span>(System.Web.HttpContext.Current.Request.QueryString[<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"DocumentId"</span>]
!<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">null</span> &amp;&amp;
System.Web.HttpContext.Current.Request.QueryString[<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"DocumentId"</span>].ToString().Length
&gt; 0) 
<br />
                    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span> Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString[<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"DocumentId"</span>]);<br />
                <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">else</span><br />
                    <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">throw</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> ApplicationException(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Document
Handler requires a DocumentId"</span>);<br />
            }<br />
        }<br /><br />
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">#region</span> IHttpHandler
Members<br /><br />
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> ProcessRequest(System.Web.HttpContext
context)<br />
        {<br />
            context.Response.Cache.SetCacheability(HttpCacheability.Public);<br />
            context.Response.BufferOutput <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">false</span>;<br />
            <br />
            Document document <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> Document.GetDocumentByDocumentId(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>.DocumentId);<br /><br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">byte</span>[]
buffer <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> document.UnzippedBinary;<br />
            context.Response.ContentType <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> document.ContentType;<br />
            context.Response.OutputStream.Write(buffer,
0, buffer.Length);<br />
        }<br /><br />
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">bool</span> IsReusable<br />
        {<br />
            get { <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">return</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">true</span>;
}<br />
        }<br /><br />
        <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">#endregion</span><br />
    }<br />
}</span>
                </font>
              </span>
            </p>
          </span>
          <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=4d4e4b7c-411b-4803-a645-255f102b3665" />
        </p>
      </body>
      <title>ASP.NET Document Handler</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,4d4e4b7c-411b-4803-a645-255f102b3665.aspx</guid>
      <link>http://offroadcoder.com/2006/11/07/ASPNETDocumentHandler.aspx</link>
      <pubDate>Tue, 07 Nov 2006 04:31:15 GMT</pubDate>
      <description>&lt;p&gt;
I frequently store documents in the database for my ASP.NET apps, eliminating web
farm complications with shared drives, permissions, etc.&amp;nbsp;&amp;nbsp;When uploading
a file, my Document class reads the uploaded file, zips the file with &lt;a href="http://www.icsharpcode.net/OpenSource/SharpZipLib/"&gt;SharpZipLib&lt;/a&gt;,
and inserts/updates in the database.&amp;nbsp;&amp;nbsp; When opening a file, I have always
used an ASPX&amp;nbsp;page that uses the Document class to unzip the file, and then changes
the Content-Disposition and ContentType headers,&amp;nbsp;and then does a BinaryWrite
to the Response object to display the file.
&lt;/p&gt;
&lt;p&gt;
I have been using Handlers a lot lately, and figured that it was time to make this
process a little more elegant.&amp;nbsp; If you've never written a handler, it's quite
simple.&amp;nbsp; You need to make a web.config change, and add a new class that implementts
IHttpHandler.&amp;nbsp; All of the work is done in ProcessRequest.&amp;nbsp;&amp;nbsp;Using the
default .ashx extension for the handler eliminates the need to make any changes in
IIS.&amp;nbsp; I thought about changing the handler to accept all requests with known
file extensions with the document ID as the filename, like 3383.pdf.&amp;nbsp; I just
figured that&amp;nbsp;using the default extnesion&amp;nbsp;would be easier.&amp;nbsp;&amp;nbsp; Laziness
or efficiency, you decide.&amp;nbsp; Check out the code.
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;In &amp;lt;system.web&amp;gt; in web.config: 
&lt;hr&gt;
&lt;/strong&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font color=#0000ff size=2&gt;&amp;lt;&lt;/font&gt;&lt;font color=#800000 size=2&gt;httpHandlers&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;gt;&lt;/font&gt;&lt;font size=2&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;lt;&lt;/font&gt;&lt;font color=#800000 size=2&gt;add&lt;/font&gt;&lt;font color=#ff00ff size=2&gt; &lt;/font&gt;&lt;font color=#ff0000 size=2&gt;verb&lt;/font&gt;&lt;font color=#0000ff size=2&gt;="*"&lt;/font&gt;&lt;font color=#ff00ff size=2&gt; &lt;/font&gt;&lt;font color=#ff0000 size=2&gt;path&lt;/font&gt;&lt;font color=#0000ff size=2&gt;="DocumentHandler.ashx"&lt;/font&gt;&lt;font color=#ff00ff size=2&gt; &lt;/font&gt;&lt;font color=#ff0000 size=2&gt;type&lt;/font&gt;&lt;font color=#0000ff size=2&gt;="TestingWebApp.DocumentHandler,
TestingWebApp"&lt;/font&gt;&lt;font color=#ff00ff size=2&gt; &lt;/font&gt;&lt;font color=#0000ff size=2&gt;/&amp;gt; &lt;/font&gt;&lt;font size=2&gt;
&lt;br&gt;
&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;lt;/&lt;/font&gt;&lt;font color=#800000 size=2&gt;httpHandlers&lt;/font&gt;&lt;font color=#0000ff size=2&gt;&amp;gt; 
&lt;p&gt;
&lt;/p&gt;
&lt;/font&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;&lt;strong&gt;DocumentHandler.cs: 
&lt;hr&gt;
&lt;/strong&gt;&lt;/font&gt;&lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;font face=Verdana size=2&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;using&lt;/span&gt; System.Web;&lt;br&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;namespace&lt;/span&gt; TestingWebApp&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;class&lt;/span&gt; DocumentHandler
: IHttpHandler&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; DocumentId 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;get&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;if&lt;/span&gt;(System.Web.HttpContext.Current.Request.QueryString[&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"DocumentId"&lt;/span&gt;]
!&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/span&gt; &amp;amp;&amp;amp;
System.Web.HttpContext.Current.Request.QueryString[&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"DocumentId"&lt;/span&gt;].ToString().Length
&amp;gt; 0) 
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; Convert.ToInt32(System.Web.HttpContext.Current.Request.QueryString[&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"DocumentId"&lt;/span&gt;]);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;else&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; ApplicationException(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Document
Handler requires a DocumentId"&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;#region&lt;/span&gt; IHttpHandler
Members&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; ProcessRequest(System.Web.HttpContext
context)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;context.Response.Cache.SetCacheability(HttpCacheability.Public);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;context.Response.BufferOutput &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;false&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Document document &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; Document.GetDocumentByDocumentId(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;.DocumentId);&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;byte&lt;/span&gt;[]
buffer &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; document.UnzippedBinary;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;context.Response.ContentType &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; document.ContentType;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;context.Response.OutputStream.Write(buffer,
0, buffer.Length);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;bool&lt;/span&gt; IsReusable&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;{&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;get { &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;return&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;true&lt;/span&gt;;
}&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;#endregion&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
}&lt;/span&gt;&lt;/font&gt;&lt;/span&gt;
&lt;/span&gt;&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=4d4e4b7c-411b-4803-a645-255f102b3665" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,4d4e4b7c-411b-4803-a645-255f102b3665.aspx</comments>
      <category>.NET Framework</category>
      <category>ASP.NET</category>
      <category>C#</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=f6fd0916-c5a0-4545-9bda-142e062de1f5</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,f6fd0916-c5a0-4545-9bda-142e062de1f5.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=f6fd0916-c5a0-4545-9bda-142e062de1f5</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
          <a href="http://developer.coreweb.com/articles/Default12.aspx">The Subject is Predicates:
On the Use of Predicates in C#</a>
        </p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=f6fd0916-c5a0-4545-9bda-142e062de1f5" />
      </body>
      <title>Great article about Predicates</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,f6fd0916-c5a0-4545-9bda-142e062de1f5.aspx</guid>
      <link>http://offroadcoder.com/2006/08/30/GreatArticleAboutPredicates.aspx</link>
      <pubDate>Wed, 30 Aug 2006 01:51:51 GMT</pubDate>
      <description>&lt;p&gt;
&lt;a href="http://developer.coreweb.com/articles/Default12.aspx"&gt;The Subject is Predicates:
On the Use of Predicates in C#&lt;/a&gt; 
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=f6fd0916-c5a0-4545-9bda-142e062de1f5" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,f6fd0916-c5a0-4545-9bda-142e062de1f5.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=0901a197-60df-4409-bc23-142122079693</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,0901a197-60df-4409-bc23-142122079693.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=0901a197-60df-4409-bc23-142122079693</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
This 2.1 update includes over 60 improvements, including new support for .NET 2.0
and Visual Studio 2005. VistaDB is a small-footprint, embedded SQL database alternative
to Jet/Access, MSDE and SQL Server Express 2005 that enables developers to build .NET
1.1 and .NET 2.0 applications. Features SQL-92 support, small 500KB embedded footprint,
free 2-User VistaDB Server for remote TCP/IP data access, royalty free distribution
for both embedded and server, Copy 'n Go! deployment, managed ADO.NET Provider, data
management and data migration tools. Free trial is available for download.
</p>
        <ul>
          <li>
            <a href="http://www.vistadb.net/overview.asp?ref=blogger">Learn more about VistaDB</a>  
</li>
          <li>
            <a href="http://www.vistadb.net/blogoffer.asp?ref=blogger">Repost this to your blog
and receive a FREE copy of VistaDB 2.1!</a>
          </li>
        </ul>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=0901a197-60df-4409-bc23-142122079693" />
      </body>
      <title>VistaDB 2.1 database for .NET has been released</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,0901a197-60df-4409-bc23-142122079693.aspx</guid>
      <link>http://offroadcoder.com/2005/11/09/VistaDB21DatabaseForNETHasBeenReleased.aspx</link>
      <pubDate>Wed, 09 Nov 2005 02:55:01 GMT</pubDate>
      <description>&lt;p&gt;
This 2.1 update includes over 60 improvements, including new support for .NET 2.0
and Visual Studio 2005. VistaDB is a small-footprint, embedded SQL database alternative
to Jet/Access, MSDE and SQL Server Express 2005 that enables developers to build .NET
1.1 and .NET 2.0 applications. Features SQL-92 support, small 500KB embedded footprint,
free 2-User VistaDB Server for remote TCP/IP data access, royalty free distribution
for both embedded and server, Copy 'n Go! deployment, managed ADO.NET Provider, data
management and data migration tools. Free trial is available for download.
&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;a href="http://www.vistadb.net/overview.asp?ref=blogger"&gt;Learn more about VistaDB&lt;/a&gt;&amp;nbsp; 
&lt;li&gt;
&lt;a href="http://www.vistadb.net/blogoffer.asp?ref=blogger"&gt;Repost this to your blog
and receive a FREE copy of VistaDB 2.1!&lt;/a&gt; 
&lt;/li&gt;
&lt;/ul&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=0901a197-60df-4409-bc23-142122079693" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,0901a197-60df-4409-bc23-142122079693.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
      <category>Database</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=296721bd-fd68-4aa0-a330-ba73bf58854f</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,296721bd-fd68-4aa0-a330-ba73bf58854f.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=296721bd-fd68-4aa0-a330-ba73bf58854f</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Yesterday, <a href="http://www.microsoft.com/presspass/exec/somasegar/default.mspx">S.
Somasegar</a>, Corporate Vice President, Developer Division (Microsoft) shared some
fantastic news, in <a href="http://blogs.msdn.com/somasegar">his blog</a>, about a
new language enhancement in C# 2.0. In addition to Generics, Anonymous Methods, Iterators,
and Partial Types, we will now have <a href="http://msdn.microsoft.com/vcsharp/2005/overview/language/nullabletypes/">nullable
types</a>. Also, more details on MSDN about <a href="http://blogs.msdn.com/somasegar/archive/2005/08/11/450640.aspx">nullable
types</a></p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=296721bd-fd68-4aa0-a330-ba73bf58854f" />
      </body>
      <title>C# 2.0 - Nullable types</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,296721bd-fd68-4aa0-a330-ba73bf58854f.aspx</guid>
      <link>http://offroadcoder.com/2005/08/13/C20NullableTypes.aspx</link>
      <pubDate>Sat, 13 Aug 2005 01:58:43 GMT</pubDate>
      <description>&lt;p&gt;
Yesterday, &lt;a href="http://www.microsoft.com/presspass/exec/somasegar/default.mspx"&gt;S.
Somasegar&lt;/a&gt;, Corporate Vice President, Developer Division (Microsoft) shared some
fantastic news, in &lt;a href="http://blogs.msdn.com/somasegar"&gt;his blog&lt;/a&gt;, about a
new language enhancement in C# 2.0. In addition to Generics, Anonymous Methods, Iterators,
and Partial Types, we will now have &lt;a href="http://msdn.microsoft.com/vcsharp/2005/overview/language/nullabletypes/"&gt;nullable
types&lt;/a&gt;. Also, more details on MSDN about &lt;a href="http://blogs.msdn.com/somasegar/archive/2005/08/11/450640.aspx"&gt;nullable
types&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=296721bd-fd68-4aa0-a330-ba73bf58854f" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,296721bd-fd68-4aa0-a330-ba73bf58854f.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=d245ba6e-1f02-4280-af8f-b9491101d6cc</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,d245ba6e-1f02-4280-af8f-b9491101d6cc.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=d245ba6e-1f02-4280-af8f-b9491101d6cc</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
I have read too many articles showing the connection being opened and closed around
a DataAdapter Fill() as in the code below. It does no harm, but it not necessary. 
</p>
        <p>
          <strong>
            <font color="#0000ff">Don't do this...</font>
          </strong>
        </p>
        <p>
          <code>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SqlCommand
command <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> SqlCommand(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"usp_MyQuery_Select"</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>._con);<br />
SqlDataAdapter adapter <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> SqlDataAdapter(command);<br />
DataSet ds <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> DataSet();<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">try</span><br />
{<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
this</span>._con.Open(); <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//unnecessary</span><br />
   adapter.Fill(ds);<br />
}<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">finally</span><br />
{<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
this</span>._con.Close(); <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//unnecessary</span><br />
}</span>
          </code>
        </p>
        <p>
          <font color="#0000ff">
            <strong>Do this...</strong>
          </font>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">SqlCommand
command <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> SqlCommand(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"usp_MyQuery_Select"</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>._con);<br />
SqlDataAdapter adapter <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> SqlDataAdapter(command);<br />
DataSet ds <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> DataSet();<br />
adapter.Fill(ds);</span>
        </p>
        <p>
        </p>
        <p>
If you track SqlDataAdapter's Fill() method in <a href="http://www.aisto.com/roeder/dotnet/">Lutz
Roeder's .NET Reflector</a>, you will see that it ends up at DbDataAdapter's FillFromCommand()
method. FillFromCommand() opens and closes the connection in a try-finally block.
Making this unnecessary in your own code. 
</p>
        <p>
          <font color="#0000ff">
            <strong>Disassembled from Reflector</strong>
          </font>
        </p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">private</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> FillFromCommand(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> data, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> startRecord, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> maxRecords, </span>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <br />
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
string</span> srcTable, IDbCommand command, CommandBehavior behavior)<br />
{<br />
   IDbConnection connection1 <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> DbDataAdapter.GetConnection(command, <span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Fill"</span>);<br />
   ConnectionState state1 <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> ConnectionState.Open;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
if</span> (MissingSchemaAction.AddWithKey == <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">base</span>.MissingSchemaAction)<br />
   {<br />
      behavior |= CommandBehavior.KeyInfo;<br />
   }<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
int</span> num1 <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
try</span><br />
   {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
try</span><br />
      {<br />
         DbDataAdapter.QuietOpen(connection1, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">out</span> state1);<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">        
using</span> (IDataReader reader1 <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> command.ExecuteReader(<br />
            behavior <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">|</span> CommandBehavior.SequentialAccess))<br />
         {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">           
if</span> (data <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">is</span> DataTable)<br />
            {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">              
return</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>.Fill((DataTable)
data, reader1);<br />
            }<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">           
return</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>.Fill((DataSet)
data, srcTable, reader1, startRecord, maxRecords);<br />
         }<br />
      }<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
finally</span><br />
      {<br />
         DbDataAdapter.QuietClose(connection1,
state1);<br />
      }<br />
   }<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
catch</span><br />
   {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
throw</span>;<br />
   }<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
return</span> num1;<br />
} </span>
        </p>
        <p>
        </p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=d245ba6e-1f02-4280-af8f-b9491101d6cc" />
      </body>
      <title>SqlDataAdapter.Fill() does not require SqlConnection Open() and Close()</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,d245ba6e-1f02-4280-af8f-b9491101d6cc.aspx</guid>
      <link>http://offroadcoder.com/2005/08/10/SqlDataAdapterFillDoesNotRequireSqlConnectionOpenAndClose.aspx</link>
      <pubDate>Wed, 10 Aug 2005 01:59:40 GMT</pubDate>
      <description>&lt;p&gt;
I have read too many articles showing the connection being opened and closed around
a DataAdapter Fill() as in the code below. It does no harm, but it not necessary. 
&lt;/p&gt;
&lt;p&gt;
&lt;strong&gt;&lt;font color=#0000ff&gt;Don't do this...&lt;/font&gt;&lt;/strong&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;code&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SqlCommand
command &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; SqlCommand(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"usp_MyQuery_Select"&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;._con);&lt;br&gt;
SqlDataAdapter adapter &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; SqlDataAdapter(command);&lt;br&gt;
DataSet ds &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; DataSet();&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;try&lt;/span&gt;
&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
this&lt;/span&gt;._con.Open(); &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//unnecessary&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; adapter.Fill(ds);&lt;br&gt;
}&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;finally&lt;/span&gt;
&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
this&lt;/span&gt;._con.Close(); &lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//unnecessary&lt;/span&gt;
&lt;br&gt;
}&lt;/span&gt; &lt;/code&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff&gt;&lt;strong&gt;Do this...&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;SqlCommand
command &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; SqlCommand(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"usp_MyQuery_Select"&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;._con);&lt;br&gt;
SqlDataAdapter adapter &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; SqlDataAdapter(command);&lt;br&gt;
DataSet ds &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; DataSet();&lt;br&gt;
adapter.Fill(ds);&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;p&gt;
If you track SqlDataAdapter's Fill() method in &lt;a href="http://www.aisto.com/roeder/dotnet/"&gt;Lutz
Roeder's .NET Reflector&lt;/a&gt;, you will see that it ends up at DbDataAdapter's FillFromCommand()
method. FillFromCommand() opens and closes the connection in a try-finally block.
Making this unnecessary in your own code. 
&lt;/p&gt;
&lt;p&gt;
&lt;font color=#0000ff&gt;&lt;strong&gt;Disassembled from Reflector&lt;/strong&gt;&lt;/font&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;private&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; FillFromCommand(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; data, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; startRecord, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; maxRecords, &lt;/span&gt;&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
string&lt;/span&gt; srcTable, IDbCommand command, CommandBehavior behavior)&lt;br&gt;
{&lt;br&gt;
&amp;nbsp;&amp;nbsp; IDbConnection connection1 &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; DbDataAdapter.GetConnection(command, &lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Fill"&lt;/span&gt;);&lt;br&gt;
&amp;nbsp;&amp;nbsp; ConnectionState state1 &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; ConnectionState.Open;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
if&lt;/span&gt; (MissingSchemaAction.AddWithKey == &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;base&lt;/span&gt;.MissingSchemaAction)&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; behavior |= CommandBehavior.KeyInfo;&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
int&lt;/span&gt; num1 &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
try&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
try&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DbDataAdapter.QuietOpen(connection1, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;out&lt;/span&gt; state1);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
using&lt;/span&gt; (IDataReader reader1 &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; command.ExecuteReader(&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; behavior &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;|&lt;/span&gt; CommandBehavior.SequentialAccess))&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
if&lt;/span&gt; (data &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;is&lt;/span&gt; DataTable)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
return&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;.Fill((DataTable)
data, reader1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
return&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;.Fill((DataSet)
data, srcTable, reader1, startRecord, maxRecords);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
finally&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DbDataAdapter.QuietClose(connection1,
state1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
catch&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
throw&lt;/span&gt;;&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
return&lt;/span&gt; num1;&lt;br&gt;
} &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=d245ba6e-1f02-4280-af8f-b9491101d6cc" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,d245ba6e-1f02-4280-af8f-b9491101d6cc.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=aa2eccfe-a297-41bd-8331-eaddf6e3a82e</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,aa2eccfe-a297-41bd-8331-eaddf6e3a82e.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=aa2eccfe-a297-41bd-8331-eaddf6e3a82e</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Most developers cringe when they hear the words "Coding Standards." A developers coding
style defines them. Their style has been molded over the years into what it is today.
Telling a developer that their way is not the "right way" is difficult and sometimes
taken personally.
</p>
        <p>
Coding standards are, however, an important part of every project. Deciding on coding
standards often happens <u>too late</u> when there is <u>too much</u> code in <u>too
many</u> different styles. It is important to every developer to have and appreciate
standards because <u>we will</u> "inherit" someone elses code. It would be nice if
we could read it.
</p>
        <p>
I recently got the chance to review David McCarter's 53-page book titled "VSDN Tips
&amp; Tricks .NET Coding Standards." I loved it! It combines coding standards from
Microsoft and other sources (not to mention common sense) into one easy-to-read "guide."
Its focus is on Visual Studio .NET 2003 with v1.1 of the Framework. <i>That doesn't
mean that you Beta 2 snobs can't read it!</i> It provides C# :) and VB :( examples
and covers a variety of topics from indentation and word choice to event and exception
handling.
</p>
        <p>
I have seen most of the suggested standards in various other white papers and on MSDN.
It's a great book to compare against your company or personal coding standards. Not
everything in this book will make sense to every shop. Personally, I found only a
few items that I don't already use (one of which being the use of Event Accessors
instead of using public event member variables.)
</p>
        <p>
Definitely worth reading. Find out more at <a href="http://www.vsdntips.com">http://www.vsdntips.com</a></p>
        <img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=aa2eccfe-a297-41bd-8331-eaddf6e3a82e" />
      </body>
      <title>VSDN Tips &amp; Tricks .NET Coding Standards</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,aa2eccfe-a297-41bd-8331-eaddf6e3a82e.aspx</guid>
      <link>http://offroadcoder.com/2005/08/06/VSDNTipsTricksNETCodingStandards.aspx</link>
      <pubDate>Sat, 06 Aug 2005 02:00:17 GMT</pubDate>
      <description>&lt;p&gt;
Most developers cringe when they hear the words "Coding Standards." A developers coding
style defines them. Their style has been molded over the years into what it is today.
Telling a developer that their way is not the "right way" is difficult and sometimes
taken personally.
&lt;/p&gt;
&lt;p&gt;
Coding standards are, however, an important part of every project. Deciding on coding
standards often happens &lt;u&gt;too late&lt;/u&gt; when there is &lt;u&gt;too much&lt;/u&gt; code in &lt;u&gt;too
many&lt;/u&gt; different styles. It is important to every developer to have and appreciate
standards because &lt;u&gt;we will&lt;/u&gt; "inherit" someone elses code. It would be nice if
we could read it.
&lt;/p&gt;
&lt;p&gt;
I recently got the chance to review David McCarter's 53-page book titled "VSDN Tips
&amp;amp; Tricks .NET Coding Standards." I loved it! It combines coding standards from
Microsoft and other sources (not to mention common sense) into one easy-to-read "guide."
Its focus is on Visual Studio .NET 2003 with v1.1 of the Framework. &lt;i&gt;That doesn't
mean that you Beta 2 snobs can't read it!&lt;/i&gt; It provides C# :) and VB :( examples
and covers a variety of topics from indentation and word choice to event and exception
handling.
&lt;/p&gt;
&lt;p&gt;
I have seen most of the suggested standards in various other white papers and on MSDN.
It's a great book to compare against your company or personal coding standards. Not
everything in this book will make sense to every shop. Personally, I found only a
few items that I don't already use (one of which being the use of Event Accessors
instead of using public event member variables.)
&lt;/p&gt;
&lt;p&gt;
Definitely worth reading. Find out more at &lt;a href="http://www.vsdntips.com"&gt;http://www.vsdntips.com&lt;/a&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=aa2eccfe-a297-41bd-8331-eaddf6e3a82e" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,aa2eccfe-a297-41bd-8331-eaddf6e3a82e.aspx</comments>
      <category>.NET Framework</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=e90626ae-090e-4a30-abec-d5ef86b35e63</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,e90626ae-090e-4a30-abec-d5ef86b35e63.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=e90626ae-090e-4a30-abec-d5ef86b35e63</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
Devloping an application using the System.Web.Mail.SmtpMail class to send email should
not be as difficult as it always is. <a href="http://www.systemwebmail.com/">http://www.systemwebmail.com</a> has
a detailed and helpful collection of possible fixes for the dreaded "Could not access
'CDO.Message' Object" Exception. The one I most recently experienced was not listed.
We thought it could be a relaying perrmission or something related to setting the
SmtpServer name. It turned out to be a Windows 2003-specific problem related to Fixed
Identity Impersonation for high security (isolated) applications using a low-privilege
user account specific to the application. 
</p>
        <p>
The exception you see, almost always the useless excpetion, "Could not access 'CDO.Message'
Object", does not help you to troubleshoot. As you can see in the code below, generated
using <a href="http://www.aisto.com/roeder/dotnet/">Lutz Roeder's .NET Reflector</a>,
called by SmtpMail.Send(), the real exception is never thrown. It will throw the "Could
not access 'CDO.Message' Object" exception no matter what exception was caught.
</p>
        <p>
          <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">internal</span>
            <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> CallMethod(<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span> obj, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">string</span> methodName, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">object</span>[]
args)<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
object</span> obj1;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
try</span><br />
   {<br />
      obj1 <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> SmtpMail.LateBoundAccessHelper.CallMethod(<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">        
this</span>.LateBoundType, obj, methodName, args);<br />
   }<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
catch</span> (Exception exception1)<br />
   {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
throw</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">new</span> HttpException(HttpRuntime.FormatResourceString(<br /><span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">        
"Could_not_access_object"</span>, <span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>._progId),
exception1);<br />
   }<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
return</span> obj1;<br />
} </span>
        </p>
        <p>
The best advice given by <a href="http://www.systemwebmail.com/">http://www.systemwebmail.com</a> is
to loop through all of the InnerExceptions thrown when the useless exception is thrown.
This will allow you to see the true exception and determine how to fix the problem.
</p>
        <p>
In Windows 2003, you can have each application run in its own application pool using
an application-specific user account. Depending on the privileges and group memberships
of this user account, it may or may not have the correct permissions to be able to
send mail using the machine's SMTP server. To send mail, the user account needs to
have write permissions on the directory named C:\inetpub\mailroot\Pickup. With those
permissions, System.Web.Mail (.NET wrapper around CDOSys.dll) will create a .eml file
in that directory. The mail gets sent when the SMTP service, with SYSTEM privileges,
sees this file and sends the email.
</p>
        <p>
If granting the necessary permissions is not possible for your application's user
account, you can bypass System.Web.Mail's default CDO send method, using the Pickup
directory, altogether. You can modify the mail message's configuration fields to set
the values used by CDO, regardless of the values set by System.Web.Mail.
</p>
        <p>
You can send the mail message by going through the smtp port instead of the pickup
directory (default). Change the <i>sendusing</i> configuration field from 0 (default
- pickup directory) to 1 (port). 
</p>
        <code>
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">mailMsg.Fields.Add(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://schemas.microsoft.com/cdo/configuration/sendusing"</span>,
1);</span>
          </p>
        </code>
        <p>
          <code>
          </code>If you still cannot send email, try using other CDO configuration fields
to bypass the System.Web.Mail settings. Here are some other configuration fields.
I would try them in this order: 
</p>
        <code>
          <p>
            <span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">
              <span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">//
smtpauthenticate values (2=NTLM, 1=Basic, 0=None)</span>
              <br />
mailMsg.Fields.Add(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"</span>,
1);<br />
mailMsg.Fields.Add(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://schemas.microsoft.com/cdo/configuration/smtpserverport"</span>,
25);<br />
mailMsg.Fields.Add(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://schemas.microsoft.com/cdo/configuration/smtpserver"</span>,
mailServer);<br />
mailMsg.Fields.Add(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://schemas.microsoft.com/cdo/configuration/sendusername"</span>,
username);<br />
mailMsg.Fields.Add(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://schemas.microsoft.com/cdo/configuration/sendpassword"</span>,
pw);<br />
mailMsg.Fields.Add(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"</span>,
10); </span>
          </p>
        </code>
        <hr />
Of course, all of this is only possible if you are using .NET Framework 1.1. The Fields
property of the MailMessage class was not exposed in version 1.0 of the framework. 
<p></p><img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=e90626ae-090e-4a30-abec-d5ef86b35e63" /></body>
      <title>System.Web.Mail issues in Windows Server 2003</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,e90626ae-090e-4a30-abec-d5ef86b35e63.aspx</guid>
      <link>http://offroadcoder.com/2005/06/05/SystemWebMailIssuesInWindowsServer2003.aspx</link>
      <pubDate>Sun, 05 Jun 2005 02:02:18 GMT</pubDate>
      <description>&lt;p&gt;
Devloping an application using the System.Web.Mail.SmtpMail class to send email should
not be as difficult as it always is. &lt;a href="http://www.systemwebmail.com/"&gt;http://www.systemwebmail.com&lt;/a&gt; has
a detailed and helpful collection of possible fixes for the dreaded "Could not access
'CDO.Message' Object" Exception. The one I most recently experienced was not listed.
We thought it could be a relaying perrmission or something related to setting the
SmtpServer name. It turned out to be a Windows 2003-specific problem related to Fixed
Identity Impersonation for high security (isolated) applications using a low-privilege
user account specific to the application. 
&lt;p&gt;
The exception you see, almost always the useless excpetion, "Could not access 'CDO.Message'
Object", does not help you to troubleshoot. As you can see in the code below, generated
using &lt;a href="http://www.aisto.com/roeder/dotnet/"&gt;Lutz Roeder's .NET Reflector&lt;/a&gt;,
called by SmtpMail.Send(), the real exception is never thrown. It will throw the "Could
not access 'CDO.Message' Object" exception no matter what exception was caught.
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;internal&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; CallMethod(&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt; obj, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;string&lt;/span&gt; methodName, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;object&lt;/span&gt;[]
args)&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
object&lt;/span&gt; obj1;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
try&lt;/span&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; obj1 &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; SmtpMail.LateBoundAccessHelper.CallMethod(&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
this&lt;/span&gt;.LateBoundType, obj, methodName, args);&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
catch&lt;/span&gt; (Exception exception1)&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
throw&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;new&lt;/span&gt; HttpException(HttpRuntime.FormatResourceString(&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
"Could_not_access_object"&lt;/span&gt;, &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;._progId),
exception1);&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
return&lt;/span&gt; obj1;&lt;br&gt;
} &lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
The best advice given by &lt;a href="http://www.systemwebmail.com/"&gt;http://www.systemwebmail.com&lt;/a&gt; is
to loop through all of the InnerExceptions thrown when the useless exception is thrown.
This will allow you to see the true exception and determine how to fix the problem.
&lt;/p&gt;
&lt;p&gt;
In Windows 2003, you can have each application run in its own application pool using
an application-specific user account. Depending on the privileges and group memberships
of this user account, it may or may not have the correct permissions to be able to
send mail using the machine's SMTP server. To send mail, the user account needs to
have write permissions on the directory named C:\inetpub\mailroot\Pickup. With those
permissions, System.Web.Mail (.NET wrapper around CDOSys.dll) will create a .eml file
in that directory. The mail gets sent when the SMTP service, with SYSTEM privileges,
sees this file and sends the email.
&lt;/p&gt;
&lt;p&gt;
If granting the necessary permissions is not possible for your application's user
account, you can bypass System.Web.Mail's default CDO send method, using the Pickup
directory, altogether. You can modify the mail message's configuration fields to set
the values used by CDO, regardless of the values set by System.Web.Mail.
&lt;/p&gt;
&lt;p&gt;
You can send the mail message by going through the smtp port instead of the pickup
directory (default). Change the &lt;i&gt;sendusing&lt;/i&gt; configuration field from 0 (default
- pickup directory) to 1 (port). 
&lt;/p&gt;
&lt;code&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;mailMsg.Fields.Add(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://schemas.microsoft.com/cdo/configuration/sendusing"&lt;/span&gt;,
1);&lt;/span&gt;
&lt;/p&gt;
&lt;/code&gt; 
&lt;p&gt;
&lt;code&gt;&lt;/code&gt;If you still cannot send email, try using other CDO configuration fields
to bypass the System.Web.Mail settings. Here are some other configuration fields.
I would try them in this order: 
&lt;/p&gt;
&lt;code&gt; 
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: green; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;//
smtpauthenticate values (2=NTLM, 1=Basic, 0=None)&lt;/span&gt;
&lt;br&gt;
mailMsg.Fields.Add(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpauthenticate"&lt;/span&gt;,
1);&lt;br&gt;
mailMsg.Fields.Add(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpserverport"&lt;/span&gt;,
25);&lt;br&gt;
mailMsg.Fields.Add(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpserver"&lt;/span&gt;,
mailServer);&lt;br&gt;
mailMsg.Fields.Add(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://schemas.microsoft.com/cdo/configuration/sendusername"&lt;/span&gt;,
username);&lt;br&gt;
mailMsg.Fields.Add(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://schemas.microsoft.com/cdo/configuration/sendpassword"&lt;/span&gt;,
pw);&lt;br&gt;
mailMsg.Fields.Add(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout"&lt;/span&gt;,
10); &lt;/span&gt;
&lt;/p&gt;
&lt;/code&gt; 
&lt;hr&gt;
Of course, all of this is only possible if you are using .NET Framework 1.1. The Fields
property of the MailMessage class was not exposed in version 1.0 of the framework. 
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=e90626ae-090e-4a30-abec-d5ef86b35e63" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,e90626ae-090e-4a30-abec-d5ef86b35e63.aspx</comments>
      <category>ASP.NET</category>
      <category>C#</category>
    </item>
    <item>
      <trackback:ping>http://offroadcoder.com/Trackback.aspx?guid=6fc7ac74-39b7-480c-80d5-6f8b77fa66e4</trackback:ping>
      <pingback:server>http://offroadcoder.com/pingback.aspx</pingback:server>
      <pingback:target>http://offroadcoder.com/PermaLink,guid,6fc7ac74-39b7-480c-80d5-6f8b77fa66e4.aspx</pingback:target>
      <dc:creator>Scott Klueppel</dc:creator>
      <georss:point>30.109017 -81.497099</georss:point>
      <wfw:commentRss>http://offroadcoder.com/SyndicationService.asmx/GetEntryCommentsRss?guid=6fc7ac74-39b7-480c-80d5-6f8b77fa66e4</wfw:commentRss>
      <body xmlns="http://www.w3.org/1999/xhtml">
        <p>
DropDownLists within a Repeater appear to lose or forget which item is selected before
the page loads. This is not the case. Dynamically created DropDownLists inside of
a Repeater create a rare obstacle. The SelectedItem is not being lost or forgotten.
It only appears that way because the OnDataBinding event for the DropDownList is being
called twice. Only when the RepeaterItem containing the DropDownList calls its own
DataBind method is the data actually bound to the DropDownList. Consider the following
code: 
</p>
        <p>
          <code>
            <font size="3">
              <font size="2">
                <font color="green">// UsingDropDownLists.aspx</font>
                <br />
115 <font color="blue">&lt;</font><font color="brown">asp:Repeater</font><font color="red">id</font><font color="blue">="rptOne"</font><font color="red">runat</font><font color="blue">="server"</font><font color="red">OnItemCreated</font><font color="blue">="rptOne_ItemCreated"/&gt;</font><br />
116  <font color="blue">&lt;</font><font color="brown">ItemTemplate</font><font color="blue">&gt;</font><br />
117    <font color="blue">&lt;</font><font color="brown">asp:Literal</font><font color="red">id</font><font color="blue">="litQuestion"</font><font color="red">runat</font><font color="blue">="server"</font><font color="blue">/&gt;</font><br />
118    <font color="blue">&lt;</font><font color="brown">asp:DropDownList</font><font color="red">id</font><font color="blue">="ddlResponse"</font><font color="red">runat</font><font color="blue">="server"</font><font color="blue">/&gt;</font><br />
119    <font color="blue">&lt;</font><font color="brown">br</font><font color="blue">/&gt;</font><br />
120  <font color="blue">&lt;/</font><font color="brown">ItemTemplate</font><font color="blue">&gt;</font><br />
121 <font color="blue">&lt;/</font><font color="brown">asp:Repeater</font><font color="blue">&gt;</font><br /><br /><font color="green">// UsingDropDownLists.aspx.cs</font><br />
211 <font color="blue">protected void</font> rptOne_ItemCreated(<font color="blue">object</font> sender,
RepeaterItemEventArgs e)<br />
212 {<br />
213   <font color="blue">if</font>(e.Item.DataItem != null)<br />
214   { 
<br />
215     MyClass myClass = sender <font color="blue">as</font> MyClass;<br />
216     (e.Item.FindControl("litQuestion") <font color="blue">as</font> Literal).Text
= myClass.Question;<br />
217     DropDownList ddl = e.Item.FindControl("ddlResponse") <font color="blue">as</font> DropDownList;<br />
218     ddl.DataSource = GetResponseList(myClass.AvailableResponses);<br />
219     ddl.Items.FindByValue(myClass.Response).Selected = <font color="blue">true</font>;<br />
220     ddl.DataBind();<br />
221     ddl.SelectedIndex = e.Item.ItemIndex%(ddl.Items.Count-1); <font color="darkgreen">//Random</font><br />
222   }<br />
223 }</font>
            </font>
          </code>
        </p>
Here is the sequence of events: 
<ol><li>
Page_Load 
</li><li>
Data Retrieval/Bind Data to Repeater 
</li><li>
Repeater's ItemCreated event fires for each RepeaterItem 
</li><li>
Data Retrieval/Bind Data to DropDownList 
</li><li>
OnDataBinding is fired from the DropDownList's DataBind() (line 220). However, if
you watch in debug mode, you will see that the DropDownList has no ListItems yet. 
</li><li>
DropDownList's SelectedIndex is chosen (line 221). Although, at this point, the DropDownList
still has no ListItems. The SelectedIndex call falls on deaf ears. 
</li><li>
RepeaterItem's DataBind method performs an actual DataBind on the DropDownList. There
are no selected items at this point. 
</li></ol><p>
RepeaterItem inherits from Control. If you look at Control's DataBind() method in <a href="http://www.aisto.com/roeder/dotnet/" target="_new">Lutz
Roeder's .NET Reflector</a>, you will see that it performs a DataBind on each of its
child controls. 
</p><p><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">public</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">virtual</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">void</span> DataBind()<br />
{<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
this</span>.OnDataBinding(EventArgs.Empty);<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">  
if</span> (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>._controls
!<span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">null</span>)<br />
   {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
string</span> text1 <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>._controls.SetCollectionReadOnly(<span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4">"Parent_collections_readonly"</span>);<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
int</span> num1 <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">this</span>._controls.Count;<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
for</span> (<span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">int</span> num2 <span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">=</span> 0;
num2 &lt; num1; num2++)<br />
      {<br /><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">         this</span>._controls[num2].DataBind();<br />
      }</span><br /><span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"><span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent">     
this</span>._controls.SetCollectionReadOnly(text1);<br />
   }<br />
}</span></p><p>
From this, we can see three things. 
</p><ol><li>
The only safe time to choose the SelectedItem is after the binding of all objects
within the Repeater. A perfect place to do this is in the RepeaterItem's PreRender
or in the Repeater's PreRender. You have access to the same bound object from RepeaterItem.DataItem,
and can find the DropDownList and choose the SelectedIndex, SelectedValue, or ddl.Items.FindByValue(response).Selected
= true; 
</li><li>
The DataBind() call (line 220) is completely unnecessary and leads the programmer
to believe that it has actually bound the data. This is untrue. Again, in debug mode,
you will see that by line 221, there are still zero ListItems in ddl.Items. 
</li><li>
The same obstacle will arise for all Controls derived from ListControl. This includes
CheckBoxList, DropDownList, ListBox, and RadioButtonList. The same solution will apply
to these controls within a Repeater. 
</li></ol><p></p><img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=6fc7ac74-39b7-480c-80d5-6f8b77fa66e4" /></body>
      <title>Why is my DropDownList losing the SelectedItem inside a Repeater?</title>
      <guid isPermaLink="false">http://offroadcoder.com/PermaLink,guid,6fc7ac74-39b7-480c-80d5-6f8b77fa66e4.aspx</guid>
      <link>http://offroadcoder.com/2004/10/17/WhyIsMyDropDownListLosingTheSelectedItemInsideARepeater.aspx</link>
      <pubDate>Sun, 17 Oct 2004 02:03:32 GMT</pubDate>
      <description>&lt;p&gt;
DropDownLists within a Repeater appear to lose or forget which item is selected before
the page loads. This is not the case. Dynamically created DropDownLists inside of
a Repeater create a rare obstacle. The SelectedItem is not being lost or forgotten.
It only appears that way because the OnDataBinding event for the DropDownList is being
called twice. Only when the RepeaterItem containing the DropDownList calls its own
DataBind method is the data actually bound to the DropDownList. Consider the following
code: 
&lt;p&gt;
&lt;code&gt;&lt;font size=3&gt;&lt;font size=2&gt;&lt;font color=green&gt;// UsingDropDownLists.aspx&lt;/font&gt;
&lt;br&gt;
115&amp;nbsp;&lt;font color=blue&gt;&amp;lt;&lt;/font&gt;&lt;font color=brown&gt;asp:Repeater&lt;/font&gt; &lt;font color=red&gt;id&lt;/font&gt;&lt;font color=blue&gt;="rptOne"&lt;/font&gt; &lt;font color=red&gt;runat&lt;/font&gt;&lt;font color=blue&gt;="server"&lt;/font&gt; &lt;font color=red&gt;OnItemCreated&lt;/font&gt;&lt;font color=blue&gt;="rptOne_ItemCreated"/&amp;gt;&lt;/font&gt;
&lt;br&gt;
116&amp;nbsp;&amp;nbsp;&lt;font color=blue&gt;&amp;lt;&lt;/font&gt;&lt;font color=brown&gt;ItemTemplate&lt;/font&gt;&lt;font color=blue&gt;&amp;gt;&lt;/font&gt;
&lt;br&gt;
117&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color=blue&gt;&amp;lt;&lt;/font&gt;&lt;font color=brown&gt;asp:Literal&lt;/font&gt; &lt;font color=red&gt;id&lt;/font&gt;&lt;font color=blue&gt;="litQuestion"&lt;/font&gt; &lt;font color=red&gt;runat&lt;/font&gt;&lt;font color=blue&gt;="server"&lt;/font&gt;&lt;font color=blue&gt;/&amp;gt;&lt;/font&gt;
&lt;br&gt;
118&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color=blue&gt;&amp;lt;&lt;/font&gt;&lt;font color=brown&gt;asp:DropDownList&lt;/font&gt; &lt;font color=red&gt;id&lt;/font&gt;&lt;font color=blue&gt;="ddlResponse"&lt;/font&gt; &lt;font color=red&gt;runat&lt;/font&gt;&lt;font color=blue&gt;="server"&lt;/font&gt;&lt;font color=blue&gt;/&amp;gt;&lt;/font&gt;
&lt;br&gt;
119&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color=blue&gt;&amp;lt;&lt;/font&gt;&lt;font color=brown&gt;br&lt;/font&gt;&lt;font color=blue&gt;/&amp;gt;&lt;/font&gt;
&lt;br&gt;
120&amp;nbsp;&amp;nbsp;&lt;font color=blue&gt;&amp;lt;/&lt;/font&gt;&lt;font color=brown&gt;ItemTemplate&lt;/font&gt;&lt;font color=blue&gt;&amp;gt;&lt;/font&gt;
&lt;br&gt;
121&amp;nbsp;&lt;font color=blue&gt;&amp;lt;/&lt;/font&gt;&lt;font color=brown&gt;asp:Repeater&lt;/font&gt;&lt;font color=blue&gt;&amp;gt;&lt;/font&gt;
&lt;br&gt;
&lt;br&gt;
&lt;font color=green&gt;// UsingDropDownLists.aspx.cs&lt;/font&gt;
&lt;br&gt;
211&amp;nbsp;&lt;font color=blue&gt;protected void&lt;/font&gt; rptOne_ItemCreated(&lt;font color=blue&gt;object&lt;/font&gt; sender,
RepeaterItemEventArgs e)&lt;br&gt;
212&amp;nbsp;{&lt;br&gt;
213&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;font color=blue&gt;if&lt;/font&gt;(e.Item.DataItem != null)&lt;br&gt;
214&amp;nbsp;&amp;nbsp;&amp;nbsp;{ 
&lt;br&gt;
215&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; MyClass myClass = sender &lt;font color=blue&gt;as&lt;/font&gt; MyClass;&lt;br&gt;
216&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; (e.Item.FindControl("litQuestion") &lt;font color=blue&gt;as&lt;/font&gt; Literal).Text
= myClass.Question;&lt;br&gt;
217&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; DropDownList ddl = e.Item.FindControl("ddlResponse") &lt;font color=blue&gt;as&lt;/font&gt; DropDownList;&lt;br&gt;
218&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ddl.DataSource = GetResponseList(myClass.AvailableResponses);&lt;br&gt;
219&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ddl.Items.FindByValue(myClass.Response).Selected = &lt;font color=blue&gt;true&lt;/font&gt;;&lt;br&gt;
220&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ddl.DataBind();&lt;br&gt;
221&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ddl.SelectedIndex = e.Item.ItemIndex%(ddl.Items.Count-1); &lt;font color=darkgreen&gt;//Random&lt;/font&gt;
&lt;br&gt;
222&amp;nbsp;&amp;nbsp;&amp;nbsp;}&lt;br&gt;
223&amp;nbsp;}&lt;/font&gt; &lt;/font&gt;&lt;/code&gt;
&lt;/p&gt;
Here is the sequence of events: 
&lt;ol&gt;
&lt;li&gt;
Page_Load 
&lt;li&gt;
Data Retrieval/Bind Data to Repeater 
&lt;li&gt;
Repeater's ItemCreated event fires for each RepeaterItem 
&lt;li&gt;
Data Retrieval/Bind Data to DropDownList 
&lt;li&gt;
OnDataBinding is fired from the DropDownList's DataBind() (line 220). However, if
you watch in debug mode, you will see that the DropDownList has no ListItems yet. 
&lt;li&gt;
DropDownList's SelectedIndex is chosen (line 221). Although, at this point, the DropDownList
still has no ListItems. The SelectedIndex call falls on deaf ears. 
&lt;li&gt;
RepeaterItem's DataBind method performs an actual DataBind on the DropDownList. There
are no selected items at this point. 
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
RepeaterItem inherits from Control. If you look at Control's DataBind() method in &lt;a href="http://www.aisto.com/roeder/dotnet/" target=_new&gt;Lutz
Roeder's .NET Reflector&lt;/a&gt;, you will see that it performs a DataBind on each of its
child controls.&amp;nbsp;
&lt;/p&gt;
&lt;p&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;public&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;virtual&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;void&lt;/span&gt; DataBind()&lt;br&gt;
{&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
this&lt;/span&gt;.OnDataBinding(EventArgs.Empty);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;
if&lt;/span&gt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;._controls
!&lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;null&lt;/span&gt;)&lt;br&gt;
&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
string&lt;/span&gt; text1 &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;._controls.SetCollectionReadOnly(&lt;span style="FONT-SIZE: 11px; COLOR: #666666; FONT-FAMILY: Courier New; BACKGROUND-COLOR: #e4e4e4"&gt;"Parent_collections_readonly"&lt;/span&gt;);&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
int&lt;/span&gt; num1 &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; &lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;this&lt;/span&gt;._controls.Count;&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
for&lt;/span&gt; (&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;int&lt;/span&gt; num2 &lt;span style="FONT-SIZE: 11px; COLOR: red; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;=&lt;/span&gt; 0;
num2 &amp;lt; num1; num2++)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;this&lt;/span&gt;._controls[num2].DataBind();&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;
&lt;br&gt;
&lt;span style="FONT-SIZE: 11px; COLOR: black; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&lt;span style="FONT-SIZE: 11px; COLOR: blue; FONT-FAMILY: Courier New; BACKGROUND-COLOR: transparent"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;
this&lt;/span&gt;._controls.SetCollectionReadOnly(text1);&lt;br&gt;
&amp;nbsp;&amp;nbsp; }&lt;br&gt;
}&lt;/span&gt;
&lt;/p&gt;
&lt;p&gt;
From this, we can see three things. 
&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
The only safe time to choose the SelectedItem is after the binding of all objects
within the Repeater. A perfect place to do this is in the RepeaterItem's PreRender
or in the Repeater's PreRender. You have access to the same bound object from RepeaterItem.DataItem,
and can find the DropDownList and choose the SelectedIndex, SelectedValue, or ddl.Items.FindByValue(response).Selected
= true; 
&lt;li&gt;
The DataBind() call (line 220) is completely unnecessary and leads the programmer
to believe that it has actually bound the data. This is untrue. Again, in debug mode,
you will see that by line 221, there are still zero ListItems in ddl.Items. 
&lt;li&gt;
The same obstacle will arise for all Controls derived from ListControl. This includes
CheckBoxList, DropDownList, ListBox, and RadioButtonList. The same solution will apply
to these controls within a Repeater. 
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;
&lt;/p&gt;
&lt;img width="0" height="0" src="http://offroadcoder.com/aggbug.ashx?id=6fc7ac74-39b7-480c-80d5-6f8b77fa66e4" /&gt;</description>
      <comments>http://offroadcoder.com/CommentView,guid,6fc7ac74-39b7-480c-80d5-6f8b77fa66e4.aspx</comments>
      <category>ASP.NET</category>
      <category>C#</category>
    </item>
  </channel>
</rss>