<p>The exact error is as follows</p>

<blockquote>
  <p>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.</p>
</blockquote>

<p>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.</p>

[{'answer_id': 41451, 'author': 'baldy', 'author_id': 2012, 'author_profile': 'https://Stackoverflow.com/users/2012', 'pm_score': 8, 'selected': True, 'text': "<p>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.</p>\n"}, {'answer_id': 2926982, 'author': 'bboyle1234', 'author_id': 213256, 'author_profile': 'https://Stackoverflow.com/users/213256', 'pm_score': 9, 'selected': False, 'text': '<p>The <a href="https://stackoverflow.com/a/41451/148412">answer by baldy</a> below is correct, but you may also need to enable 32-bit applications in your AppPool. </p>\n\n<p>Source: <a href="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/" rel="noreferrer">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/</a></p>\n\n<p>Whilst setting up an application to run on my local machine (running Vista 64bit) I encountered this error:</p>\n\n<blockquote>\n  <p>Could not load file or assembly <code>ChilkatDotNet2</code> or one of its\n  dependencies. An attempt was made to load a program with an incorrect\n  format.</p>\n</blockquote>\n\n<p>Obviously, the application uses <a href="http://www.chilkatsoft.com/" rel="noreferrer">ChilKat components</a>, but it would seem that the version we are using, is only the 32bit version.</p>\n\n<p>To resolve this error, I set my app pool in IIS to allow 32bit applications.\nOpen up IIS Manager, right click on the app pool, and select Advanced Settings (See below)</p>\n\n<p><img src="https://i.stack.imgur.com/LQkqf.jpg" alt="enter image description here"></p>\n\n<p>Then set "Enable 32-bit Applications" to True.</p>\n\n<p><img src="https://i.stack.imgur.com/7ltqt.jpg" alt="enter image description here"></p>\n\n<p>All done!</p>\n'}, {'answer_id': 4023955, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 7, 'selected': False, 'text': '<p>Change the value for Platform Target on your web project\'s property page to <code>Any CPU</code>.</p>\n\n<p><img src="https://i.stack.imgur.com/a5Ipu.png" alt="enter image description here"></p>\n'}, {'answer_id': 6426092, 'author': 'Ryan Lundy', 'author_id': 5486, 'author_profile': 'https://Stackoverflow.com/users/5486', 'pm_score': 4, 'selected': False, 'text': '<p>For those who get this error in an <strong>ASP.NET MVC 3</strong> project, within Visual Studio itself:</p>\n\n<p>In an ASP.NET MVC 3 app I\'m working on, I tried adding a reference to Microsoft.SqlServer.BatchParser to a project to resolve a problem where it was missing on a deployment server.  (Our app uses SMO; the correct fix was to install SQL Server Native Client and a couple other things on the deployment server.)</p>\n\n<p>Even after I removed the reference to BatchParser, I kept getting the "An attempt was made..." error, referencing the BatchParser DLL, on every ASP.NET MVC 3 page I opened, and that error was followed by dozens of page parsing errors.</p>\n\n<p><strong>If this happens to you, do a file search and see if the DLL is still in one of your project\'s \\bin folders.</strong>  Even if you do a rebuild, Visual Studio doesn\'t necessarily clear out everything in all your \\bin folders.  When I deleted the DLL from the bin and built again, the error went away.</p>\n'}, {'answer_id': 7752112, 'author': 'Harpal', 'author_id': 548585, 'author_profile': 'https://Stackoverflow.com/users/548585', 'pm_score': 6, 'selected': False, 'text': '<p>Go to IIS\n -> Application Pool -> Advance Settings -> Enable 32-bit Applications</p>\n'}, {'answer_id': 19577840, 'author': 'SushiGuy', 'author_id': 757931, 'author_profile': 'https://Stackoverflow.com/users/757931', 'pm_score': 2, 'selected': False, 'text': '<p>If <strong>Publishing in Visual Studio 2012</strong> when erroring try unchecking the <em>"Procompile during publishing"</em> option in the Publish wizard.</p>\n\n<p><img src="https://i.stack.imgur.com/uhB5m.png" alt="Un-check &quot;Precompile during publishing&quot;"></p>\n'}, {'answer_id': 33553957, 'author': 'Justin', 'author_id': 1195195, 'author_profile': 'https://Stackoverflow.com/users/1195195', 'pm_score': 5, 'selected': False, 'text': '<p>We recently had the issue when trying to run the code from Visual Studio. In that case you need to do<br>\nTOOLS > OPTIONS > Projects and Solutions > WEB PROJECTS and check the "Use the 64 bit version of IIS Express for web sites and projects".</p>\n'}, {'answer_id': 35222817, 'author': 'munwar shaiik', 'author_id': 5809459, 'author_profile': 'https://Stackoverflow.com/users/5809459', 'pm_score': 2, 'selected': False, 'text': '<p>change it to 32-bit (true) it works</p>\n\n<p>if you get this  Length cannot be less than zero. Parameter name: length issue in iis server configuation do the simple thing change the connection string in web.config file like your sql server name and server name and restart iis then try to load the page it works</p>\n'}, {'answer_id': 44602783, 'author': 'Amirhossein Yari', 'author_id': 1945443, 'author_profile': 'https://Stackoverflow.com/users/1945443', 'pm_score': 0, 'selected': False, 'text': '<p>in windows form application I do this,\nRight-click on Project->Properties->Build->Check Prefer 32-bit checkbox.\nThanks all</p>\n'}, {'answer_id': 45168244, 'author': 'Madhurya Gandi', 'author_id': 4184525, 'author_profile': 'https://Stackoverflow.com/users/4184525', 'pm_score': 0, 'selected': False, 'text': '<ol>\n<li><p>Delete the temp test directory located here\nC:\\Users(User)\\AppData\\Local\\Temp\\VisualStudioTestExplorerExtensions\\</p></li>\n<li><p>Set all projects to x64 in Visual Studio </p></li>\n<li><p>Set the default processor architecture to x64(Test/TestSettings/Default Processor Architecture).</p></li>\n</ol>\n\n<p>Make sure to clean build the solution file.Hope this helps!</p>\n'}, {'answer_id': 45640758, 'author': 'krillgar', 'author_id': 1195056, 'author_profile': 'https://Stackoverflow.com/users/1195056', 'pm_score': 3, 'selected': False, 'text': '<p>I had this in an MVC5 app in Windows 10 against IIS Express. My solution was the following:</p>\n\n<ul>\n<li>Tools => \n\n<ul>\n<li>Options => \n\n<ul>\n<li>Projects and Solutions =>\n\n<ul>\n<li>Web Projects =>\n\n<ul>\n<li>Use the 64 bit version of IIS Express for web sites and projects</li>\n</ul></li>\n</ul></li>\n</ul></li>\n</ul></li>\n</ul>\n'}, {'answer_id': 49735995, 'author': 'sussexrick', 'author_id': 3169017, 'author_profile': 'https://Stackoverflow.com/users/3169017', 'pm_score': 0, 'selected': False, 'text': '<p>Changing the Target Framework in project properties from .NET Framework 4.7.1 to 4.6.2 worked for me.</p>\n'}]
['https://Stackoverflow.com/questions/41449', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2012/']