I just spent a few hours trying to figure out an issue on a project I started a while back to automate the SQL replication setup for any servers we add to our environment. I started the project when I had some free time a few months ago, then got going on another project which took preference, and now finally have time to get going again. First thing I did after loading the solution was hit F5 to run it, making sure that everything is as it should. Also remembering that I left it in a working state when I put it on the back-burner.
Then I get this beauty
"Could not load file or assembly 'Microsoft.SqlServer.Replication, Version=220.127.116.11, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. An attempt was made to load a program with an incorrect format."
Now my first reaction was that I reinstalled my machine recently, upgrading from XP SP2 to Windows 2008 64-bit edition, so I double checked my installation of the SQL Server SDK, and the various other things that are referenced in this project, but no luck. AARRRRGGGHHH!!!
Boot up the XP VM, test the project there and it works like it should.
So, I went back to my dev environment and do what I should have done in the first place, click that friendly "Search for more help online". And first in the list is the description for the System.BadImageFormatException with a simple solution.
Turns out that the SQL Replication SDK was developed for 32bit platforms only, so go to the Project Properties, select the Build page and set the Target Platform to x86. Hit F5, and my project is back to a working state.