RichardHowells posted on August 02, 2015 09:43
Symptom.
The site crashes with an exception trace like this one. (Warning you only see this on web page if the site allows you to see exception messages. Showing users exception messages is generally a bad security practice.) You may have to look in the event log table to see this.
Server Error in '/' Application.
Input string was not in a correct format.
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.FormatException: Input string was not in a correct format.
Source Error:
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below. |
Stack Trace:
[FormatException: Input string was not in a correct format.] System.Number.StringToNumber(String str, NumberStyles options, NumberBuffer& number, NumberFormatInfo info, Boolean parseDecimal) +10725735 System.Number.ParseInt32(String s, NumberStyles style, NumberFormatInfo info) +145 System.String.System.IConvertible.ToInt32(IFormatProvider provider) +46 System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider) +510 DotNetNuke.Collections.CollectionExtensions.ConvertValue(Object value) +100 DotNetNuke.Collections.CollectionExtensions.GetValueOrDefault(IDictionary dictionary, String key, T defaultValue, Func`2 converter) +64 DotNetNuke.Collections.CollectionExtensions.GetValueOrDefault(IDictionary dictionary, String key, T defaultValue) +55 DotNetNuke.Entities.Portals.PortalSettingsController.LoadPortalSettings(PortalSettings portalSettings) +898 DotNetNuke.Entities.Portals.PortalSettings.BuildPortalSettings(Int32 tabId, PortalInfo portal) +28 DotNetNuke.Entities.Portals.PortalSettings..ctor(Int32 tabId, PortalAliasInfo portalAliasInfo) +94 DotNetNuke.HttpModules.UrlRewrite.BasicUrlRewriter.RewriteUrl(Object sender, EventArgs e) +2131 System.Web.SyncEventExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +136 System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +69
Diagnosis.
This huge and scary message may cause you to panic. Don't. There are a few useful signals in all that noise.
These things...
DotNetNuke.Entities.Portals.PortalSettingsController.LoadPortalSettings(PortalSettings portalSettings) +898
DotNetNuke.Entities.Portals.PortalSettings.BuildPortalSettings(Int32 tabId, PortalInfo portal) +28
DotNetNuke.Entities.Portals.PortalSettings..ctor(Int32 tabId, PortalAliasInfo portalAliasInfo)
...appearing in the stack trace make it a reasonable guess that your PortalSettings table contains bad data.
The presence of System.Number.ParseInt32 in the stack trace suggests that the code found a PortalSetting that should be an integer but isn't. There are other reasonably named functions that you may see there with ParseXXXXX in the name. The XXXXX gives you a clue about what the expected data is.
Fixing it.
First off take a backup. You are about to do risky stuff in the database and you need a way to recover if things go wrong and you make the situation worse.
Try Sebastian Leupold's excellent Script. It's intended to correct errors in the PortalSettings table. https://dnnscript.codeplex.com/releases/view/132975.
If the script does not correct your issue then you need to take a very careful look at your PortalSettings table and use your intuition. You'll have to guess a bit. You are looking for a setting (or settings) that sounds like it should be an integer (if ParseInt32 appeared in the stack trace) but is either empty or not an integer. In this context something like 1.0 does *not* qualify as an integer. Once you find some suspect data you need to change it to a 'reasonable' value.
Once all the PortalSettings have reasonable values the site should come up again.
Leave a comment to let us know how you got on!