当前位置: 首页>>代码示例>>C#>>正文


C# Reflection.TargetInvocationException类代码示例

本文整理汇总了C#中System.Reflection.TargetInvocationException的典型用法代码示例。如果您正苦于以下问题:C# TargetInvocationException类的具体用法?C# TargetInvocationException怎么用?C# TargetInvocationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


TargetInvocationException类属于System.Reflection命名空间,在下文中一共展示了TargetInvocationException类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DontStripIfNoInnerException

        public void DontStripIfNoInnerException()
        {
            TargetInvocationException wrapper = new TargetInvocationException(null);

              List<Exception> exceptions = _client.ExposeStripWrapperExceptions(wrapper).ToList();
              Assert.AreEqual(1, exceptions.Count);
              Assert.Contains(wrapper, exceptions);
        }
开发者ID:nelsonsar,项目名称:raygun4net,代码行数:8,代码来源:RaygunClientTests.cs

示例2: HandleTargetInvocationException

 internal static void HandleTargetInvocationException(TargetInvocationException exception)
 {
     var innerException = exception.InnerException as SyncServiceException;
     if (innerException != null)
     {
         throw new SyncServiceException(innerException.StatusCode, innerException.ErrorCode, innerException.Message, exception);
     }
 }
开发者ID:yonglehou,项目名称:SyncFrameworkToolkit,代码行数:8,代码来源:ErrorHandler.cs

示例3: Inner

 /// <summary>
 /// Returns inner exception, while preserving the stack trace
 /// </summary>
 /// <param name="e">The target invocation exception to unwrap.</param>
 /// <returns>inner exception</returns>
 public static Exception Inner(TargetInvocationException e)
 {
     if (e == null) throw new ArgumentNullException("e");
     if (null != InternalPreserveStackTraceMethod)
     {
         InternalPreserveStackTraceMethod.Invoke(e.InnerException, new object[0]);
     }
     return e.InnerException;
 }
开发者ID:mojamcpds,项目名称:lokad-cqrs-1,代码行数:14,代码来源:InvocationUtil.cs

示例4: FailedTest

        static void FailedTest(TargetInvocationException ex, ref int counter)
        {
            Console.ForegroundColor = GetColor(Colors.Failed);
            Console.WriteLine(@"Failed");
            Console.WriteLine(ex.InnerException.Message);
            Console.ResetColor();

            counter++;
        }
开发者ID:sunriselink,项目名称:OLAProject,代码行数:9,代码来源:Program.cs

示例5: EvaluateException

 private void EvaluateException(bool expression, ExecuteParameters parameters, TargetInvocationException e)
 {
     if (expression) {
         Processor.TestStatus.MarkRight(parameters.Cell);
     }
     else {
         Processor.TestStatus.MarkWrong(parameters.Cell, "exception[" + e.InnerException.GetType().Name + ": \"" + e.InnerException.Message + "\"]");
     }
 }
开发者ID:nhajratw,项目名称:fitsharp,代码行数:9,代码来源:ExecuteException.cs

示例6: RemoveWrapperExceptions

        public void RemoveWrapperExceptions()
        {
            _client.RemoveWrapperExceptions(typeof(TargetInvocationException));

              TargetInvocationException wrapper = new TargetInvocationException(_exception);

              List<Exception> exceptions = _client.ExposeStripWrapperExceptions(wrapper).ToList();
              Assert.AreEqual(1, exceptions.Count);
              Assert.Contains(wrapper, exceptions);
        }
开发者ID:nelsonsar,项目名称:raygun4net,代码行数:10,代码来源:RaygunClientTests.cs

示例7: GetRealExceptionWithStackTrace

        public static Exception GetRealExceptionWithStackTrace(TargetInvocationException tiex)
        {
            var remoteStackTraceString = typeof(Exception).GetField("_remoteStackTraceString", BindingFlags.Instance | BindingFlags.NonPublic);

            remoteStackTraceString.SetValue(
                tiex.InnerException,
                tiex.StackTrace + Environment.NewLine
                );

            return tiex.InnerException;
        }
开发者ID:andreycha,项目名称:tangerine,代码行数:11,代码来源:ExceptionHelper.cs

示例8: GetAdviceForUser_ReturnsIntroTextAsFirstLine_Always

        public void GetAdviceForUser_ReturnsIntroTextAsFirstLine_Always()
        {
            var fileNotFoundException = new FileNotFoundException("message about missing styles", "dummyAssemblyStyles.dll");
            var xamlParseException = new XamlParseException("", fileNotFoundException);
            var targetInvocationException = new TargetInvocationException(xamlParseException);
            var missingPreloadException = new MissingPreloadException("", targetInvocationException);

            string adviceForUser = missingPreloadException.GetAdviceForUser();

            string[] lines = adviceForUser.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
            Assert.AreEqual(MissingPreloadException.IntroPartOfAdvice, lines[0]);
        }
开发者ID:kurattila,项目名称:Cider-x64,代码行数:12,代码来源:MissingPreloadException_Test.cs

示例9: StripAggregateExceptionAndTargetInvocationException

        public void StripAggregateExceptionAndTargetInvocationException()
        {
            _client.AddWrapperExceptions(typeof(AggregateException));

              OutOfMemoryException exception2 = new OutOfMemoryException("Ran out of Int64s");
              TargetInvocationException innerWrapper = new TargetInvocationException(exception2);
              AggregateException wrapper = new AggregateException(_exception, innerWrapper);

              List<Exception> exceptions = _client.ExposeStripWrapperExceptions(wrapper).ToList();
              Assert.AreEqual(2, exceptions.Count);
              Assert.Contains(_exception, exceptions);
              Assert.Contains(exception2, exceptions);
        }
开发者ID:nelsonsar,项目名称:raygun4net,代码行数:13,代码来源:RaygunClientTests.cs

示例10: Cozy

        public static void Cozy()
        {
            Console.WriteLine("\n-----------------------------------------------");
            Console.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.FullName);
            Console.WriteLine("-----------------------------------------------");

            System.Exception e1 = new Exception();
            System.ApplicationException e2 = new ApplicationException();
            e2 = null;
            System.Reflection.TargetInvocationException e3 = new TargetInvocationException(e1);
            System.SystemException e4 = new SystemException();
            e4 = null;
            System.StackOverflowException e5 = new StackOverflowException();
            e5 = null;
        }
开发者ID:xxy1991,项目名称:cozy,代码行数:15,代码来源:O1ExceptionClasses.cs

示例11: HandleSubscriberMethodException

        /// <summary>
        /// Handles a subscriber method exception by passing it to all extensions and re-throwing the inner exception in case that none of the
        /// extensions handled it.
        /// </summary>
        /// <param name="targetInvocationException">The targetInvocationException.</param>
        /// <param name="eventTopic">The event topic.</param>
        protected void HandleSubscriberMethodException(TargetInvocationException targetInvocationException, IEventTopicInfo eventTopic)
        {
            Ensure.ArgumentNotNull(targetInvocationException, "targetInvocationException");

            var innerException = targetInvocationException.InnerException;
            innerException.PreserveStackTrace();

            var context = new ExceptionHandlingContext();

            this.ExtensionHost.ForEach(extension => extension.SubscriberExceptionOccurred(eventTopic, innerException, context));
                
            if (!context.Handled)
            {
                throw innerException;
            }
        }
开发者ID:ursenzler,项目名称:eventbroker,代码行数:22,代码来源:EventBrokerHandlerBase.cs

示例12: ResolveTargetInvocationException

        public static Exception ResolveTargetInvocationException(TargetInvocationException ex)
        {
            if (SecurityManager.IsGranted(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess)))
            {
                FieldInfo remoteStackTrace = typeof (Exception).GetField("_remoteStackTraceString",
                                                                         BindingFlags.Instance | BindingFlags.NonPublic);

                remoteStackTrace.SetValue(ex.InnerException, ex.InnerException.StackTrace + "\r\n");

                return ex.InnerException;
            }
            else
            {
                return ex;
            }
        }
开发者ID:TheMouster,项目名称:mvc,代码行数:16,代码来源:ExceptionHelper.cs

示例13: UnwrapTargetInvokationException

 /// <summary>
 /// Unwraps the TargetInvocationException that reflection methods helpfully give us.
 /// </summary>
 /// <param name="tie">Exception to unwrap</param>
 /// <returns>A copy of the inner exception, for a few cases.</returns>
 public static Exception UnwrapTargetInvokationException(TargetInvocationException tie)
 {
     if (tie.InnerException.GetType() == typeof(DataStoreCastException))
     {
         DataStoreCastException orig = (DataStoreCastException)tie.InnerException;
         return new DataStoreCastException(orig.FromType, orig.ToType, tie);
     }
     else if (tie.InnerException.GetType() == typeof(DataNode.ValueNotInitialized))
     {
         DataNode.ValueNotInitialized orig = (DataNode.ValueNotInitialized)tie.InnerException;
         throw new DataNode.ValueNotInitialized(orig.key, tie);
     }
     else if (tie.InnerException.GetType() == typeof(NotSupportedException))
     {
         NotSupportedException orig = (NotSupportedException)tie.InnerException;
         throw new NotSupportedException(orig.Message, tie);
     }
     return null;
 }
开发者ID:linuxgurugamer,项目名称:ContractConfigurator,代码行数:24,代码来源:ExceptionUtil.cs

示例14: StripMultipleWrapperExceptions

        public void StripMultipleWrapperExceptions()
        {
            HttpUnhandledException wrapper = new HttpUnhandledException("Something went wrong", _exception);
              TargetInvocationException wrapper2 = new TargetInvocationException(wrapper);

              RaygunMessage message = _client.CreateMessage(wrapper2);
              Assert.AreEqual("System.NullReferenceException", message.Details.Error.ClassName);
        }
开发者ID:robfe,项目名称:raygun4net,代码行数:8,代码来源:RaygunClientTests.cs

示例15: StripTargetInvocationExceptionByDefault

        public void StripTargetInvocationExceptionByDefault()
        {
            TargetInvocationException wrapper = new TargetInvocationException(_exception);

              RaygunMessage message = _client.CreateMessage(wrapper);
              Assert.AreEqual("System.NullReferenceException", message.Details.Error.ClassName);
        }
开发者ID:robfe,项目名称:raygun4net,代码行数:7,代码来源:RaygunClientTests.cs


注:本文中的System.Reflection.TargetInvocationException类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。