views:

11933

answers:

6

The exact error is as follows

"Could not load file or assembly 'Microsoft.SqlServer.Replication, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. An attempt was made to load a program with an incorrect format."

I've recently started working on this project again after a two month move to another project. It worked perfectly before, and I've double checked all the references.

+22  A: 

I've found the solution. I've recently upgraded my machine to Windows 2008 Server 64-bit. The SqlServer.Replication namespace was written for 32-bit platforms. All I needed to do to get it running again was to set the Target Platform in the Project Build Properties to X86.

baldy
A: 

Yes I can concur with this solution - changing my VS2008 compilation settings to x86 for all libraries when on 64-bit windows 7 fixed this problem.

TriSys
+20  A: 

The answer above is correct, but you may also need to enable 32-bit applications in your AppPool.

See http://www.alexjamesbrown.com/uncategorized/could-not-load-file-or-assembly-chilkatdotnet2-or-one-of-its-dependencies-an-attempt-was-made-to-load-a-program-with-an-incorrect-format/

bboyle1234
This was the cause of the problem for me. Thanks soo much.
Neil Barnwell
+1 THANK YOU!!! :)
IanR
+2  A: 

Sorry, bboyle, up'ing your answer seems to demand 15 reputation of me. That stinks, cause your answer was as useful to me as the accepted answer for the questioneer:

  • Applications Pools, set Application pool defaults, Enable 32-bit applications -> true. Ta da!

A newcomer to Stack Overflow can't show any appreciation to answers, then, huh? I guess this will have to do.

andersoyvind
+1 so you now have the rep you need.
Dennis Palmer
A: 

This answer worked for me in VS 2005 as well. Sorry couldn't up your answer (low reputation).

wlappin
A: 

Change

Project Properties> Build > Target CPU to "Any CPU"

it will resolve the issue in case of platform dependency.

Thanks

Mazhar Karimi

Mazhar Karimi