Hi,

Working with LINQ to SQL over an ASP.NET application (VS2008, .NET 3.5)
while calling
"MyDataContextInstance.GetTable<MyTable>()"
it produces sometimes the following exception:
"an item with the same key has already been added"

I think is some trouble about concurrency or async calls
(MyDataContextInstance is an static variable).
Could it be a problem related to ASP.NET application lifecycle management?
or...
a LINQ to SQL (DataContext) bug not supporting concurrency?

Thanks in advance for your time.


Néstor Sánchez A.

Re: LINQ to SQL, over ASP.NET, DataContext.GetTable trouble by Miha

Miha
Sat Jun 14 05:43:13 CDT 2008

DataContext isn't thread safe:
"Any public static (Shared in Visual Basic) members of this type are thread
safe. Any instance members are not guaranteed to be thread safe."
(from the docs).

--
Miha Markic [MVP C#, INETA Country Leader for Slovenia]
RightHand .NET consulting & development www.rthand.com
Blog: http://cs.rthand.com/blogs/blog_with_righthand/

"Néstor Sánchez A." <nestor.sanchez@akzio.cl> wrote in message
news:e3VPGBXzIHA.524@TK2MSFTNGP05.phx.gbl...
> Hi,
>
> Working with LINQ to SQL over an ASP.NET application (VS2008, .NET 3.5)
> while calling
> "MyDataContextInstance.GetTable<MyTable>()"
> it produces sometimes the following exception:
> "an item with the same key has already been added"
>
> I think is some trouble about concurrency or async calls
> (MyDataContextInstance is an static variable).
> Could it be a problem related to ASP.NET application lifecycle management?
> or...
> a LINQ to SQL (DataContext) bug not supporting concurrency?
>
> Thanks in advance for your time.
>
>
> Néstor Sánchez A.
>
>