0

ConfigurationSection から継承する次のクラスがあります

public class ExceptionsConfiguration:ConfigurationSection
    {
        private static ExceptionsConfiguration _exceptionsconfig = ConfigurationManager.GetSection("ExceptionsConfig") as ExceptionsConfiguration;
        /// <summary>
        /// Static accessible configuration
        /// </summary>
        public static ExceptionsConfiguration ExceptionsConfig
        {
            get
            {
                return _exceptionsconfig;
            }
        }
        //HTML message with the exception to be sent by email
        public string HTMLMessage { get; set; }
        //Subject of the email
        public string Subject { get; set; }
        //UserName of the email account to use
        public string FromLabel { get; set; }
        //Password of the email
        public string Password { get; set; }
        //Email account used to send the email
        public string Email { get; set; }
        //To account to send email with exception
        public string To{get;set;}
        //Smtp server used to send the email
        public string SmtpServer{get;set;}
        //Port used to send the email
        public int Port{get;set;}
    }

一方、web.configでセクションを宣言しました

<configSections>
        <section name="ExceptionsConfig" type="Framework.Web.Configuration.ExceptionsConfiguration" allowLocation="true" allowDefinition="Everywhere" />
    </configSections>
    <ExceptionsConfig configSource="Config\ExceptionsConfig.config"/>

そして最後に私の設定ファイル:

<ExceptionsConfig>
    <HTMLMessage>
        <![CDATA[
            <p> DataService:{0}</p>
            <p> AvailableCategories:{1} </p>
            <p> Queries:{2} </p>
            <p> Exception:{3} </p>
            <p> Is child action:{4} </p>
            <p> Action executed:{5} </p>
            <p> Controller executed:{6} </p>
            <p> Current URL: {7} </p>
            <p> Headers start </p>
            <p> {8} </p>
            <p> Headers end </p>
            <p> IP adress: {9}
        ]]>
    </HTMLMessage>
    <Subject>Exception on www.</Subject>
    <FromLabel>Exception watcher from</FromLabel>
    <Password>zzzzz</Password>
    <Email>xxxxxx@xxxxx.com</Email>
    <To>yyyyyy@yyyyyyy.com</To>
    <SmtpServer>smtp.nnnnnnn.com</SmtpServer>
    <Port>000</Port>
</ExceptionsConfig>

ここでスタックトレース:

ja Framework.Web.Configuration.ExceptionsConfigurationSection.get_ExceptionsConfiguration() ja Framework.Web.Filters.ExceptionFilter.OnException(ExceptionContext filterContext) ja C:\inetpub\wwwroot\Projects\Generic Website\Framework.Web\Filters\ExceptionFilter.cs:línea 19 ja System.Web.Mvc.ControllerActionInvoker.InvokeExceptionFilters(ControllerContext controllerContext, IList 1 filters, Exception exception) en System.Web.Mvc.ControllerActionInvoker.InvokeAction(ControllerContext controllerContext, String actionName) en System.Web.Mvc.Controller.ExecuteCore() en System.Web.Mvc.ControllerBase.Execute(RequestContext requestContext) en System.Web.Mvc.ControllerBase.System.Web.Mvc.IController.Execute(RequestContext requestContext) en System.Web.Mvc.MvcHandler.<>c__DisplayClass6.<>c__DisplayClassb.<BeginProcessRequest>b__5() en System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass1.<MakeVoidDelegate>b__0() en System.Web.Mvc.Async.AsyncResultWrapper.<>c__DisplayClass81.b_ 7(IAsyncResult ) ja System.Web.Mvc.Async.AsyncResultWrapper.WrappedAsyncResult`1.End() ja System.Web.Mvc.MvcHandler. <>c_ DisplayClasse.b_d() ja System.Web.Mvc.SecurityUtil.b__0(Action f) ja System.Web.Mvc.SecurityUtil.ProcessInApplicationTrust(Action action) ja System.Web.Mvc.MvcHandler.EndProcessRequest(IAsyncResult asyncResult) ja System.Web. Mvc.MvcHandler.System.Web.IHttpAsyncHandler.EndProcessRequest(IAsyncResult 結果) System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)

クラス ExceptionsConfiguration の型の初期化エラーが発生しました... エラーには、「要素 HTMLMessage が認識されません」と表示されます。

手を貸していただけますか?

ありがとう

よろしく

ホセ

4

0 に答える 0