当前位置: 首页>>代码示例>>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;未经允许,请勿转载。