none
Error while building DLL :: Exception has been thrown by the target of an invocation RRS feed

  • Question

  • I am creating a DLL in .NET 3.5 framework. However, while I am trying to build the DLL, I am getting the error "Exception has been thrown by the target of an invocation".
    • Moved by edhickey Thursday, December 9, 2010 4:23 PM (From:.NET 3.0/3.5 Windows Workflow Foundation)
    • Changed type Kaushik Ganguli Thursday, December 9, 2010 5:07 PM
    • Moved by edhickey Thursday, December 9, 2010 5:10 PM (From:Off-Topic Posts (Do Not Post Here))
    Thursday, December 9, 2010 4:03 PM

Answers

  • Hi,

    If you are creating some class libraries and got them built into dll, the way to reference them is to add the dll to your current project as reference.

    I am not sure why your dll is not registered since only com need to be registered or if you are trying to put your assembly into GAC, then the assembly need to to SN and register as well.

    Thanks

    Binze


    Binze Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bin-ze Zhao Friday, December 17, 2010 3:31 AM
    Thursday, December 16, 2010 5:10 AM

All replies

  • What language are you using too develop this .DLL?  This is a Windows Workflow Forum, so I will need to move your post to where you can get an answer.
    Ed Hickey http://blogs.msdn.com/b/edhickey/archive/2010/04/21/how-to-post-effectively-in-forums.aspx
    Thursday, December 9, 2010 4:12 PM
  • The error you mentioned can be due to the following issues. 

    • You are trying to build your application in .Net Framework 3.5 and the DLL was build in .Net Framework 2.0. 
    • If you calling the database, make sure that a value is being returned from the database, otherwise this error would occur.

    And these all can be recognized from the inner exception of the exception you are getting.

    You can also try the procedure described in the following article:

    http://www.geekpedia.com/KB70_Exception-has-been-thrown-by-the-target-of-an-invocation.html

     

    Regards,

    Samreen

     


    Friday, December 10, 2010 4:14 AM
  • No, Samreen.. I looked into all the options you gave and nothing worked.

    I am getting this error "Exception has been thrown by the target of an invocation" while building the DLL itself (both in debug and release mode), and not in any application. The DLL has .csproj project file, so it will be built in 3.5 framework only.

    The DLL is calling the database, bt I am unable to debug or built the DLL to reach the step wherein I can check if correct value is being returned. The DLL has a third party VB COM DLL added as reference. It doesnt have Invoke() method, no the link is of no help either.


    Thanks & Regards, Kaushik Ganguli, MCTS (ASP.net, SQL Server)
    Friday, December 10, 2010 10:17 AM
  • Hi,

    I guess the problem is happen with the third party VB COM DLL, try to delete the reference to see whether you can get the dll built, if yes then you need to consult the COM dll provide for this problem.

    If the problem still exist try to copy the code to a new project and build it again.

    Thanks

    Binze


    Binze Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, December 14, 2010 6:53 AM
  • Thanks Binze.

    The current situation is: after coping the code in a separate project, the DLL is getting built; but I am unable to register the DLL.

    Neither the Debug version, nor the Release version are getting registered. Though I am able to built the DLL error-free, I am unable to use the DLL in any other application. The DLL is not getting instanciated from other applications.


    Thanks & Regards, Kaushik Ganguli, MCTS (ASP.net, SQL Server)
    Tuesday, December 14, 2010 3:29 PM
  • Hi,

    Actully this is not issue in the code. If you use any other third party component, You need to specify the strong name key (snk).

     


    With Regards, DP
    Tuesday, December 14, 2010 3:36 PM
  • No, I am not using any 3rd party DLL now. I removed that and all references to that.

    Now, the only thing thats there in the code are the classes and functions for this DLL in 3.5 framework. I have a setup project as well, and two build configurations: Debug and Release. Neither of the DLL's created are getting registered.

    The DLL that I am building is not getting registered.


    Thanks & Regards, Kaushik Ganguli, MCTS (ASP.net, SQL Server)
    Tuesday, December 14, 2010 5:01 PM
  • Hi,

    If you are creating some class libraries and got them built into dll, the way to reference them is to add the dll to your current project as reference.

    I am not sure why your dll is not registered since only com need to be registered or if you are trying to put your assembly into GAC, then the assembly need to to SN and register as well.

    Thanks

    Binze


    Binze Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bin-ze Zhao Friday, December 17, 2010 3:31 AM
    Thursday, December 16, 2010 5:10 AM