use Activator.CreateInstance to dynamically load the concrete class and avoid Circular references

I have a Factory class that creates number of classes to handle different XML responses, returned by Web Service. All of them are derived from some base class GwsResponse and created depending on the top name element name.
Previously factory and all created object classes were located in the same DLL.
Now we need to increase number of handled responses, but we want new classes to create in separate extension DLL. 

We are going to use Activator.CreateInstance to dynamically load the concrete class and avoid Circular references

The names of classes and assembly will be defind in config file.

The approach is well described in the thread:    

Circular references not possible?

Similar idea suggested in Creating an object dynamically using Reflection and running in a seperate thread

 

Links about Dependency Injection (pointed by TheCPUWizard)

Design Patterns Dependency Injection(MSDN Magazine, September 2005)

Unity competitors discussin on forum and post Microsoft releases Unity, an IoC library

 
 

Controls with the same name in GridView Templates

I've created the GridView with templates like the following:
       <asp:TemplateField SortExpression="Date1">

            <AlternatingItemTemplate>

                <asp:CheckBox ID="chkSelected" runat="server" />

            </AlternatingItemTemplate>

        </asp:TemplateField>

        <asp:TemplateField SortExpression="Date2">

            <AlternatingItemTemplate>

                <asp:CheckBox ID="chkSelected" runat="server" />

            </AlternatingItemTemplate>

        </asp:TemplateField>

On runtime it cause the error:
Message : Multiple controls with the same ID 'chkSelected' were found. FindControl requires that controls have unique IDs.
Type : System.Web.HttpException, System.Web, Version=
2.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
Message : Multiple controls with the same ID 'chkSelected' were found. FindControl requires that controls have unique IDs.
Source : System.Web
ErrorCode : -2147467259
Stack Trace : at System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls)
at System.Web.UI.Control.FillNamedControlsTable(Control namingContainer, ControlCollection controls)
at System.Web.UI.Control.EnsureNamedControlsTable()
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Control.FindControl(String id, Int32 pathOffset)
at System.Web.UI.Page.FindControl(String id)
at System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)

The problem explained on forum "GridViewRow is the naming container in GridView, not individual TableCell.
 
I had to use Dynamic Template columns based on  page http://www.webswapp.com/codesamples/viewsource.aspx?file=~/codesamples/aspnet20/itemplate/checkboxtemplate.cs
Note that in that example the CheckBoxTemplate class declared as implemented INamingContainer.
It causes expectation, that generated cell is naming container, which is not correct.
Because template is not derived from Control, specifying INamingContainer interface has no effect and should be removed.
 
Similar templates are described in

Error: control with id ... could not be located or a different control is assigned to the same ID after postback

Our application has the intermittent (not too often,but can be 10-20 per day) errors like the following:
An error has occurred because a control with id 'grdComplaints$ctl04$ctl00' could not be located or a different control is assigned to the same ID after postback. If the ID is not assigned, explicitly set the ID property of controls that raise postback events to avoid this error.
 System.Web.UI.Page.ProcessPostData(NameValueCollection postData, Boolean fBeforeLoad) +877
   System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
I've tried advice from http://p2p.wrox.com/TopicIndex/45979.htm  -
  "EnableViewState Property was set to 'False' when i change it to 'True' it becomes functional."
but it didn't eliminate errors.
Not sure, how to make the problem reproducible. I have some suspicion that it is relatted to An error "An entry with the same key already exists" when assigning ImageButton.ImageUrl
«May»
SunMonTueWedThuFriSat
27282930123
45678910
11121314151617
18192021222324
25262728293031
1234567