當前位置: 首頁>>代碼示例>>C#>>正文


C# FaultException.CreateMessageFault方法代碼示例

本文整理匯總了C#中System.ServiceModel.FaultException.CreateMessageFault方法的典型用法代碼示例。如果您正苦於以下問題:C# FaultException.CreateMessageFault方法的具體用法?C# FaultException.CreateMessageFault怎麽用?C# FaultException.CreateMessageFault使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.ServiceModel.FaultException的用法示例。


在下文中一共展示了FaultException.CreateMessageFault方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: TestCreateMessageFault

		public void TestCreateMessageFault ()
		{
			FaultException<int> e = new FaultException<int> (0);				Assert.IsFalse (
				(object) MessageFault.CreateFault (e.Code, e.Reason, e.Detail)
				== e.CreateMessageFault (), "#1");
			AreMessageFaultEqual (
				MessageFault.CreateFault (e.Code, e.Reason, e.Detail), 
				e.CreateMessageFault (), "#2");
		}
開發者ID:nickchal,項目名稱:pash,代碼行數:9,代碼來源:FaultExceptionTest.cs

示例2: ProvideFault

        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            var newEx = new FaultException(string.Format("服務端錯誤 {0}", error.TargetSite.Name));
            MessageFault msgFault = newEx.CreateMessageFault();

            fault = Message.CreateMessage(version, msgFault, newEx.Action);
        }
開發者ID:dennyli,項目名稱:HandySolution,代碼行數:7,代碼來源:LighterErrorHandler.cs

示例3: ProvideFault

        /// <summary>
        /// Enables the creation of a custom System.ServiceModel.FaultException{TDetail}
        /// that is returned from an exception in the course of a service method.
        /// </summary>
        /// <param name="error">The System.Exception object thrown in the course of the service operation.</param>
        /// <param name="version">The SOAP version of the message.</param>
        /// <param name="fault">The System.ServiceModel.Channels.Message object that is returned to the client, or service in duplex case</param>
        public void ProvideFault(Exception error, System.ServiceModel.Channels.MessageVersion version, ref System.ServiceModel.Channels.Message fault)
        {
            if (error is FaultException<ApplicationServiceError>)
            {
                MessageFault messageFault = ((FaultException<ApplicationServiceError>)error).CreateMessageFault();

                //propagate FaultException
                fault = Message.CreateMessage(version, messageFault, ((FaultException<ApplicationServiceError>)error).Action);
            }
            else
            {
                //create service error
                ApplicationServiceError defaultError = new ApplicationServiceError()
                {
                    ErrorMessage = Resources.Messages.message_DefaultErrorMessage
                };

                //Create fault exception and message fault
                FaultException<ApplicationServiceError> defaultFaultException = new FaultException<ApplicationServiceError>(defaultError);
                MessageFault defaultMessageFault = defaultFaultException.CreateMessageFault();

                //propagate FaultException
                fault = Message.CreateMessage(version, defaultMessageFault, defaultFaultException.Action);
            }
        }
開發者ID:gabrielsimas,項目名稱:MicrosoftNLayerApp,代碼行數:32,代碼來源:ApplicationErrorHandler.cs

示例4: ExceptionDetail

 void IErrorHandler.ProvideFault(Exception error, MessageVersion version, ref Message fault)
 {
     this.ErrorGuid = Guid.NewGuid();
     FaultException<ExceptionDetail> faultException = new FaultException<ExceptionDetail>(new ExceptionDetail(error) { Message = this.ErrorGuid.ToString() }, new FaultReason("ServiceError"));
     MessageFault messageFault = faultException.CreateMessageFault();
     fault = Message.CreateMessage(version, messageFault, faultException.Action);
 }
開發者ID:qianlb,項目名稱:webcode,代碼行數:7,代碼來源:ErrorHandlerBehaviorAttribute.cs

示例5: ProvideFault

      /// <summary>
      ///    Enables the creation of a custom System.ServiceModel.FaultException{TDetail}
      ///    that is returned from an exception in the course of a service method.
      /// </summary>
      /// <param name="error">The System.Exception object thrown in the course of the service operation.</param>
      /// <param name="version">The SOAP version of the message.</param>
      /// <param name="fault">
      ///    The System.ServiceModel.Channels.Message object that is returned to the client, or service in
      ///    duplex case
      /// </param>
      public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
      {
         if (error is FaultException<ApplicationServiceError>)
         {
            var messageFault = ((FaultException<ApplicationServiceError>) error).CreateMessageFault();

            //propagate FaultException
            fault = Message.CreateMessage(
               version,
               messageFault,
               ((FaultException<ApplicationServiceError>) error).Action);
         }
         else
         {
            //create service error
            var defaultError = new ApplicationServiceError()
            {
               ErrorMessage = Messages.message_DefaultErrorMessage
            };

            //Create fault exception and message fault
            var defaultFaultException = new FaultException<ApplicationServiceError>(defaultError);
            var defaultMessageFault = defaultFaultException.CreateMessageFault();

            //propagate FaultException
            fault = Message.CreateMessage(version, defaultMessageFault, defaultFaultException.Action);
         }
      }
開發者ID:MyLobin,項目名稱:NLayerAppV2,代碼行數:38,代碼來源:ApplicationErrorHandler.cs

示例6: ProvideFault

        /// <summary>
        ///  Allows to add, modify, or suppress a fault message that is generated in response to an exception.
        /// </summary>
        /// <param name="error"></param>
        /// <param name="version"></param>
        /// <param name="fault"></param>
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            FaultException<PricingException> faultException =
                new FaultException<PricingException>(new PricingException(error.Message,error.InnerException));
            MessageFault messageFault = faultException.CreateMessageFault();

            fault = Message.CreateMessage(version, messageFault, faultException.Action);
        }
開發者ID:jonteho,項目名稱:ticketing-office,代碼行數:14,代碼來源:PricingErrorHander.cs

示例7: ProvideFault

        /// <summary>
        /// Enables the creation of a custom <see cref="T:System.ServiceModel.FaultException`1"/> that is returned from an exception in the course of a service method.
        /// </summary>
        /// <param name="error">
        /// The <see cref="T:System.Exception"/> object thrown in the course of the service operation.
        /// </param>
        /// <param name="version">
        /// The SOAP version of the message.</param>
        /// <param name="fault">
        /// The <see cref="T:System.ServiceModel.Channels.Message"/> object that is returned to the client, or service, in the duplex case.
        /// </param>
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            // Shield the unknown exception
            var faultException = new FaultException("Server error encountered. All details have been logged.");
            var messageFault = faultException.CreateMessageFault();

            fault = Message.CreateMessage(version, messageFault, faultException.Action);
        }
開發者ID:kapitanov,項目名稱:diploma,代碼行數:19,代碼來源:ErrorHandler.cs

示例8: ProvideFault

 public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
 {
     if (error is FaultException)
         return;
     FaultException faultException = new FaultException("A general service error occured");
     MessageFault messageFault = faultException.CreateMessageFault();
     fault = Message.CreateMessage(version, messageFault, null);
 }
開發者ID:dimafoot,項目名稱:EBusiness2,代碼行數:8,代碼來源:GlobalErrorHandler.cs

示例9: ProvideFault

        // Provide a fault. The Message fault parameter can be replaced, or set to null to suppress
        // reporting a fault.

        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            var newEx = new FaultException(
                $"Exception caught at GlobalErrorHandler{Environment.NewLine}Method: {error.TargetSite.Name}{Environment.NewLine}Message:{error.Message}");

            var msgFault = newEx.CreateMessageFault();
            fault = Message.CreateMessage(version, msgFault, newEx.Action);
        }
開發者ID:truller2010,項目名稱:Diversia,代碼行數:11,代碼來源:GlobalErrorHandler.cs

示例10: ProvideFault

 /// <summary>
 /// ProvideFault
 /// </summary>
 /// <param name="ex">ex</param>
 /// <param name="version">version</param>
 /// <param name="msg">msg</param>
 public void ProvideFault(Exception ex, MessageVersion version, ref Message msg)
 {
     //// 寫入log4net
     //log.Error("WCF異常", ex);
     Logging.LogHelper.WriteError(string.Empty, "WCF異常", ex);
     var newEx = new FaultException(string.Format("WCF接口出錯 {0}", ex.TargetSite.Name));
     MessageFault msgFault = newEx.CreateMessageFault();
     msg = Message.CreateMessage(version, msgFault, newEx.Action);
 }
開發者ID:deboe2015,項目名稱:Ctrip.SOA,代碼行數:15,代碼來源:GlobalExceptionHandler.cs

示例11: ProvideFault

        // Provide a fault. The Message fault parameter can be replaced, or set to
        // null to suppress reporting a fault.
        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            var newEx = new FaultException(
                string.Format("Exception caught at GlobalErrorHandler{0}Method: {1}{2}Message:{3}",
                             Environment.NewLine, error.TargetSite.Name, Environment.NewLine, error.Message));

            MessageFault msgFault = newEx.CreateMessageFault();
            fault = Message.CreateMessage(version, msgFault, newEx.Action);
        }
開發者ID:hardborn,項目名稱:MonitorManager,代碼行數:11,代碼來源:GlobalErrorHandler.cs

示例12: ProvideFault

        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            if (error is FaultException) return;
            if (!error.GetType().IsSerializable) return;

            FaultException<GeneralServerFault> faultExc = new FaultException<GeneralServerFault>(new GeneralServerFault(error), new FaultReason("Server Level Error"));
            MessageFault messageFault = faultExc.CreateMessageFault();
            fault = Message.CreateMessage(version, messageFault, faultExc.Action);
        }
開發者ID:higeneko2015,項目名稱:WcfSample,代碼行數:9,代碼來源:ErrorHandler.cs

示例13: ProvideFault

        public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
        {
            if (fault == null)
            {
                var fe = new FaultException<FaultException>(new FaultException(error.StackTrace));

                var mf = fe.CreateMessageFault();
                fault = Message.CreateMessage(version, mf, fe.Action);
            }
        }
開發者ID:huayumeng,項目名稱:ytoo.service,代碼行數:10,代碼來源:Service1.cs

示例14: ProvideFault

        /// <summary>
        /// ProvideFault
        /// </summary>
        /// <param name="ex">ex</param>
        /// <param name="version">version</param>
        /// <param name="msg">msg</param>
        public void ProvideFault(Exception ex, MessageVersion version, ref Message msg)
        {

            Loger.Error("Wcf異常", ex);
            //// 寫入log4net
            //log.Error("WCF異常", ex);
            var newEx = new FaultException(string.Format("WCF接口出錯 {0}", ex.TargetSite.Name + "=>msg:" + ex.Message));
            MessageFault msgFault = newEx.CreateMessageFault();
            msg = Message.CreateMessage(version, msgFault, newEx.Action);
        }
開發者ID:reckcn,項目名稱:DevLib.Comm,代碼行數:16,代碼來源:GlobalExceptionHandler.cs

示例15: ProvideFault

 public void ProvideFault(Exception error, MessageVersion version, ref Message fault)
 {
     ValidationException validationException = error as ValidationException;
     if (validationException != null)
     {
         FaultException<string> faultException = new FaultException<string>("Error: " + validationException.ValidationResult.ErrorMessage);
         MessageFault messageFault = faultException.CreateMessageFault();
         fault = Message.CreateMessage(version, messageFault, null);
     }
 }
開發者ID:GusLab,項目名稱:WCFSamples,代碼行數:10,代碼來源:ValidationAwareErrorHandler.cs


注:本文中的System.ServiceModel.FaultException.CreateMessageFault方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。