VS2010中的SharpSVN错误

时间:2011-09-19 16:31:34

标签: vb.net sharpsvn

我正在尝试让SharpSVN使用我正在VS2010中工作的VB.NET项目。我已将SharpSVN.dll添加到我的项目引用中,但当我尝试加载该站点时出现以下错误:

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

描述:在执行当前Web请求期间发生了未处理的异常。请查看堆栈跟踪以获取有关错误及其源自代码的位置的更多信息。

异常详细信息: System.BadImageFormatException:无法加载文件或程序集“SharpSvn”或其依赖项之一。试图加载格式不正确的程序。

来源错误:

An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

我的机器是64位的,我已将Configuration Manager设置为x64,并将64位版本的SharpSVN.dll复制到我项目的bin目录中。另外,我也尝试将build设置为x86并使用x86版本的SharpSVN.dll并出现相同的错误(所以我怀疑错误可能与指令集系列没有直接关系)。

在我的配置文件中,我尝试将以下内容添加到assemblies属性:

<add assembly="SharpSvn, Version=1.6016.1637.10768, Culture=neutral, PublicKeyToken=d729672594885a28"/>

有什么想法吗?

3 个答案:

答案 0 :(得分:1)

我有同样的错误,无法解释发生了什么。但是,对于32位版本,错误更具描述性:

Unhandled Exception: System.IO.FileLoadException: Mixed mode assembly is built against 
  version 'v2.0.50727' of the runtime and cannot be loaded in the 4.0 runtime without 
  additional configuration information.

您可以通过将以下代码段添加到app.config

来解决此问题
<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0"/>
</startup>

不确定64位版本有什么问题,但您始终可以build it from source

答案 1 :(得分:1)

尽管认为<add assembly>已经足够了,但我实际上是通过将SharpSvn添加到GAC来解决了这个问题(如果有人遇到这个问题的话)。

答案 2 :(得分:1)

我不确定为什么添加到GAC为您工作,这不是装配加载程序的正确行为。

错误指的是装配的位数。 SharpSVN是一种混合模式程序集,即:它包含托管代码和非托管代码。您必须专门针对x86(使用x86 SharpSVN程序集)或x64(再次使用适当的程序集)。您必须进一步将所有程序集设置为显式x86或x64。定位任何CPU都将允许运行时为您做出此决定,如果它选择的字长与SharpSvn DLL不匹配,则无法加载SharpSvn.dll。

相关问题