无法加载文件或程序集“Castle.DynamicProxy2,Version=2.1.0.0,Culture=neutral,PublicKeyToken=407dd0808d44fbdc”;

发布于 2024-09-28 05:07:34 字数 360 浏览 4 评论 0原文

我正在使用 Microsoft Visual Studio 2010。我开始使用 FluentNHibernate 1.1。配置.BuildSessionFactory() 执行后,我有异常。

<代码> 消息“无法加载文件或程序集‘Castle.DynamicProxy2,版本 = 2.1.0.0,文化 = 中性,PublicKeyToken = 407dd0808d44fbdc’或其依赖项之一。

Castle.DynamicProxy2 存在于项目引用中,版本正确。该程序集也存在于构建路径中。我无法解决这个问题...

ps 我尝试获取最新版本的 FluentNHibernate,在我的项目中使用程序集构建并运行。我有同样的错误。

I'm using Microsoft Visual Studio 2010. I start to work with FluentNHibernate 1.1. After configuration.BuildSessionFactory() execute, i have exception.


Message "Could not load file or assembly 'Castle.DynamicProxy2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies.

Castle.DynamicProxy2 present in project references, version is correct. Also this assembly present in build path. I can't resolve this problem...

p.s. i try to get last version of FluentNHibernate, build and run with assembly in my project. I have the same error.

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

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

发布评论

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

评论(2

遗心遗梦遗幸福 2024-10-05 05:07:34

这可能是因为您的目标框架是 4.0,而 Castle 程序集是针对 2.0 编译的。

您可以尝试将其添加到 app.config 的 元素中,以允许在运行时混合版本:

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>

It may be because you target framework 4.0 and the Castle assembly is compiled for 2.0.

You can try to add this to your app.config, within the <configuration /> element, to allow mixed version at runtime:

<startup useLegacyV2RuntimeActivationPolicy="true">
  <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
</startup>
鹊巢 2024-10-05 05:07:34

您说您的项目中存在对 Castle.DynamicProxy2 的引用,并且是正确的版本。你验证一下它的文件路径是否正确?

MSVS 有一个关于引用路径的小问题。引用程序集并编译项目后,会将该程序集的副本复制到输出目录中。通常,其引用路径会自动更改为指向此输出目录。然后,如果您进行清理或其他操作,您的文件将不再存在于预期的位置,并导致此类错误消息。

要解决此问题,您需要删除对有问题的程序集的引用,然后再次将其添加为项目的引用。

另一种简单的方法是从项目属性中设置每个项目的参考路径。不幸的是,您将需要为每个项目设置它们,因此您的解决方案的项目数设置多少次。另外,您团队中的每个程序员也会这样做,因为这些设置保存在本地计算机上,并且不会部署在项目设置(例如参数)中。

You say the reference to Castle.DynamicProxy2 exists in your project, and is the correct version. Did you verify its filepath, whether it is correct?

There is a tiny problem with MSVS that is about reference paths. Once you reference an assembly, and your project gets compiled, a copy of this assembly is made to your output directory. Often, its reference path is changed automatically to point to this output directory. Then, if you clean up or something, your file no longer exists where it is expected, and causes this kind of error message.

To resolve this problem, you need to remove your reference the problematic assembly, and add it again as a reference to your project.

Another simple approach is to set your reference paths per project from within your project properties. Unfortunately, you will be required to set them per project, so as many times as the project count your solution has. Plus, every programmer of your team will do to do so as well, as these settings are kept on the local machine and are not deployed within the project settings like parameters, for instance.

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