I've got a .NET app that I have been developing for many years (about 15 projects, some of which are pretty large) and I have just encountered the following exception when trying to launch it.
System.BadImageFormatException was unhandled Message: Could not load file or assembly 'System.Runtime.Remoting, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. An attempt was made to load a program with an incorrect format.
There doesn't appear to be any call stack - this happens before launching into my code, so I can't even step in. I was using this DLL in some projects, but I have now gone through and completely removed all references to it, but I am still getting the error. It is only happening with this project (I can launch other projects within the solution ok and other projects from other solutions ok).
EDIT
After a lot of fiddling around, disabling the application framework in the application tab under My Project seems to allow it to launch, but I can't work out why. I do want to re-enable it as I make use of some of those features.
EDIT 2 After a lot more messing about, I think that it is caused by the application framework using remoting to enforce that it is a single instance application. However, .NET reflector seems to indicate that this shouldn't actually be run if I uncheck the single instance option but I still have the problem even if I do. That said, it does still go into the scope of the method which uses types from that assembly (Microsoft.VisualBasic.ApplicationServices.ApplicationBase.Run), so I presume that is what is causing it to try to resolve that assembly. Whilst all this is interesting, it doesn't really give any answer as to why I'm getting this exception. I've tried reproducing it with an empty project and that works fine - both set on the same application framework settings, both on .NET 4.0, both x86. I'm pretty stumped as to where to go from here.