Last post Oct 04, 2011 02:52 PM by todo1979
Oct 04, 2011 09:52 AM|todo1979|LINK
Hi to all,
I'm facing an issue here and I really don't know how to deal with it. I start the project with 2 browsers, and after loading, I press the start button almost at the same time for both browsers. The application uses values from controls I have on the page,
sends them to other webservices (in async mode) that belong to other sites and receives values from them. After that, a dataset table is created and populated with the results and then a gridview is displaying the results. Now, what happens is that the datatable
is getting mixed values from both processes, ... and the application is not running for 2 independent users but for 1, just immagine 10 clients running my application and each one receiving results that should belong to each browser.
Now, when a datatable row is created almost every time I get this error:
Server Error in '/asp' Application.
An item with the same key has already been added.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.ArgumentException: An item with the same key has already been added.
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
[ArgumentException: An item with the same key has already been added.]
System.ThrowHelper.ThrowArgumentException(ExceptionResource resource) +52
System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add) +9382923
System.Data.DataView.UpdateIndex(Boolean force, Boolean fireEvent) +315
System.Data.DataView.UpdateIndex(Boolean force) +12
System.Data.DataView.SetIndex2(String newSort, DataViewRowState newRowStates, IFilter newRowFilter, Boolean fireEvent) +113
_Default.Button10_Click(Object sender, EventArgs e) +1484
_Default.OK_Button_Click(Object sender, EventArgs e) +2171
System.Web.UI.WebControls.Button.OnClick(EventArgs e) +113
System.Web.UI.WebControls.Button.RaisePostBackEvent(String eventArgument) +112
System.Web.UI.WebControls.Button.System.Web.UI.IPostBackEventHandler.RaisePostBackEvent(String eventArgument) +10
System.Web.UI.Page.RaisePostBackEvent(IPostBackEventHandler sourceControl, String eventArgument) +13
System.Web.UI.Page.RaisePostBackEvent(NameValueCollection postData) +36
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +5325
Any idea how to syncronize the sessions, each one to run independently?
Oct 04, 2011 11:03 AM|markfitzme|LINK
What is the key? There is some value in there that is marked as a unique key in the dataview most likely, but there are duplicate values. It could just be that the field you chose as the primary key for the datasource is actually invalid as it has duplicates.
Oct 04, 2011 02:52 PM|todo1979|LINK
When the application receives a value from a webservice it adds a row to the datatable like:
Dim row As DataRow = DS.Tables.Item("Table1").NewRow
row.Item("name") = "webservice1"
row.Item("value") = value_from_webservice1
and if first the other browser received a value from webservice1, the second browser can't add the same row because it allready exists