gpt4 book ai didi

c# - 系统.ApplicationException

转载 作者:行者123 更新时间:2023-11-30 22:24:06 31 4
gpt4 key购买 nike

我正在尝试朗姆酒我的应用程序,但我收到以下错误:System.Web.HttpUnhandledException:引发了“System.Web.HttpUnhandledException”类型的异常。

异常在代码**行附近抛出:

public void LoadFromEntity(bool editable, string TabKey)
{
//Getting the FormMaster collection
**FormTemplate formTemplate = PolicyClassCollection.CachedPolicyClasses.FindBy((int)EnumPolicyClasses.PNI).FormTemplateCo**llection.Find(ft => ft.PolicyClassId == Utility.GetCurrentPolicyClassId() && ft.DocumentType.DocumentTypeId == (int)EnumDocumentTypes.Coverage_Summary && ft.PolicyTypeId == Utility.GetCurrentAccount().CurrentRisk.PolicyTypeId);

if (formTemplate != null)
{
//Set context string with current option number
this._Account.CurrentRisk.FormContextData = this.OptionNum.ToString();

//getting FormMasterID
Guid vsDatabaseId = formTemplate.FormFilingHistoryId;
string accountXmlString = this._Account.ToXML();

//Setting the parameters in PDFServiceParms class that are to be used in "PDFService.aspx" page.
PDFServiceParms pdfParams = new PDFServiceParms(FORM_MODE_EDIT, vsDatabaseId.ToString(), Model.AppConstants.FORM_TYPE_SELECTED_FORM, accountXmlString);

//Saving the parameters in the session. PDFService.aspx page reads the parameters from the session. Session key is passed in the
//query string when calling the PDFService.aspx page.
Session[AppConstants.SK_SUMMARY_PDF_PARAMS] = pdfParams;

//Setting the iFrame's source to PDFService.aspx page. The PDF document generated in this page is displayed in the iFrame.
this.iframePdf.Attributes["src"] = ResolveClientUrl(AppConstants.PAGE_NAME_PDFSERVICE) + "?datakey=" + AppConstants.SK_SUMMARY_PDF_PARAMS;
}
else
throw new ApplicationException("FormMaster not found for PolicyClass = " + Utility.GetCurrentPolicyClassId().ToString() + " and DocumentType = " + ((int)EnumDocumentTypes.Coverage_Summary).ToString());
}

抛出异常:

System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.ApplicationException: FormMaster not found for PolicyClass = 2 and DocumentType = 27
at PNI_SqbpeCovInfoPNISummary.LoadFromEntity(Boolean editable, String TabKey) in C:\TFS\Navigate Development\NavigateWebApp\PNI\SqbpeCovInfoPNISummary.aspx.cs:line 95
at SQBPECoverageInformationMasterPNI.LoadFromEntity() in C:\TFS\Navigate Development\NavigateWebApp\PNI\SQBPECoverageInformationMasterPNI.master.cs:line 188
at SQBPE.Page_Load(Object sender, EventArgs e) in C:\TFS\Navigate Development\NavigateWebApp\SQBPE.master.cs:line 55
at System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e)
at System.Web.Util.CalliEventHandlerDelegateProxy.Callback(Object sender, EventArgs e)
at System.Web.UI.Control.OnLoad(EventArgs e)
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Control.LoadRecursive()
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
--- End of inner exception stack trace ---
at System.Web.UI.Page.HandleError(Exception e)
at System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint)
at System.Web.UI.Page.ProcessRequest()
at System.Web.UI.Page.ProcessRequest(HttpContext context)
at ASP.pni_sqbpecovinfopnisummary_aspx.ProcessRequest(HttpContext context) in c:\Windows\Microsoft.NET\Framework64\v2.0.50727\Temporary ASP.NET Files\navigatewebapp\253cae21\57ec5e1d\App_Web_sqbpecovinfopnisummary.aspx.41d7eb59.1z9y4p0a.0.cs:line 0
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

有人可以让我知道为此需要做什么吗。

最佳答案

抱歉,整个答案的编辑,之前只对了一半

父异常是 HttpUnhandledException。内部异常似乎很清楚,并说:

FormMaster not found for PolicyClass = 2 and DocumentType = 27

该错误在您自己的代码中。 ApplicationException 发生在您所指的行上。该行的结果是 formTemplate 为空,您的代码抛出此异常。

这是抛出异常的行:

throw new ApplicationException("FormMaster not found for PolicyClass = " 
+ Utility.GetCurrentPolicyClassId().ToString()
+ " and DocumentType = "
+ ((int)EnumDocumentTypes.Coverage_Summary).ToString());

(友情提示,改用string.Format)

这是返回 null 的行:

FormTemplate formTemplate = PolicyClassCollection.CachedPolicyClasses
.FindBy((int)EnumPolicyClasses.PNI).FormTemplateCollection
.Find(ft => ft.PolicyClassId == Utility.GetCurrentPolicyClassId()
&& ft.DocumentType.DocumentTypeId == (int)EnumDocumentTypes.Coverage_Summary
&& ft.PolicyTypeId == Utility.GetCurrentAccount().CurrentRisk.PolicyTypeId);

(友情提示:分多行写。这有助于设置断点和提高可读性)


您的下一个问题应该是:为什么返回 null?答案,我不知道。在我之前的回答尝试中,我说了一些关于第三方代码的事情。这正是它的含义,因为类 PolicyClassCollection 不是众所周知的类,因此 Internet 上没有关于它的文档。因此,要么是您自己的,在这种情况下您可以尝试单步执行(设置断点),要么是其他人的,在这种情况下您可以尝试调用供应商或在删除“仅我的代码”设置后尝试单步执行。

关于c# - 系统.ApplicationException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12977961/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com