Microsoft KB Archive/327287

= PRB: Error message: System.InvalidCastException: Specified Cast is not valid =

Article ID: 327287

Article Last Modified on 5/4/2004

-

APPLIES TO


 * Microsoft ASP.NET 1.1
 * Microsoft ASP.NET 1.0

-



This article was previously published under Q327287



SYMPTOMS
When you view your ASP.NET page in the browser, you may receive the following error message:

Specified cast is not valid.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.InvalidCastException: Specified cast is not valid.



CAUSE
This problem might occur on postback because the control tree hierarchy is re-ordered. On postback, the view state for controls is loaded based on the positions of the controls (indexes) in the control tree. The hierarchy that is created on postback must match the hierarchy that is used initially when the view state is saved.



RESOLUTION
Make sure that the control tree is re-created on postback in the same order that it was saved at the end of the previous request.



STATUS
This behavior is by design.

Keywords: kberrmsg kbstate kbprb kbservercontrols KB327287

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.