SQL Server Protocol error in TDS stream Communication link failure TCP Provider: An existing connection was forcibly closed by the remote host

Recently ran into an issue with long running sql queries that used TCP to communicate between different SQL Server servers.  We sporatically noticed the below errors and SQL job failures for jobs that ran long running sql queries.

Error: 2009-09-28 08:43:40.62     Code: 0xC0202009     Source:      Description: SSIS Error Code DTS_E_OLEDBERROR.  An OLE DB error has occurred. Error code: 0x80004005.  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Protocol error in TDS stream".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Communication link failure".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "TCP Provider: An existing connection was forcibly closed by the remote host.  ".  An OLE DB record is available.  Source: "Microsoft SQL Native Client"  Hresult: 0x80004005  Description: "Communication link failure".  An OLE DB record is ...  The package execution fa...  The step failed.

After some research, the below KB article outlines that TCP Chimney may be the cause.  Turns out, TCP Chimney may require an update the your NIC drivers.  

http://support.microsoft.com/kb/945977

We have not had the chance to upgrade our drivers, but we did disable TCP Chimney and that eliminated the error. To disable, issue the below statement at the command prompt (does not require a restart):

Netsh int ip set chimney DISABLED;

Need a developer, architect or manager? I am available - email me at [email protected]

.NET how to set the background color of a bitmap

I was struggling with this for a while...how to set the background of a bitmap.  I read a few suggestions, but none worked for me. 

My need was to set the background of the image to white, crop it, with the end result that after cropping, the background be set to white.

To do this, I used the Clear method on the Graphics class...essentially this sets the background.

 

Graphics grPhoto = Graphics.FromImage(bmpImage);

grPhoto.Clear(Color.White);

grPhoto.InterpolationMode = InterpolationMode.HighQualityBicubic;

grPhoto.DrawImage(imgPhoto,
                new Rectangle(destX, destY, destWidth, destHeight),
                new Rectangle(sourceX, sourceY, sourceWidth, sourceHeight),
                GraphicsUnit.Pixel);

            grPhoto.Dispose();

System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to

We were gettign an error with one of our WCF services "System.ServiceModel.CommunicationException: An error occurred while receiving the HTTP response to..." and needed to get additional information on the problem.  Below are steps to use the built in diagnostics with WCF to find out more info for the error above as well as the overall health of your service.

  1. Add to your web.config:

     <system.diagnostics>
        <sources>
          <source name="System.ServiceModel.MessageLogging">
            <listeners>
              <add name="messages"
              type="System.Diagnostics.XmlWriterTraceListener"
              initializeData="D:\LogFiles\SalesOrderTrackingService\messages.svclog" />
            </listeners>
          </source>
        </sources>
      </system.diagnostics>

    <system.serviceModel>
        <diagnostics>
          <messageLogging
               logEntireMessage="true"
               logMalformedMessages="false"
               logMessagesAtServiceLevel="true"
               logMessagesAtTransportLevel="false"
               maxMessagesToLog="3000"
               maxSizeOfMessageToLog="2000"/>
        </diagnostics>
    ...
  2. Create the necessary folder and ensure the security is set so IIS/ASP.NET can write to the log file
  3. Use the SvcTraceViewer.exe application to view your log file

    This tool can be found in the SDK directory...for me, this was C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin