dcsimg
Results 1 to 4 of 4

Thread: [RESOLVED] Can't instantiate CookieContainer

  1. #1

    Thread Starter
    Fanatic Member cory_jackson's Avatar
    Join Date
    Dec 2011
    Location
    Fallbrook, California
    Posts
    723

    Resolved [RESOLVED] Can't instantiate CookieContainer

    I have a small class that retrieves web pages for me. In it I have
    "Private objCookies As New CookieContainer"
    It's been working all night and I haven't done any work that relates to it. At least not as far as I can tell. Now when I instantiate it blows up into the Disassembler.
    System.Reflection.TargetInvocationException was unhandled
    Message: An unhandled exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll
    Additional information: Exception has been thrown by the target of an invocation.
    And I don't understand how to use the disassembler to tell much more.
    Any ideas what it could be or how I can get more information from VS on what's going wrong?

  2. #2
    .NUT jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    100,984

    Re: Can't instantiate CookieContainer

    A TargetInvocationException is thrown on the calling thread when an exception is thrown and not caught in a method invoked on a different thread. The fact that is breaks to the disassembler seems to suggest that it's not your code that's doing it though. Are you able to get any additional information about the exception? The InnerException property may contain the original exception.

  3. #3

    Thread Starter
    Fanatic Member cory_jackson's Avatar
    Join Date
    Dec 2011
    Location
    Fallbrook, California
    Posts
    723

    Re: Can't instantiate CookieContainer

    Now that you helped me solve the other problem. I can make this more reliably! :-)

    I am seeing something else. This is strange. When I'm in the class that's instantiating this class. I command "Dim objGunner As New Retriever". AS soon as it jumps to the New method in the Retreiver class, I get "A first chance exception of type 'System.InvalidCastException' occurred in Microsoft.VisualBasic.dll" Huh? That's odd. At this point the first line "Public Sub New()" is highlighted. But it gets stranger. When I continue to hit F8, it jumps up to the declarations. It sets a few variables, a list of WebProxy and then when it gets to "Private objCookies As New CookieContainer", BAM! Dissasembly window pops up. If I copy the exception, it's what I showed you in the first post. I can't put a "try" block around it to catch exceptions.

    But now I see 3 exceptions in an unrelated area. THis is in a Background Worker and the progress report is complaining, I'm sure something I did wrong, and I should fix those first. I can't imagine how that could be related, but please don't think on this anymore until I can solve the other invalid cast exception. And it's time to sleep. Thanks for your help.

  4. #4

    Thread Starter
    Fanatic Member cory_jackson's Avatar
    Join Date
    Dec 2011
    Location
    Fallbrook, California
    Posts
    723

    Re: Can't instantiate CookieContainer

    I found it. A few lines before instantiating this object I called the ReportProgress method of the background worker. Several lines into it, I was trying to cast invalid string to an integer. And doing F8 in the debugger took me into instantiating the retriever. Weird. Maybe since they're parallel threads it was the same number of steps in? I can't figure it out. But as soon as I fixed my mistake in the ReportProgress method, the retriever worked fine.
    Anyway thanks for your help. I'll sleep better now.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width