Wrox Programmer Forums
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 30th, 2003, 01:38 PM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default Reflection

Hi,

I'm invoking a method of a class using reflection and in this method
I'm trying thrown an exception with an specifc message but the exception message in the caller of this method is always "Exception has been thrown by the target of an invocation."


Thank's

Fabio Ferreira Balota
__________________
Fabio Ferreira Balota
 
Old January 3rd, 2004, 08:06 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 453
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Ankur_Verma Send a message via MSN to Ankur_Verma
Default

You are getting that exeption message becuase thats actually the exeption messagse. Its indeed the target of invocation that has thrown the exception. If you want to access the message that you threw with your exeption you can do that with the InnerException property like this.

  catch(Exception ex)
  {
Console.WriteLine(ex.InnerException.Message);

Ankur Verma
.Net and C++ Specialist
Wiley Tech Support
 
Old January 8th, 2004, 03:07 PM
Authorized User
 
Join Date: Jun 2003
Posts: 13
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Tank you Ankur!!!

Fabio Ferreira Balota





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using System.Reflection maxl Pro Visual Basic 2005 0 March 21st, 2007 05:42 PM
Reflection-TargetInvocationException dipak_2111 C# 2005 0 January 11th, 2007 01:08 AM
Reflection jayakumar.cj ASP.NET 1.0 and 1.1 Basics 1 July 15th, 2006 06:12 AM
Reflection and WebControl jdang67 ASP.NET 2.0 Professional 1 October 20th, 2005 04:14 PM
Attributes and Reflection eadred General .NET 0 July 22nd, 2005 01:53 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.