Friday, December 14, 2007

The "connection reset" problem

The Symptom:

I encountered a problem of "the connection between IE and the server was reset." The application couldn't download a file of dynamically generated data(without saving it the the disk) after about 20 seconds delay when user needs to locate a folder to save the file. It works fine if user saves the file immediately.


Similar Symptom:
"I am trying to download a file. When the file starts running I am getting the
following message:
IE unable to continue...The connection with the server was reset."
"I have seen this problem before and fixed it by reducing the RWin setting. This
means delving into the registry or getting a tweak utility to do it. Exactly how to
proceed depends on your OS."

Definition of RWIN:

(Receive WINdow) A TCP/IP setting that defines the size of the buffer that holds
incoming packets. In Windows, RWIN is set in the Registry.

Steps to modify RWIN with Window XP

I've found that Windows XP is largely self-tuning. Currently I'm running XP Pro and I get 600K download speeds box stock. So you might not wish to modify the RWIN size if your speed is acceptable.
However, If you do want to change your RWIN setting, I have found that the best starting modification to make is to add an entry in the registry that creates a receive window size of 64240.
To install this modification, Right-Click on this file WindowsNT2000XP-64240 RWIN.reg and select 'Open'.
Select 'Open' again and you will be asked if your are sure you want to install this information in the registry. Select 'Yes' and than re-boot your system at your convenience.
This file adds the TcpWindowSize entry to the registry and sets a value of 64240. It also adds the Tcp1323Opts entry and sets it to 0. Neither of these entries exist in the unmodified operating system.
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\TcpWindowSize\64240
HKEY_LOCAL_MACHINE\System\CurrentControlSet\Services\Tcpip\Parameters\Tcp1323Opts=0 To return your Windows XP computer back to the original settings Save This File to your desktop and than right-click on it and select install. This will remove both of the entries and it will be as if you never changed it - once you've re-booted your machine.
More on this:http://www.asksomeone.net/winxp.html

Enterprise Library Contrib

Enterprise Library

EntLib Contrib is just the newest release (released in September 2007) .
http://www.codeplex.com/entlib

The idea of Enterprise Library is to build reusable software blocks
to make .Net application more consistent, robust and to simplify
the development.

EntLib is built on top of .Net Framework. It is composed of a number
of blocks. Some blocks are depreciated in faver of the functionality of new .Net Framework version. The Security block, for example, is
depreciated in favor of the Membership in .Net 2.0.


The blocks include:

  • Caching
  • Data Access (now called Repositary Factory)
  • Logging
  • Exception Handling
  • Cryptography
These blocks are built on top the following three core components:



  • Config Helpers Design
  • Object Builder
  • Instrumentation
Videos
Tom Hollander' blog provided three videos about Enterprise
Libraryhttp://blogs.msdn.com/tomholl/archive/2007/04/10/enterprise-library-the-videos.aspx

Introduction of Repository Factory

As part of Patterns and Practices, Repository Factory is a new
version of Data Access Guidance Factory. It was part of the Web
Service Factory and the team makes it a seperate package so that
it can be used generally.

Repository Factory is a package that automates the coding to map
database repository to entity classes. It is designated to
automate the domain model which most applications have.
However, Reporsitory Factory is not intended to be a full-
fledged ORM solution, but rather a light weight code generator
for most hand-coding effort in building domain model objects
and persist them to a database.
The following links to Microsoft Repository Factory Demo - MSN
Videohttp://video.msn.com/video.aspx/?mkt=en-us&vid=61ed607a-fd42-
48cb-bf8f-14cbf921a26f&wa=wsignin1.0

Exception HandlingA "Exception Policy" maps a type of exception to an action.
e.g.Type ApplicationException should be loggedSqlClientException should be caught and wrapped into
DataLayerException and rethrownSecurityException should be replaced with AccessDeniedException
and re-thrown

The actions inlude:LoggingWrappingReplacingand other custom actions
the code is like:
try{
// some code}catch(Exception ex){if(ExceptionPolicy.HandleException(ex, "DataLayer")){throw;} }

Thursday, December 13, 2007

Using design patterns in .Net coding

Using patterns deliberately in coding is always a good practise and an important skill, no matter what language you use. That is because the nature of pattern concept and idea. Patterns are designated to solve common problems and proved effective in solving different kind of problems without tieing with a specific language, instead it is more related with a problem of conceptual circumstance.

Learning Tree International is a leading educator for technology and management professionals. From the following page, I can follow their footsteps to sniff what's new and what's important in practice

http://www.learningtree.com/courses/511.htm