Reza Nabati
Reza Nabati

Reputation: 163

stackoverflow exception on System.Data.Linq.dll

I'm recently working on a asp.net web application. that use linq to sql ORM to data access layer (DAL). In a specific case of my queries faces with stackoverflow exception on clr Level.

i use filter expression generator to get specific data (such as load with specific constrient) that we send more than 1500 parameters to the store procedure.

NOTE: we consider RPC (Remote Procedure Calling) limitation that's exactly 2100 parameters in sql server default setting.

but i don't know why i face with stackoverflow exception? it's interesting to know this problem only occur on iis and no problem in asp.net web development server.

and i'm nearly find out problem that be caused the large number of parameters.

i was grateful from someone that help me?

Exception Detail

 public List<HSEPersonnelComplexPaging> SelectHSEPersonnelPaging(PagingPropertiesDTO pagingProps, out int recCount)
    {
        using (HRPaidTimeOffDataContext db = new HRPaidTimeOffDataContext(DBHelper.GetConnectionString()))
        {
            Expression<Func<HSEPersonnelComplexPaging, bool>> expr =
                PredicateBuilder.GetFilterExpression<HSEPersonnelComplexPaging>(pagingProps);
            db.DeferredLoadingEnabled = false;

            var items = from at in db.HSEPersonnels
                        where at.IsDeleted == false
                        select new HSEPersonnelComplexPaging
                        {
                            ID = at.HSEPersonnelId,
                            PersonnelyNo = at.PersonnelyNo,
                            Name = at.Name,
                            Family = at.Family,
                            BirthPlace = at.BirthPlace,
                            Birthdate = at.Birthdate,
                            Father = at.Father,
                            IdNo = at.IdNo,
                            NationalCode = at.NationalCode,
                            IsNotActive =  at.IsNotActive,
                            IsDeleted = at.IsDeleted,
                            InsertDate = at.InsertDate,
                            UpdateDate = at.UpdateDate,
                            InsertENTUserAccountId = at.InsertENTUserAccountId

                        };
            var result = items.Where(expr);
            recCount = result.Count();
            return
                result.ApplySortExpression(pagingProps.SortSet).Skip(pagingProps.CurrentPageIndex *
                                                                     pagingProps.CurrentPageSize).Take(
                                                                         pagingProps.CurrentPageSize).ToList();
        }

Upvotes: 2

Views: 779

Answers (2)

ErikHeemskerk
ErikHeemskerk

Reputation: 1701

The problem might lie in the predicate you're building. When you enumerate the expression (which you're doing in the call to Count()), LINQ to SQL will walk down the expression tree to determine what it is you're trying to query. Is it possible that somewhere you're creating a cyclic reference?

Upvotes: 1

Vladimir Gondarev
Vladimir Gondarev

Reputation: 1243

maybe this is a some kind of explanation: http://support.microsoft.com/kb/932909 All child processes created by IIS have a 256kb stack size

Try this weird thing:

Thread thread = new Thread(() => YourMethod(),4194304);
thread .Start();
thread .Join();

The point is to execute your method in a separate thread that has a bigger stack size..

Upvotes: 1

Related Questions