none
BadImageFormatException using SSMS: how to dig deeper? RRS feed

  • Question

  • I loaded VS2010, and then installed the latest SqlExpressR2SP1 bits (SQLEXPRWT_x64_ENU.exe). I'm running Windows7 64 bit.

    I have this annoying problem that when I run Management Studio, if I click on NewQuery or Select Top 1000 I get a null reference exception, reported in the default exception dialog.  (Strangely, the Edit Top 200 option works).

    This seemed like a good time to try out the reflector disassembler capability I'd been meaning to learn about for some time now (having become a mostly manager rather than a mostly coder), which resulted in me getting over my head pretty quickly!  I think I've found the root cause of the problem, but I don't know how to interpret it so that I can take futher action to solve the problem.  I think the image below should be self-explanatory for the problem description.  My guess is that its something to do with 64/32 bit configuration anomalies, but regardless, can anyone suggest what I might do next?


    • Edited by mickan Thursday, April 26, 2012 3:48 PM
    Thursday, April 26, 2012 3:47 PM

Answers

  • I never did solve the specific problem definitively, but futher research suggested that my SSD drive was deteriorating, so I concluded that perhaps the file was simply corrupted therefore was indeed a "bad image".  My Corsair Reactor SSD has a very bad rap on the blogs, and now I'm running well so far with a Patriot Pyro Sata 3.

    • Marked as answer by mickan Tuesday, May 8, 2012 12:36 PM
    Tuesday, May 8, 2012 12:36 PM

All replies

  • Let me check if I understand your question: You have standard installation of SQL Express. Management Studio is SQL tool which fails for you. There are not any customization (i.e. your code) running in that tool.

    If that's the case I would strongly suggest to ask on SQL forums and/or file a bug on Microsoft Connect against SQL.

    If you want to debug this Microsoft code yourself, you will probably have lots of fun. Before you waste more time I would check if it is problem only on 1 machine (to rule out HW errors like corrupted .NET, SQL or OS installation).
    In general: If you need to chase down BadImageFormat exception - check how it is loaded (which Assembly.Load* API vs. static reference). Check that the architecture of the reference is correct (either MSIL, or x86 in x86 process, or x64 in x64 process) - you may need to use tools like ildasm/Reflector.

    -Karel

    • Proposed as answer by Mike FengModerator Friday, April 27, 2012 8:35 AM
    • Unproposed as answer by mickan Friday, April 27, 2012 12:31 PM
    Thursday, April 26, 2012 6:00 PM
    Moderator
  • Karel, thanks for taking the time to respond.  I did post this on the SqlExpress forum late last week, but didn't get any closer to a resolution. I think its reasonable to asume this is because its one of those strange install issues where some combinaiton of service packs and release versions that are released years apart just interact badly, in the dll-hell vein.  Most of the product groups seem to get stuck on these kinds of issues due to he difficulaty of reproducing the load scenario, not unreasonably so.  Thats why I thought I'd give it a try on the CLR forum, in case anyone had seen this kind of thing and could give some "ah-ha" moment suggestions.  As my question has been posted for a couple of days now then I think that window of opportunity has gone.

    I'll dig in a bit further with reflector, I'm not sure why the stack trace ends where it does and not in some assembly load code as you suggest. 

    Friday, April 27, 2012 12:39 PM
  • Hi Mickan,

    did you find something?

    Have a lucky day.


    Ghost,
    Call me ghost for short, Thanks
    To get the better answer, it should be a better question.

    Tuesday, May 8, 2012 12:11 PM
  • I never did solve the specific problem definitively, but futher research suggested that my SSD drive was deteriorating, so I concluded that perhaps the file was simply corrupted therefore was indeed a "bad image".  My Corsair Reactor SSD has a very bad rap on the blogs, and now I'm running well so far with a Patriot Pyro Sata 3.

    • Marked as answer by mickan Tuesday, May 8, 2012 12:36 PM
    Tuesday, May 8, 2012 12:36 PM