locked
Exception has been thrown by the target of an invocation

    Întrebare

  • Hi,

    I am getting an error message "Exception has been thrown by the target of an invocation" when my application is loading a vb.net 2005 form.

    I am using vb.net 2005 with SP1, and framework version v2.0.50727

     

    Any idea what could be causing this?

     

    Thanks

    1 februarie 2007 14:32

Răspunsuri

  • When the exception is thrown and caught in the IDE, check the InnerException property.  Please post the name, message and stack trace of the inner exception as that's going to provide the most information about the problem.
    1 februarie 2007 16:41

Toate mesajele

  • This is usually the exception you get when a constructor throws an exception.

    Try catching the exception.  You usually get some more extended information on what exception was thrown etc.

    1 februarie 2007 16:05
  • This is thrown by the constructor, when calling InitializeComponent() routine.

    However, thats all the information I am getting.

    I did a cleanbuild and then a build, and it builds fine. But I still get the error, when I run the app.

    This is a windows application, in vb2005 with SP 1

     

    Any thoughts?

    1 februarie 2007 16:24
  • Have you tried stepping through the InitializeComponent routine to see where it fails?

    I'd have to edge my bets that it probably stems from an out of date reference of some kind. 

    1 februarie 2007 16:32
  • When I step thru the code, it doesnt actually go inside InitializeComponent(), the procedure for that resides in the designer.vb page.

    Are you saying that a component may be outdated?

    Never came across anything like that in the past, but I have tried checking for out of date references, but cant find anything.

    1 februarie 2007 16:40
  • When the exception is thrown and caught in the IDE, check the InnerException property.  Please post the name, message and stack trace of the inner exception as that's going to provide the most information about the problem.
    1 februarie 2007 16:41
  • You can still access the InitializeComponent method .. your form is a partial class and the method is hidden by default.

    You'll probably find it is decorated with a DebuggerStepThrough style attribute, hence why you do not normally step into it.  Remove it and you should be ok to step in at runtime.

    1 februarie 2007 16:59
  • ok, the part of checking the InnerException property helped big time. The problem was resolved. I had added a project to my solution, and an assembly of the new project was being referenced. That assembly could not be found. So I created that.

    However, I would like to clarify something for my own information.

    Currently I have a solution file, that contains 5or 6 projects within the solution file. I add an existing project to my solution file, do a clean build (of the solution), then do a build (of the solution), and then do a "rebuild the solution". Shouldnt that process create the required assemblies of the projects within my solution?

    Or do I have to manually create the assemblies, every time I add an existing project to my solution?

     

    Thanks very much for everybody's help.

    1 februarie 2007 17:25
  • I get the following error when trying to run the Unit tests in VS 2008 for a VB.NEt solution:

    Exception has been thrown by the target of an invocation.

    Please help if anyone has faced this issue earlier ?

    16 august 2012 10:11