I have a line of C# in my ASP.NET code behind that looks like this:
DropDownList ddlStates = (DropDownList)fvAccountSummary.FindControl("ddlStates");
The DropDownList control is explicitly declared in the markup on the page, not dynamically created. It is inside of a FormView control. When my code hits this line, I am getting an ArithmeticException with the message "Value was either too large or too small for an Int32." This code has worked previously, and is in production right now. I fired up VS2008 to make some changes to the site, but before I changed anything, I got this exception from the page. Anyone seen this one before?
-
Hi!
Are you 100% sure that's the line of code that's throwing the exception? I'm pretty certain that the FindControl method is not capable of throwing an ArithmeticException. Of course, I've been known to be wrong before... :)
From aweber1 -
I have seen ArithmeticException being thrown in weird places before in C#/.NET and it was when I was working with p/invoke to an unmanaged .dll talking to an USB device.
The crash was consistent, and always at the same place. Of course, the place was totally unrelated to the crash (i think it was a basic value assignment, like int i = 4 or something similarly silly)
I'd like to have a happy ending to tell you, but I never managed to fully track down the problem. I strongly believe that the cause was in the unmanaged code, and that it somehow corrupted the memory or maybe even free'd managed memory. (Removing the calls to unmanaged code made the problem go away)
The message I'm sending is: are you doing any calls to unmanaged code? If so, my suggestion is you focus your debugging skills there :)
Mark Struzinski : Hi, Isak. I'm not doing any unmanaged code. I haven't been brave enough to attempt that yet. :)Mikael Sundberg : Isak, check out this article: http://support.microsoft.com/kb/326219.Isak Savo : that could very well have been the issue Mikael, thanks for the link. (Although I have no way to verify since that code I was talking about has long since been abandoned)From Isak Savo -
Stack Trace:
at System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) at System.String.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ChangeType(Object value, TypeCode typeCode, IFormatProvider provider) at System.Web.UI.WebControls.Parameter.GetValue(Object value, String defaultValue, TypeCode type, Boolean convertEmptyStringToNull, Boolean ignoreNullableTypeChanges) at System.Web.UI.WebControls.Parameter.GetValue(Object value, Boolean ignoreNullableTypeChanges) at System.Web.UI.WebControls.ParameterCollection.GetValues(HttpContext context, Control control) at System.Web.UI.WebControls.ObjectDataSourceView.ExecuteSelect(DataSourceSelectArguments arguments) at System.Web.UI.DataSourceView.Select(DataSourceSelectArguments arguments, DataSourceViewSelectCallback callback) at System.Web.UI.WebControls.DataBoundControl.PerformSelect() at System.Web.UI.WebControls.BaseDataBoundControl.DataBind() at System.Web.UI.WebControls.FormView.DataBind() at System.Web.UI.WebControls.BaseDataBoundControl.EnsureDataBound() at System.Web.UI.WebControls.FormView.EnsureDataBound() at System.Web.UI.WebControls.CompositeDataBoundControl.CreateChildControls() at System.Web.UI.Control.EnsureChildControls() at System.Web.UI.Control.FindControl(String id, Int32 pathOffset) at System.Web.UI.Control.FindControl(String id) at FraudLQueue.Pages.FLQApproval.LoadLists() in C:\\Documents and Settings\\mstruzinski\\My Documents\\Visual Studio 2008\\Projects\\FraudLQueue\\FraudLQueue\\FraudLQueue\\FLQApproval.aspx.cs:line 372 at FraudLQueue.Pages.FLQApproval.Page_Load(Object sender, EventArgs e) in C:\\Documents and Settings\\mstruzinski\\My Documents\\Visual Studio 2008\\Projects\\FraudLQueue\\FraudLQueue\\FraudLQueue\\FLQApproval.aspx.cs:line 55
From Mark Struzinski -
If that's the stacktrace, its comingn from databinding, not from the line you posted. Is it possible that you have some really large data set? I've seen a 6000-page GridView overflow an Int16, although it seems pretty unlikely you'd actually overflow an Int32...
Check to make sure you're passing in sane data into, say, the startpageIndex or pageSize of your datasource, for example.
Mark Struzinski : The querystring was passing in a string that was 8 digits to long. Silly mistake that I should've caught. I has just never seen that particular error before. Thanks for pointing me in the right direction!From Jimmy -
I have a similar issue. I use a unmanaged dll to send some data to a usb device. The problem is that when I do that I get a ArithmeticException. But never at the place where call the unmanaged code. But when I remove the unmanaged code the problem goes completly away. So, it should be something with the unmanaged code. Is there any way to get rite of the ArithmeticException without changing the dll? The reason is that I don't have any source code of the dll.
Any idea's?
From Peerke
0 comments:
Post a Comment