Specified cast is not valid

Specified cast is not valid

Hi there.

Have anyone experienced this kind of error? It's happening a several times in my application and i cannot debug it!

Here's the service center log:
Specified cast is not valid.
at ssSIGA.Flows.FlowAgendamento.ScrnAgendamento_Edit.Page_Load(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
eSpaceVer: 219 (Id=15341, PubId=26359, CompiledWith=
RequestUrl: http://.../ (Hidden by me)
AppDomain: /LM/W3SVC/1/ROOT/SIGA/U80021094-36-129419092745520496
FilePath: D:\...\ (Hidden by me)
Locale: pt-PT
DateFormat: yyyy-MM-dd
PID: 1524 ('w3wp', Started='11-02-2011 11:46:22', Priv=1007Mb, Virt=6111Mb)
TID: 35
.NET: 2.0.50727.4927
Hi Pedro

Usually this error is related to input parameters of the web screen that can't be converted to the correct datatype, and it can happen when the input parameter is sent through a query string parameter on the URL.

Example: You have a webscreen with input parameter Date of Date datatype, and some user (or application) is sending a web request to that screen as


it should work, Hoedver, if the user input a wrong value (or wrong format) it may fail, like:

http://server/espace/Screen.aspx?Date=Today or http://server/espace/Screen.aspx?Date=12-2011-01

Another possible cause is if there have been recent changes on the datatype of session variables, and some sessions still have information on the session data model from the old datatype. On this scenario, the application will attempt to laod a different datatype from the session data model, causing this error.

Example: You have an application with a session variable of text datatype, where you store text values. When, you publish another version of the espace with this sesison variable datatype change to integer. The sessions that are still active, will attempt to load the Text value as an integer value on the new espace, because publishing an espace doesn't reset the session informationon the session data model. Until the session id changes (the user logs out and logins in with a new session id), the problem may persist.

The solution to latest problem is to clear the session data model using the Configuraiton Tool, which causes all users to loose their session.

Hope this information is helpful.


Miguel Simões João
Hi Miguel,

Thanks for your reply.

In fact, when this problem occurs is when the screen is called by a query string that is build by SIEBEL.

However, sometimes this problem occurs, sometimes not.. It's a little weird.. Plus, when this problem occurs, the authentication popup window never appears.
It seems that the request never reaches the application...

What i'm i supposed to do?

Hi Pedro

Indeed this exception is occurring during the ASP.NET application load, hence the request never reaches inside the OutSystems application, which means you have no control over the exception.

If this problem only occurs form web requests from a specific 3rd party system, and it seems related to a query string value in wrong format or datatype, then there are 2 approaches that you can do to troubleshoot and fix the problem:
  1. Identify the erroneous query string value and fix it at the 3rd party system when calling the application through that web request. In order to achieve this you'll need to search within the IIS log files the entire URL that is being sent to the application, if you already don't have it on the Service Center error log details (the one that you've obfuscated on the first post). Try to replicate the error with that specific URL, and attempt to identify the cause of the cast failure. The causes may vary from different datatypes, to wrong datatype format, or even an invalid value (like the date 2011-02-30). After identifying the value, you can fix it on the 3rd party system side
  2. Change the query string datatypes to Text values, allowing the OutSystems application to receive any datatype, and then, for each one attempt datatype conversion. However, this is already done within the OutSystems application logic where you have full control to fix the values, or issue proper exceptions.
Hope this information helps.


Miguel Simões João
Hi Miguel,

Thanks a lot for your help, it was very usefull!

Pedro Domingues