Click here to Skip to main content
15,564,017 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi,

I have created a web-service and hosted in localhost which is doing some database operation through single static LINQ DBcontext Object. And this web-service is consumed by another windows service hosted in same machine which is using tread so multiple thread is hitting my webservice simultaneously and every thread perform their task nicely but SOMETIMES we are receiving following kind of errors.

Object reference not set to an instance of an object.

StackTrace: at System.Data.Linq.SqlClient.SqlConnectionManager.BootUser(IConnectionUser user)
at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user)
at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at System.Data.Linq.DataQuery`1.System.Linq.IQueryProvider.Execute[S](Expression expression)
at System.Linq.Queryable.Count[TSource](IQueryable`1 source)
at SMS.BLL.Subscriber.GetSubscriberByID(Guid p_subscriberID)


=====================================================

Index was outside the bounds of the array.
StackTrace: at System.Collections.Generic.List`1.RemoveAt(Int32 index)
at System.Data.Linq.SqlClient.SqlConnectionManager.BootUser(IConnectionUser user)
at System.Data.Linq.SqlClient.SqlConnectionManager.UseConnection(IConnectionUser user)
at System.Data.Linq.SqlClient.SqlProvider.Execute(Expression query, QueryInfo queryInfo, IObjectReaderFactory factory, Object[] parentArgs, Object[] userArgs, ICompiledSubQuery[] subQueries, Object lastResult)
at System.Data.Linq.SqlClient.SqlProvider.ExecuteAll(Expression query, QueryInfo[] queryInfos, IObjectReaderFactory factory, Object[] userArguments, ICompiledSubQuery[] subQueries)
at System.Data.Linq.SqlClient.SqlProvider.System.Data.Linq.Provider.IProvider.Execute(Expression query)
at SMS.BLL.SMSDataClassesDataContext.SMS_INSERTMT(String sUBSCRIBERID, XElement mESSAGEXML)
at SMS.BLL.Subscriber.SaveMTMessages(Guid SubscriberID, Byte[] smsInfoCompressed, String EncodingName)



Can anybody help me please?

Thanks
Rohit
Posted
Updated 12-Feb-14 21:28pm
v2

1 solution

Without seeing the code would be bit of a generic answer.

But try to Dispose the DataContext over each request.

Just adding a link which solves the similar issue. Also read the Comments related to the Answer in the post.

http://stackoverflow.com/questions/6653874/strange-linq-exception[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900