2

私は自分のアプリケーションをラムしようとしていますが、次のようなエラーが発生しています: System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was throw.

コードの ** 行の近くで例外がスローされます。

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());

(フレンドリーなヒント、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はよく知られたクラスではないため、インターネット上にドキュメントがありません。したがって、それが自分のものである場合は、ステップスルー (ブレークポイントを設定) を試すことができます。または、他の誰かのものである場合は、ベンダーに電話するか、「自分のコードのみ」設定を削除した後にステップスルーを試みることができます。

于 2012-10-19T16:28:13.230 に答える