我在SQL Server复制项目上收到"尝试加载格式不正确的程序"错误

时间:2020-03-05 18:46:57  来源:igfitidea点击:

确切的错误如下

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.

在转移到另一个项目两个月后,我最近又开始从事该项目。之前它工作得非常好,我已经仔细检查了所有引用。

解决方案

回答

我找到了解决方案。我最近将计算机升级到了Windows 2008 Server 64位。 SqlServer.Replication命名空间是为32位平台编写的。为了使它再次运行,我要做的就是将Project Build Properties中的Target Platform设置为X86.

回答

下面的错误答案是正确的,但是我们可能还需要在AppPool中启用32位应用程序。

资料来源:http://www.alexjamesbrown.com/uncategorized/could-not-load-file-or-assembly-chilkatdotnet2-or-one-of-its-dependencies-an-attempt-was-made-to-load-一个格式错误的程序/

在设置要在我的本地计算机上运行(运行Vista 64位)的应用程序时,我遇到此错误:

Could not load file or assembly ChilkatDotNet2 or one of its
  dependencies. An attempt was made to load a program with an incorrect
  format.

显然,该应用程序使用ChilKat组件,但似乎我们正在使用的版本仅为32位版本。

要解决此错误,我在IIS中将我的应用程序池设置为允许32位应用程序。
打开IIS管理器,右键单击应用程序池,然后选择"高级设置"(请参见下文)

然后将"启用32位应用程序"设置为True。

全部完成!

回答

在Web项目的属性页上,将Platform Target的值更改为Any CPU。