Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / June 2007

Tip: Looking for answers? Try searching our database.

Problem invoking method with reflection

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rotsey - 27 Jun 2007 07:36 GMT
Hi,

I am getting a  Exception has been thrown by the target of an invocation
error when invoking a method

Here is the crux of the code.

I realise it could be a few things, any one give me an idea where
to start looking.

rotsey

object obj;

Type type;

type = Type.GetType("TBR.NET." + formdef.TableName);

obj = Activator.CreateInstance(type);

if (obj == null)

throw new ApplicationException("Cannot create object for type " +
formdef.TableName);

int retval = (int)type.InvokeMember("Update",
BindingFlags.InvokeMethod,null, obj, null);
Alberto Poblacion - 27 Jun 2007 08:00 GMT
> I am getting a  Exception has been thrown by the target of an invocation
> error when invoking a method

   Typically this means that you succeeded in calling the method, but
something failed inside that method and threw an exception. Take a look at
the InnerException inside the Exception that you received to find out more
about what failed inside your method.
Jon Skeet [C# MVP] - 27 Jun 2007 08:06 GMT
On Jun 27, 7:36 am, "Rotsey"
<malcolm_sm...@RemoveThis.optusnet.com.au> wrote:
> I am getting a  Exception has been thrown by the target of an invocation
> error when invoking a method

Obvious next question: what does the inner exception say? That should
make it a lot clearer what's going wrong.

Jon
Rotsey - 27 Jun 2007 08:28 GMT
of course. bit slow today soory

> On Jun 27, 7:36 am, "Rotsey"
> <malcolm_sm...@RemoveThis.optusnet.com.au> wrote:
[quoted text clipped - 5 lines]
>
> Jon

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.