简体   繁体   English

有没有办法使Nhibernate 3与使用Visual Studio 2008的Sharp Architecture一起使用?

[英]Is there a way to get Nhibernate 3 to work with Sharp Architecture using Visual Studio 2008?

I have been trying to find a version of Sharp Architecture which works with Visual Studio 2008 and uses NHibernate 3 but have been unsucsessful. 我一直在尝试找到与Visual Studio 2008一起使用并使用NHibernate 3的Sharp Architecture版本,但一直没有成功。 I want to use the QueryOver API from NHibernate version 3. The latest build available that I can find is sharp-architecture-1.6.0.0-templify-package.zip which is compatibale with Visual Studio 2008, MVC 2 and NHibernate 2. All the newer version of Sharp Architecture are only compatible with Visual Studio 2010. I attempted to make a custom build of Sharp Architecture: 我想使用NHibernate 3版中的QueryOver API。我可以找到的最新内部版本是sharp-architecture-1.6.0.0-templify-package.zip,它与Visual Studio 2008,MVC 2和NHibernate 2兼容。较新版本的Sharp Architecture仅与Visual Studio 2010兼容。我尝试制作Sharp Architecture的自定义版本:

I changed the references in the "SharpArchitecture 1.6 Full Source" project...: 我在“ SharpArchitecture 1.6 Full Source”项目中更改了引用:

  • NHibernate.Validator to Version 1.3.0.4000 NHibernate.Validator版本1.3.0.4000
  • NHibernate to Version 3.1.0.4000 NHibernate版本3.1.0.4000
  • NHibernate.ByteCode.Castle to Version 3.1.0.4000 NHibernate.ByteCode.Castle至版本3.1.0.4000
  • FluentNHibernate to Version 1.2.0.694 FluentNHibernate版本1.2.0.694
  • Castle.Core to Version=2.5.2.0 Castle.Core版本= 2.5.2.0

...by replacing the old dlls with the new ones in the projects bin directory. ...通过在项目bin目录中用新的dll替换旧的dll。 Then I ran ClickToBuild.bat (located in the downloaded Sharp Architecture zip file base directory) to build the solution. 然后,我运行ClickToBuild.bat(位于下载的Sharp Architecture zip文件基本目录中)来构建解决方案。 The build succeeded and all the tests passed. 构建成功,所有测试通过。 Then I replaced the all dlls in my own project with the new Sharp Architecture ones I just built. 然后,我用自己刚刚构建的新Sharp架构替换了自己项目中的所有dll。 My project does compile, but when I run it, SharpArch.Data\\NHibernate\\NHibernateSession.cs throws the following exception: 我的项目确实可以编译,但是当我运行它时,SharpArch.Data \\ NHibernate \\ NHibernateSession.cs会引发以下异常:

Could not load file or assembly 'Castle.Core, Version=2.5.1.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. 无法加载文件或程序集“ Castle.Core,版本= 2.5.1.0,区域性=中性,PublicKeyToken = 407dd0808d44fbdc”或其依赖项之一。 The located assembly's manifest definition does not match the assembly reference. 找到的程序集的清单定义与程序集引用不匹配。 (Exception from HRESULT: 0x80131040) (来自HRESULT的异常:0x80131040)

I tried using a bindingRedirect for Castle.Core in my web.config: 我尝试在我的web.config中为Castle.Core使用bindingRedirect:

<configuration>
    <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="Castle.Core" publicKeyToken="407dd0808d44fbdc" culture="neutral"/>
                <bindingRedirect oldVersion="2.5.1.0" newVersion="2.5.2.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
</configuration>

but that still did not work. 但这仍然行不通。

Am I on the right track? 我在正确的轨道上吗? What else can I do to get it to work? 我还能做些什么才能使其正常工作?

I've done that. 我已经做到了。 You just have to change the references in the S# projects as there's no breaking change from NH 2.1 to 3.0 (or 3.1 if you want the most recent one) regarding S#. 您只需要更改S#项目中的引用,因为关于S#的NH 2.1到3.0(如果需要最新版本,则为3.1)没有什么重大变化。

It'll be a little bit cumbersome thus, but definitelly manageable. 这样会有点麻烦,但是绝对可以管理。

note: Don't forget that projects like Fluent NHibernate should also be updated to use NH 3. 注意:不要忘记,像Fluent NHibernate这样的项目也应该更新为使用NH 3。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM