Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 180347
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:34:14+00:00 2026-05-11T14:34:14+00:00

I just launched my tiny webapp on my humble dedicated server (Win2003)… running ASP.NET

  • 0

I just launched my tiny webapp on my humble dedicated server (Win2003)… running ASP.NET MVC, LINQ2SQL, SQL Express 2005, and IIS6 (setup with wildcard mapping)

The website runs smoothly 90% of the times. However, on relatively high traffic, LINQ2SQL throws the error: Specified cast is not valid

This error is ONLY thrown at high traffic. I have NO IDEA how or exactly why this happens. Caching did not remove this problem entirely.

Anyone seen this problem before? are there any secret SQL Server tweaking I should’ve done? Or at least, any ideas on how to diagnose this issue? because i’m out!

Naimi

Stacktrace (from Event Log):

 at System.Data.SqlClient.SqlBuffer.get_SqlGuid()    at System.Data.SqlClient.SqlDataReader.GetGuid(Int32 i)    at Read_Friend(ObjectMaterializer`1 )    at System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader`2.MoveNext()    at Dudlers.Web.Models.DudlersDataContext.GetFriendRequests(Guid userId) in C:\Web\Models\DudlersDataContext.cs:line 562    at Dudlers.Web.Controllers.BaseController.View(String viewName, String masterName, Object viewData) in C:\Web\Controllers\BaseController.cs:line 39    at System.Web.Mvc.Controller.View(String viewName)    at Dudlers.Web.Controllers.CatController.Index() in C:\Web\Controllers\CatController.cs:line 25    at lambda_method(ExecutionScope , ControllerBase , Object[] )    at System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters)    at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(MethodInfo methodInfo, IDictionary`2 parameters)    at System.Web.Mvc.ControllerActionInvoker.c__DisplayClassb.b__8()    at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter(IActionFilter filter, ActionExecutingContext preContext, Func`1 continuation)    at System.Web.Mvc.ControllerActionInvoker.c__DisplayClassb.c__DisplayClassd.b__a()    at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodWithFilters(MethodInfo methodInfo, IDictionary`2 parameters, IList`1 filters)    at System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName)    at System.Web.Mvc.Controller.ExecuteCore()    at System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext)    at System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext)    at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContextBase httpContext)    at System.Web.Mvc.MvcHandler.ProcessRequest(HttpContext httpContext)    at System.Web.Mvc.MvcHandler.System.Web.IHttpHandler.ProcessRequest(HttpContext httpContext)    at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()    at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T14:34:14+00:00Added an answer on May 11, 2026 at 2:34 pm

    We had a similar problem with LINQ that we get ‘Unable to cast object of type ‘System.Int32’ to type ‘System.String” and ‘Specified cast is not valid.’

    Examples of stacktraces

    System.InvalidCastException: Unable to cast object of type 'System.Int32' to type 'System.String'.    at System.Data.SqlClient.SqlBuffer.get_String()    at System.Data.SqlClient.SqlDataReader.GetString(Int32 i)    at Read_Person(ObjectMaterializer`1 )    at System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader`2.MoveNext()    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)    at RF.Ias.Services.Person.BusinessLogic.PersonTransactionScripts.GetPersons(IEnumerable`1 personIds, Boolean includeAddress, Boolean includeContact)    at CompositionAopProxy_5b0727341ad64f29b816c1b73d11dd44.GetPersons(IEnumerable`1 personIds, Boolean includeAddress, Boolean includeContact)    at RF.Ias.Services.Person.ServiceImplementation.PersonService.GetPersons(GetPersonRequest request)   System.InvalidCastException: Specified cast is not valid.    at System.Data.SqlClient.SqlBuffer.get_Int32()    at System.Data.SqlClient.SqlDataReader.GetInt32(Int32 i)    at Read_GetRolesForOrganisationResult(ObjectMaterializer`1 )    at System.Data.Linq.SqlClient.ObjectReaderCompiler.ObjectReader`2.MoveNext()    at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)    at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)    at RF.Ias.Services.Role.DataAccess.RoleDataAccess.GetRolesForOrganisation(GetRolesForOrganisationCriteria criteria, Int32 pageIndex, Int32 pageSize, Int32& recordCount)    at RF.Ias.Services.Role.BusinessLogic.RoleTransactionScripts.GetRolesForOrganisation(GetRolesForOrganisationCriteria criteria, Int32 pageIndex, Int32 pageSize, Int32& recordCount)    at CompositionAopProxy_4bd29c6074f54d10a2c09bd4ab27ca66.GetRolesForOrganisation(GetRolesForOrganisationCriteria criteria, Int32 pageIndex, Int32 pageSize, Int32& recordCount)    at RF.Ias.Services.Role.ServiceImplementation.RoleService.GetRolesForOrganisation(GetRolesForOrganisationRequest request) 

    We used to get these exceptions if we first got a exception like this ‘System.InvalidOperationException: There is already an open DataReader associated with this Command which must be closed first.’ or ‘ A transport-level error has occurred when receiving results from the server. (provider: TCP Provider, error: 0 – An existing connection was forcibly closed by the remote host.)’.

    The first exception occur for a different instance of the DataCOntext then for all those that then are following.

    After some research and asking in this thread , I found that the reason was that I did not dispose the DataContexts. After I started to do that, it dissappered.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

just wondering if anyone knows of a truly restful Put/delete implementation asp.net mvc preview
When I first launched the Visual Studio (I just installed it) I choose the
We just launched and are looking to better understand where the users who are
I just launched a site a few weeks ago, and I've been getting several
I've just launched my new site, and in going though it in multiple browsers
I've just launched a small application i've been working on. Nothing major, but something
I'm facing a bit of an odd problem here. I just launched: http://claudiu.phpfogapp.com/ To
Ok, this is the deal. I just launched a website working on Wordpress where
I have simple application with single AppDomain which is periodicaly launched on a server.
I just launched my test website in Windows Azure this weekend with a single

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.