VS2010中SharpSVN错误

发布于 2024-12-05 11:55:27 字数 958 浏览 1 评论 0原文

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

无法加载文件或程序集“SharpSvn”或其依赖项之一。尝试加载格式不正确的程序。

描述:执行当前 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 位,我已将配置管理器设置为构建为 x64,并将 64 位版本的 SharpSVN.dll 复制到项目的 bin 目录中。此外,我还尝试将构建设置为 x86 并使用 x86 版本的 SharpSVN.dll 并出现相同的错误(因此我怀疑该错误可能与指令集系列没有直接关系)。

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

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

有什么想法吗?

I'm trying to get SharpSVN to work with a VB.NET project I'm working on in VS2010. I've added SharpSVN.dll to my project references but the following error appears when I try to load the site:

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

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

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

Source Error:

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.

My machine is 64-bit, and I've set the Configuration Manager to build to x64 as well as copied the 64-bit version of SharpSVN.dll into my project's bin directory. Additionally, I've also tried setting build to x86 and using the x86 version of SharpSVN.dll and the same error appears (so I suspect the error may not be directly related to instruction set family).

In my config file, I've tried adding the following to the assemblies attribute:

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

Any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

走过海棠暮 2024-12-12 11:55:27

我有同样的错误,无法解释发生了什么。但是,对于 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 位版本有什么问题,但您始终可以 从源代码构建

I have the same error and can't explain what's going on. However, with the 32bit version, the error is more descriptive:

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.

Which you can fix by adding the following snippet to your app.config

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0"/>
</startup>

Not sure what's wrong with the 64bit version, but you can always build it from source.

节枝 2024-12-12 11:55:27

尽管我认为 就足够了,但实际上我通过将 SharpSvn 添加到 GAC 来解决了这个问题(以防有人也遇到这个问题)。

Despite thinking that <add assembly> was enough, I actually solved this issue by adding SharpSvn to GAC (in case anybody is running into this problem as well).

心如狂蝶 2024-12-12 11:55:27

我不确定为什么添加到 GAC 对您有用,这对于程序集加载器来说不是正确的行为。

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

I am not sure why adding to the GAC worked for you, this is not the correct behavior for the assembly loader.

The error refers to the bitness of an assembly. SharpSVN is a mixed mode assembly, ie: it contains both managed and unmanaged code. You must specifically target x86 (with the x86 SharpSVN Assembly) or x64 (again with appropriate assembly). You must further set all your assemblies to be explicitly x86 or x64. Targeting Any CPU will allow the runtime to make this decision for you, and it will fail to load SharpSvn.dll if it picks a word length that does not match the SharpSvn DLL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文