2

我试图朗姆酒我的应用程序,我收到以下错误: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)

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

4

1 回答 1

3

对不起,整个答案的编辑,以前只对了一半

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

未找到 PolicyClass = 2 和 DocumentType = 27 的 FormMaster

该错误在您自己的代码中。ApplicationException没有发生在您所指的行上。该行的结果formTemplate是 null 并且您的代码会引发此异常。

这是引发异常的行:

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

(a friendly tip, use string.Format instead)

And this is the line returning 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);

(a friendly tip: write it out over multiple lines. That helps with setting breakpoints and with readability)


Your next question should be: why is it returning null? The answer, I don't know. In my previous attempt of answering I said something about third party code. And that's exactly what this is, as the class PolicyClassCollection is not a well-known class, there's no documentation on the internet on it. So either it is your own, in which case you can try stepping through (set a breakpoint) or it is someone else's in which case you can try calling the vendor or try stepping through after removing the "just my code" setting.

于 2012-10-19T16:28:13.230 回答