Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Exception has been thrown by the target of an invocation.

Exception has been thrown by the target of an invocation.

Scheduled Pinned Locked Moved C#
helpphpdatabasecomdebugging
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MichCl
    wrote on last edited by
    #1

    I did some cleanup in my code, and now I'm getting the above error message, but I'm having trouble seeing the reason. I searched the internet and found this article, but I don't see that I'm having that issue. http://www.softwareandfinance.com/forums/index.php?topic=314.0[^] In my Program.cs class, I have the following lines of code.

                Control control = new Control();
                Assembly \_assembly = Assembly.LoadFrom(programDll);
                Type \_type = \_assembly.GetType("CWriter.ProgramControl");
                //problem here?
                Object \_objectInstance = Activator.CreateInstance(\_type); //exception thrown
    

    I tried adding a breakpoint in the ProgramControl constructor, but it doesn't get hit. The constructor doesn't have any arguments to it.

    P 1 Reply Last reply
    0
    • M MichCl

      I did some cleanup in my code, and now I'm getting the above error message, but I'm having trouble seeing the reason. I searched the internet and found this article, but I don't see that I'm having that issue. http://www.softwareandfinance.com/forums/index.php?topic=314.0[^] In my Program.cs class, I have the following lines of code.

                  Control control = new Control();
                  Assembly \_assembly = Assembly.LoadFrom(programDll);
                  Type \_type = \_assembly.GetType("CWriter.ProgramControl");
                  //problem here?
                  Object \_objectInstance = Activator.CreateInstance(\_type); //exception thrown
      

      I tried adding a breakpoint in the ProgramControl constructor, but it doesn't get hit. The constructor doesn't have any arguments to it.

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      Wrap the Activator.CreateInstance in a try/catch block and then take a look at the full exception. Is there an InnerException that provides more details (there should be)?

      *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

      M 1 Reply Last reply
      0
      • P Pete OHanlon

        Wrap the Activator.CreateInstance in a try/catch block and then take a look at the full exception. Is there an InnerException that provides more details (there should be)?

        *pre-emptive celebratory nipple tassle jiggle* - Sean Ewington

        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

        CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

        M Offline
        M Offline
        MichCl
        wrote on last edited by
        #3

        That helped a lot. Thanks! It looks like it can't find a file that the class it's trying to invoke is trying to use. I had pulled some code into it's own SerialNumber class. That's the problem. Thank you!

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups