本文整理汇总了C#中System.Reflection.TargetInvocationException类的典型用法代码示例。如果您正苦于以下问题:C# TargetInvocationException类的具体用法?C# TargetInvocationException怎么用?C# TargetInvocationException使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TargetInvocationException类属于System.Reflection命名空间,在下文中一共展示了TargetInvocationException类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
示例16: HandleException
private static void HandleException(ref RunningResults results, TargetInvocationException ex)
{
HandleInnerException(ref results, (dynamic)ex.InnerException);
}
开发者ID:andgein,项目名称:uLearn,代码行数:4,代码来源:RunningResultsExtention.cs
示例17: UnwrapTargetInvocationException
/// <summary>
/// Unwraps the supplied <see cref="System.Reflection.TargetInvocationException"/>
/// and returns the inner exception preserving the stack trace.
/// </summary>
/// <param name="ex">
/// The <see cref="System.Reflection.TargetInvocationException"/> to unwrap.
/// </param>
/// <returns>The unwrapped exception.</returns>
public static Exception UnwrapTargetInvocationException(TargetInvocationException ex)
{
#if NET_2_0
if (SystemUtils.MonoRuntime)
{
return ex.InnerException;
}
Exception_InternalPreserveStackTrace.Invoke(ex.InnerException, new Object[] { });
#else
Exception_RemoteStackTraceString.SetValue(ex.InnerException, ex.InnerException.StackTrace + Environment.NewLine);
#endif
return ex.InnerException;
}
开发者ID:hazzik,项目名称:nh-contrib-everything,代码行数:21,代码来源:ReflectionUtils.cs
示例18: SwallowedException
/// <summary>
/// Called when an exception was swallowed.
/// </summary>
/// <param name="targetInvocationException">The target invocation exception.</param>
/// <param name="message">The message.</param>
/// <param name="controlledModule">The controlled module.</param>
public void SwallowedException(TargetInvocationException targetInvocationException, object message, object controlledModule)
{
this.log.DebugFormat("Swallowing exception {0} that occurred consuming message {1} of module {2}.", targetInvocationException, message, controlledModule);
}
开发者ID:tiger2soft,项目名称:bbv.Common,代码行数:10,代码来源:Log4NetAsyncModuleLogExtension.cs
示例19: FormatTargetInvocationException
static string FormatTargetInvocationException(TargetInvocationException exception)
{
var i = exception.InnerException;
return string.Format("{0}: {1}", i.GetType().Name, i.Message);
}
开发者ID:JeetKunDoug,项目名称:lokad-cqrs,代码行数:5,代码来源:ExpressionParser.cs
示例20: ParseXml
private void ParseXml(XmlTextReader reader) {
bool success = false;
try {
try {
while (reader.Read()) {
if (reader.NodeType == XmlNodeType.Element) {
string s = reader.LocalName;
if (reader.LocalName.Equals(ResXResourceWriter.AssemblyStr)) {
ParseAssemblyNode(reader, false);
}
else if (reader.LocalName.Equals(ResXResourceWriter.DataStr)) {
ParseDataNode(reader, false);
}
else if (reader.LocalName.Equals(ResXResourceWriter.ResHeaderStr)) {
ParseResHeaderNode(reader);
}
else if (reader.LocalName.Equals(ResXResourceWriter.MetadataStr)) {
ParseDataNode(reader, true);
}
}
}
success = true;
}
catch (SerializationException se) {
Point pt = GetPosition(reader);
string newMessage = SR.GetString(SR.SerializationException, reader[ResXResourceWriter.TypeStr], pt.Y, pt.X, se.Message);
XmlException xml = new XmlException(newMessage, se, pt.Y, pt.X);
SerializationException newSe = new SerializationException(newMessage, xml);
throw newSe;
}
catch (TargetInvocationException tie) {
Point pt = GetPosition(reader);
string newMessage = SR.GetString(SR.InvocationException, reader[ResXResourceWriter.TypeStr], pt.Y, pt.X, tie.InnerException.Message);
XmlException xml = new XmlException(newMessage, tie.InnerException, pt.Y, pt.X);
TargetInvocationException newTie = new TargetInvocationException(newMessage, xml);
throw newTie;
}
catch (XmlException e) {
throw new ArgumentException(SR.GetString(SR.InvalidResXFile, e.Message), e);
}
catch (Exception e) {
if (ClientUtils.IsSecurityOrCriticalException(e)) {
throw;
} else {
Point pt = GetPosition(reader);
XmlException xmlEx = new XmlException(e.Message, e, pt.Y, pt.X);
throw new ArgumentException(SR.GetString(SR.InvalidResXFile, xmlEx.Message), xmlEx);
}
}
}
finally {
if (!success) {
resData = null;
resMetadata = null;
}
}
bool validFile = false;
if (object.Equals(resHeaderMimeType, ResXResourceWriter.ResMimeType)) {
Type readerType = typeof(ResXResourceReader);
Type writerType = typeof(ResXResourceWriter);
string readerTypeName = resHeaderReaderType;
string writerTypeName = resHeaderWriterType;
if (readerTypeName != null &&readerTypeName.IndexOf(',') != -1) {
readerTypeName = readerTypeName.Split(new char[] {','})[0].Trim();
}
if (writerTypeName != null && writerTypeName.IndexOf(',') != -1) {
writerTypeName = writerTypeName.Split(new char[] {','})[0].Trim();
}
// Don't check validity, since our reader/writer classes are in System.Web.Compilation,
// while the file format has them in System.Resources.
#if SYSTEM_WEB
validFile = true;
#else
if (readerTypeName != null &&
writerTypeName != null &&
readerTypeName.Equals(readerType.FullName) &&
writerTypeName.Equals(writerType.FullName)) {
validFile = true;
}
#endif
}
if (!validFile) {
resData = null;
resMetadata = null;
throw new ArgumentException(SR.GetString(SR.InvalidResXFileReaderWriterTypes));
}
}
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:97,代码来源:ResXResourceReader.cs
注:本文中的System.Reflection.TargetInvocationException类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论