Click here to Skip to main content
16,018,442 members
Please Sign up or sign in to vote.
1.40/5 (3 votes)
See more: , +
I have a winforms application which was working fine. Recently i formatted my system and reinstalled VS 2008. From that time the application has stopped running.
When i run it through VS it gives error

"exception has been thrown by the target of an invocation."

I went on to debug and found that in the this exception comes when from c# code using reflection the code tries to invoke a function from an assembly which is written in c++.
Posted
Updated 20-Sep-22 20:08pm
v2
Comments
Member 11698388 28-Oct-17 7:27am    
knlknlk

Eventually I solved this myself. It was just a matter of getting to the root of the problem.
Actually the cuase of this exception was another exception which occured inside the method being invoked.

So i went to look out for solution by searching the exception ex.innerexception .
From there i searched the stack trace of that exception to finnaly get to the root of the problem.

So anyone getting this error do look for the innerexception cause the real problem lies there.


Thanks,
Mateen
 
Share this answer
 
Comments
Nelek 16-Mar-12 14:45pm    
Thank you for posting your own solution. 5 for it
Basics Learner 16-Aug-13 7:01am    
Thanks saved me !
thams 24-May-12 0:59am    
Thanks a ton. Saved me lot of time. Just went to the inner exception and found the problem. My problem is with threading. Thanks again.
MAYANK GEETE 11-Sep-13 6:33am    
I am New To WPF and i am working on it but it gives the same error "Exception has been thrown by the target of an invocation." it is a simple program to show data (that is stored in database) to datagrid in wpf. can u plz help?
thanks in advance
Member 14851467 9-Jun-21 8:40am    
Thank you. Your solution worked for me too. I previously was running a code synchronously and decided to change it and run in async mode because I added an activity indicator to display while the task is going on; only for my codes to start generating errors.
for the said error, we are talking about inner exception. How to get this inner exception?
running bat "${NUGET_HOME}/nuget.exe restore Dotsolution.sln from jenkins file and getting this error:

Error parsing solution file at D:\Jenkins\workspace\Dotsolution.sln: Exception has been thrown by the target of an invocation.
 
Share this answer
 
Disable the ajax for a moment (EnablePartialRendering="false" on the scriptmanager).


we Got Exception aftr that delete EnablePartialRendering property.
 
Share this answer
 
Great said by Mateen Khan, you need to understand what is you controls default value..


eg i'm using combobox in silverlight and i was trying to bind its selected index

as a default its selected index was -1

but it was get nothing from the respective property ...


I looked inside the inner exception and find out my solution
 
Share this answer
 
Comments
Thomas Daniels 21-Dec-12 8:39am    
Why do you answer to a question from May? The question is solved already, and the question has an accepted answer.
Elegantly Wasted 17-Oct-13 6:54am    
sharing my views..... thats it.... -_-

actually the solution helped me indeed... i just tried to tell what i came accross....

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900