System.InvalidCastException: Invalid cast from 'DateTime' to 'Int32'.

This is the place to report bugs and get support. When posting in this forum, please always provide as much detail as possible.

Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum, do not report it as a bug.

This is the place to report bugs and get support

When posting in this forum, please try to provide as many relevant details as possible. Particularly the following:

  • What operating system were you running when the bug appeared?
  • What database platform is your site using?
  • What version of mojoPortal are you running?
  • What version of .NET do you use?
  • What steps are necessary to reproduce the issue? Compare expected results vs actual results.
Please do not report problems with a custom build or custom code in this forum. If you are producing your own build from the source code and have problems or questions, ask in the developer forum.
This thread is closed to new posts. You must sign in to post in the forums.
3/26/2012 8:37:27 PM
Gravatar
Total Posts 4

System.InvalidCastException: Invalid cast from 'DateTime' to 'Int32'.

System.InvalidCastException: Invalid cast from 'DateTime' to 'Int32'. at System.DateTime.System.IConvertible.ToInt32(IFormatProvider provider) at System.Convert.ToInt32(Object value) at MySql.Data.Types.MySqlInt32.MySql.Data.Types.IMySqlValue.WriteValue(MySqlPacket packet, Boolean binary, Object val, Int32 length) at MySql.Data.MySqlClient.MySqlParameter.Serialize(MySqlPacket packet, Boolean binary, MySqlConnectionStringBuilder settings) at MySql.Data.MySqlClient.Statement.SerializeParameter(MySqlParameterCollection parameters, MySqlPacket packet, String parmName) at MySql.Data.MySqlClient.Statement.InternalBindParameters(String sql, MySqlParameterCollection parameters, MySqlPacket packet) at MySql.Data.MySqlClient.Statement.BindParameters() at MySql.Data.MySqlClient.PreparableStatement.Execute() at MySql.Data.MySqlClient.MySqlCommand.ExecuteReader(CommandBehavior behavior) at MySql.Data.MySqlClient.MySqlCommand.ExecuteNonQuery() at MySql.Data.MySqlClient.MySqlHelper.ExecuteNonQuery(MySqlConnection connection, String commandText, MySqlParameter[] commandParameters) at MySql.Data.MySqlClient.MySqlHelper.ExecuteNonQuery(String connectionString, String commandText, MySqlParameter[] parms) at mojoPortal.Data.DBSystemLog.DeleteOlderThan(DateTime cutoffDate) at mojoPortal.Web.Global.PurgeOldLogEvents()

Happens every time the app is restarted ( dropping a changed dll in /bin seems to do the trick :) ).

Cosmetic, I guess.

 

3/27/2012 7:56:42 AM
Gravatar
Total Posts 18439

Re: System.InvalidCastException: Invalid cast from 'DateTime' to 'Int32'.

Hi,

Thanks for the bug report.

I've just fixed this in my copy so it will be fixed in the next release, it is a handled error so it isn't causing any problems other than older log entries are not being deleted by default.

I've just updated the article Logging to the Database with some additional config settings that were not documented. You can disable the default behavior of deleting older log items on application start if you want to, though it is ok to leave it alone and ignore that error, it will stop happening after you upgrade to the next release. I must have that disabled on this site as I'm using MySql and database logging and haven't seen that in my log, but I review my log every day and clear the log after I review it. This setting to make it automatically clear the old logs is just because if not attended to it can really accumulate over time.

Best,

Joe

3/28/2012 4:35:17 PM
Gravatar
Total Posts 4

Re: System.InvalidCastException: Invalid cast from 'DateTime' to 'Int32'.

Thanks, I'm working on some extensions for my site so I'll pull in the fixes later today.

If my hosting wouldn't allow either global rw rights or none at all, I wouldn't be using db logging as I think the load caused by it is higher then a file based log, I figured out those additional settings already but I would actually like to have older logs deleted since I can run into a couple thousand entries quickly for debugging.

Would be nice btw if the log viewer had a dropdown to select which reporting level to view, and maybe extend some of the log4net configuration options through the ui.

Got a long whish list btw, and buying beers for now isn't in the budget so it's not so much a request, just a comment. If I have time in the future I might try and add it myself but it will be awhile as I'm quite overwhelmed already. 

You must sign in to post in the forums. This thread is closed to new posts.