Nooto's Blog

Medal of Honor Allied Assault Gallery »

.Net Framework error “Could not load file or assembly”

Recently I had some trouble with a computer at work. The machine was running Windows XP Professional with the last updates (01-2011) and .Net Framework 3.5 SP1.

The problem was with a program called Pimphony, made by Alcatel. It talks with the Alcatel Omni PCX phone system we have, it shows the user who is calling, missed calls and other things. It always worked fine on this computer up until now.

When trying to start Alcatel Pimphony the following error would show:

Runtime error 8007000b (0x8007000B)
Could not load file or assembly ‘0 bytes loaded from System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ or one of its dependencies.
 
After some googling I found that this is a BadImageFormatException. No clue what that is though. I checked if other .Net programs had the same problem, but they were still working fine. 

I first try all the basic things: rebooting, try with different user account, repair application, reinstall application. But no change. Still the same error.

After some more googling other users were reporting the same problem when installing .Net 3.5 SP1 on webservers, .Net 2.0 on Windows 2000, when  installing Visual Studio 2008 after 2010.  None of this really applied to this simple workstation.

Microsoft Connect had some suggestions to run this command to try repair WCF part of .Net:

C:\Windows\Microsoft.NET\Framework\v3.0\Windows Communication Foundation\ServiceModelReg.exe” /r /x

This gave me a new error message: Configuration system failed to initialize. Now i’m thinking the whole framework got borked somehow and needs reinstalling. So I uninstalled all frameworks in reverse order like a good sysadmin, and then reinstall from the 3.5 SP1 redistributable… After 2 reboots and 30 minutes of reinstalling I launch the application again hoping it will start. Instead i’m faced with a new error popup:

System.Configuration.ConfigurationErrorsException: Unrecognized configuration section system.serviceModel. (c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Config\machine.config line 146)

Sweet, a new error.  I navigate my way to the folder and open the config file in notepad and scroll down to line 146. This line has some ServiceModel information. This is used by WCF, which Pimphony uses to communicate with the phone system (I think). Checking the machine.config on another machine with the same configuration I find that the broken machine has some missing “sectionGroup” lines. So I copy the missing lines from the working config to the broken config and try again. I launch the application and what do I get?

Runtime error 8007000b (0x8007000B)
Could not load file or assembly ‘0 bytes loaded from System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089’ or one of its dependencies. An attempt was made to load a program with an incorrect format…

Doh! Now I’m back where I started. 🙁 I try several more things: uninstall the .Net Framework using the .Net cleanup tools on the internet, clearing temp folders, deleting the assembly folder and it’s contents, clearing registry subkeys that have anything to do with the program. All to no avail, I still get the same error.

After an hour of googling for b77a5c561934e089BadImageFormatException and other keywords I hit upon a newsgroup post about problems with csc.exe not producing any output. Someone called Jonathan Gilbert explains that his csc.exe didn’t work due to a fake antivirus messing around with his system and blocking valid process names like csc.exe.

I didn’t see a fake antivirus in my task manager, but when I did a Malwarebytes scan on the machine it did come up with about 20  Security.Hijack messages in the follow registry keys:

HKCU\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\Explorer\DisallowRun
and
HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options

In here was csc.exe among other processes. After clearing these “infections” and rebooting, Pimphony started up again like nothing ever happened. W00t! 🙂  Well almost anyway, it had lost all settings because I deleted the registry key for it more times than I can count 😮

My job wasn’t finished yet though. I still had to spend another 30 minutes to restore all the damage I caused when trying to “fix” the problem 🙁

February 7, 2011 at 18:49
5 comments »
  • July 4, 2011 at 11:11Darrell

    Had the same issue and the above solution worked for me as well…. Thank You So Much….!!! Very Much Appreciated.

  • February 22, 2012 at 14:12jaz

    Wow, that hint is HOT! Removing csc.exe in HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Image File Execution Options did the trick. you saved me hours of googling and thousands of nerves. Thank you so much!

  • August 15, 2012 at 21:41Chris

    Thank you for posting this. You saved me a ton of time and serching. Thanks

  • November 26, 2012 at 21:52teri

    This worked for me as well…. Wow..

  • September 30, 2013 at 04:51Jason

    worked like a lucky charm! thanks!

Leave a Reply or trackback

highslide for wordpress