我有这段代码片段
public Version BuildVersion =Version.Parse(System.Web.Configuration.WebConfigurationManager.AppSettings["BuildVersion"].ToString());
读取以下appSetting条目
<appSettings>
<add key="BuildVersion" value="4.7.2.2" />
</appSettings>
这会引发异常
[FormatException: Input string was not in a correct format.]
System.VersionResult.SetFailure(ParseFailureKind failure, String argument) +10852983
System.Version.TryParseComponent(String component, String componentName, VersionResult& result, Int32& parsedComponent) +105
System.Version.TryParseVersion(String version, VersionResult& result) +135
System.Version.Parse(String input) +68
QuickPick.Main..ctor() in D:\IWROX-DEV\Expresslane\IWorx-Trunk-PromoFrontEnd\ExpressLane.Web\Main.Master.cs:52
ASP.main_master..ctor() in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\e43b3107\2f748eb6\App_Web_main.master.cdcab7d2.uaxqveln.0.cs:0
__ASP.FastObjectFactory_app_web_main_master_cdcab7d2_uaxqveln.Create_ASP_main_master() in c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\root\e43b3107\2f748eb6\App_Web_main.master.cdcab7d2.uaxqveln.1.cs:0
System.Web.Compilation.BuildResultCompiledType.CreateInstance() +30
System.Web.UI.MasterPage.CreateMaster(TemplateControl owner, HttpContext context, VirtualPath masterPageFile, IDictionary contentTemplateCollection) +782
System.Web.UI.Page.get_Master() +54
System.Web.UI.Page.ApplyMasterPage() +14
System.Web.UI.Page.PerformPreInit() +45
System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +335
一旦部署到服务器,但它在VS2010 Web主机(ASP NET Development Server)上运行良好。
答案 0 :(得分:1)
很可能没有将正确的配置文件部署到您的主机。