Hi,
When I call a method(present in external DLL) through reflection which having no parameters and void return ,it get called fine but in same DLL when I call a method which have no parameters but return type Datatable then I got the 'TargetInvocation' exception.
Can anybody help me ?
nitin2010
0
Newbie Poster
Recommended Answers
Jump to PostThe TargetInvocationException tells you that the method you are calling has thrown an exception. Check the InnerException property of the exception to find out what the underlying cause might have been.
Jump to Postits the line
dt_Temp.Rows.Add(23,45);
that is throwing the exception. You are adding 2 values to the datatable but the datatable doesnt have 2 columns.
Try this:Datatable dt_Temp = new DataTable(); dt_Temp.Columns.Add(); //optionally use Columns.Add("name here") to name your columns dt_Temp.Columns.Add(); dt_Temp.Rows.Add(23, 45);
All 5 Replies
Geekitygeek
480
Nearly a Posting Virtuoso
nitin2010
0
Newbie Poster
Geekitygeek
480
Nearly a Posting Virtuoso
nitin2010
0
Newbie Poster
nitin2010
0
Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.