![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
I have an asp.net web app that is coded to use caching. The intermittent error that I see is the following: ======================= System.Data.DuplicateNameException: A DataTable named 'REG_EmailOptions' already belongs to this DataSet. at System.Data.DataTableCollection.RegisterName(Strin g name) at System.Data.DataTableCollection.BaseAdd(DataTable table) at System.Data.DataTableCollection.Add(DataTable table) ======================= The fact that it is intermittent makes me think the caching is working, and the error only occurs whenever the objects need to be re-cached. I've implemented the use of the cache in other areas of the site, but this is the only one that is throwing an exception. This problem also cannot be reproduced in dev, only in production, in a server farm environment. Perhaps the load is required to trigger the error. Can anyone see anything fundamentally wrong with what they see here? Thanks in advance for thoughts and suggestions. try { dsEmailOptionsAndSubOptions = (DataSet)HttpContext.Current.Cache["dsEmailOptionsAndSubOptions"]; if (dsEmailOptionsAndSubOptions == null) { dsEmailOptions = (DataSet)HttpContext.Current.Cache["dsEmailOptions"]; dsEmailSubOptions = (DataSet)HttpContext.Current.Cache["dsEmailSubOptions"]; if (dsEmailOptions == null || dsEmailSubOptions == null) { dsEmailOptions = GetEmailOptions(); dsEmailSubOptions = GetEmailSubOptions(); } dsEmailOptions.Tables.Add( dsEmailSubOptions.Tables["REG_EmailOptions"].Copy() ); dsEmailOptions.Relations.Add("SubOptions",dsEmailO ptions.Tables["REG_Emails"].Columns["EmailID"], dsEmailOptions.Tables["REG_EmailOptions"].Columns["EmailID"]); dsEmailOptionsAndSubOptions = dsEmailOptions.Copy(); if (bUseCache) HttpContext.Current.Cache.Insert( "dsEmailOptionsAndSubOptions", dsEmailOptionsAndSubOptions ); } return dsEmailOptionsAndSubOptions; } |
#3
| |||
| |||
|
|
is dsemailoptions dataset global? where is that code running? in global.asax? if both these conditions are true, you will need to protect access to the dataset by locking it when you update it. -- Regards, Alvin Bruney - ASP.NET MVP [Shameless Author Plug] The Microsoft Office Web Components Black Book with .NET Now available @ www.lulu.com/owc, Amazon.com etc "Lefty" <Lefty (AT) discussions (DOT) microsoft.com> wrote in message news:B5928839-EE7F-4A7F-98A5-0E0549B39B4C (AT) microsoft (DOT) com... I have an asp.net web app that is coded to use caching. The intermittent error that I see is the following: ======================= System.Data.DuplicateNameException: A DataTable named 'REG_EmailOptions' already belongs to this DataSet. at System.Data.DataTableCollection.RegisterName(Strin g name) at System.Data.DataTableCollection.BaseAdd(DataTable table) at System.Data.DataTableCollection.Add(DataTable table) ======================= The fact that it is intermittent makes me think the caching is working, and the error only occurs whenever the objects need to be re-cached. I've implemented the use of the cache in other areas of the site, but this is the only one that is throwing an exception. This problem also cannot be reproduced in dev, only in production, in a server farm environment. Perhaps the load is required to trigger the error. Can anyone see anything fundamentally wrong with what they see here? Thanks in advance for thoughts and suggestions. try { dsEmailOptionsAndSubOptions = (DataSet)HttpContext.Current.Cache["dsEmailOptionsAndSubOptions"]; if (dsEmailOptionsAndSubOptions == null) { dsEmailOptions = (DataSet)HttpContext.Current.Cache["dsEmailOptions"]; dsEmailSubOptions = (DataSet)HttpContext.Current.Cache["dsEmailSubOptions"]; if (dsEmailOptions == null || dsEmailSubOptions == null) { dsEmailOptions = GetEmailOptions(); dsEmailSubOptions = GetEmailSubOptions(); } dsEmailOptions.Tables.Add( dsEmailSubOptions.Tables["REG_EmailOptions"].Copy() ); dsEmailOptions.Relations.Add("SubOptions",dsEmailO ptions.Tables["REG_Emails"].Columns["EmailID"], dsEmailOptions.Tables["REG_EmailOptions"].Columns["EmailID"]); dsEmailOptionsAndSubOptions = dsEmailOptions.Copy(); if (bUseCache) HttpContext.Current.Cache.Insert( "dsEmailOptionsAndSubOptions", dsEmailOptionsAndSubOptions ); } return dsEmailOptionsAndSubOptions; } |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |