This thread looks to be a little on the old side and therefore may no longer be relevant. Please see if there is a newer thread on the subject and ensure you're using the most recent build of any software if your question regards a particular product.
This thread has been locked and is no longer accepting new posts, if you have a question regarding this topic please email us at support@mindscape.co.nz
|
I am getting a sporadic error when I add an entity to an entity collection. The error is Normal 0 false false false EN-NZ X-NONE X-NONE MicrosoftInternetExplorer4 /* Style Definitions */ table.MsoNormalTable {mso-style-name:"Table Normal"; mso-tstyle-rowband-size:0; mso-tstyle-colband-size:0; mso-style-noshow:yes; mso-style-priority:99; mso-style-qformat:yes; mso-style-parent:""; mso-padding-alt:0cm 5.4pt 0cm 5.4pt; mso-para-margin:0cm; mso-para-margin-bottom:.0001pt; mso-pagination:widow-orphan; font-size:11.0pt; font-family:"Calibri","sans-serif"; mso-ascii-font-family:Calibri; mso-ascii-theme-font:minor-latin; mso-fareast-font-family:"Times New Roman"; mso-fareast-theme-font:minor-fareast; mso-hansi-font-family:Calibri; mso-hansi-theme-font:minor-latin; mso-bidi-font-family:"Times New Roman"; mso-bidi-theme-font:minor-bidi;} System.ArgumentException: An item with the same key has already been added. at System.ThrowHelper.ThrowArgumentException(ExceptionResource resource)
at System.Collections.Generic.Dictionary`2.Insert(TKey key, TValue value, Boolean add)
at System.Collections.Generic.Dictionary`2.Add(TKey key, TValue value)
at Mindscape.LightSpeed.LightSpeedContext.(TypeModel )
at Mindscape.LightSpeed.LightSpeedContext.(Entity )
at Mindscape.LightSpeed.Entity.GeneratedId()
at Mindscape.LightSpeed.Entity`1.get_Id()
at Mindscape.LightSpeed.Entity`1.get_IdInternal()
at Mindscape.LightSpeed.Model.TypeModel.(Entity )
at Mindscape.LightSpeed.Entity.get_UniqueId()
at Mindscape.LightSpeed.UnitOfWorkBase.(Entity )
at Mindscape.LightSpeed.Entity.AddToUnitOfWorkIdentityMap(Entity )
at Mindscape.LightSpeed.Entity.SyncUnitOfWork(Entity )
at Mindscape.LightSpeed.Entity.EntityAddedEvent(Object , EntityEventArgs`1 )
at Mindscape.LightSpeed.EntityCollection`1.(TEntity )
at Mindscape.LightSpeed.EntityCollection`1.InsertItem(Int32 index, TEntity item)
at System.Collections.ObjectModel.Collection`1.Add(T item)
at CmsModels.Entities.User.AddLog(String action, String details, DateTime actionTime) in D:\dev\dotnet\Projects\CmsWeb\CmsModels\Entities\User.cs:line 68
at CmsModels.Repositories.UserRepository.AddUserLog(String userName, String action, String details) in D:\dev\dotnet\Projects\CmsWeb\CmsModels\Repositories\UserRepository.cs:line 79
at CmsWeb.MvcApplication.LogUserAction(String action) in D:\dev\dotnet\Projects\CmsWeb\CmsWeb\Global.asax.cs:line 131
at CmsWeb.MvcApplication.SaveSessionDetails() in D:\dev\dotnet\Projects\CmsWeb\CmsWeb\Global.asax.cs:line 115
at CmsWeb.MvcApplication.Session_Start(Object sender, EventArgs e) in D:\dev\dotnet\Projects\CmsWeb\CmsWeb\Global.asax.cs:line 93
at System.Web.SessionState.SessionStateModule.RaiseOnStart(EventArgs e)
at System.Web.SessionState.SessionStateModule.CompleteAcquireState()
at System.Web.SessionState.SessionStateModule.BeginAcquireState(Object source, EventArgs e, AsyncCallback cb, Object extraData)
at System.Web.HttpApplication.AsyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) I suspect that it is because my entity (UserLog) uses an indentity column so the Id is 0 when I add it to the entity collection. I am saving the changes imediately after adding the item but the damage may already have been done. I am unable to reproduce the error reliably, it pops up only when I am not looking for it :(, about once an hour.
Any ideas?
Sean
|
|
|
Looks like a race condition where two threads attempt to cache internal identity generator objects at the same time. I've committed a fix and it should be in the next nightly. Thanks for drawing our attention to this, and let us know if it happens again! |
|
|
Thanks, I will give it a try |
|
|
I haven't had the issue since upgrading to the nightly. Thanks. |
|