如何使用 Nunit 的 gui 运行程序设置绑定重定向?
我正在尝试使用 nHibernate 3 和 FluentnHibernate 运行单元测试,为此,我需要设置程序集绑定重定向,以便 FluentnHibernate 将与新版本的 nHibernate 一起使用。我尝试更新我的测试项目的 app.config 但是 testdriven.net 运行程序和 nunit gui 运行程序似乎没有读取这些设置。
下面是我的 test.dll 的 app.config。
<configuration>
<configSections>
<!-- Others sections -->
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<connectionStrings>
<add name="Test" connectionString="Data Source=SQL2008, 1080;Initial Catalog=TestCOM;Integrated Security=True"/>
</connectionStrings>
<log4net>
<appender name="GeneralLog" type="log4net.Appender.RollingFileAppender">
<file value="Logs.txt"/>
<appendToFile value="true"/>
<maximumFileSize value="100KB"/>
<rollingStyle value="Size"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{HH:mm:ss} [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<logger name="NHibernate.SQL" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="GeneralLog"/>
</logger>
</log4net>
<startup useLegacyV2RuntimeActivationPolicy="true">
<requiredRuntime version="v4.0.30319" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly
partialName="System.Data.SqlServerCe"
fullName="System.Data.SqlServerCe,
Version=3.5.1.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91"/>
<dependentAssembly>
<assemblyIdentity name="NHibernate"
publicKeyToken="AA95F207798DFDB4"
culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.0.0.1001"
newVersion="3.0.0.1001"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
我收到以下错误:
TestCase 'FieldGuideTests.Service.SchemaFacts.Can_Build_SQL_Schema' 失败:System.IO.FileLoadException:无法加载文件或程序集“NHibernate,Version=2.1.2.4000,Culture=neutral,PublicKeyToken=aa95f207798dfdb4”或其依赖项之一。找到的程序集的清单定义与程序集引用不匹配。 (HRESULT 异常:0x80131040) 在 FieldGuideService.SessionFactoryManagers.SQL_SessionFactoryManager.CreateSessionFactory()
I am trying to run my unit tests with nHibernate 3 and fluentnHibernate, To do this I need to setup a assembly binding redirect so fluentnHibernate will work with the new version of nHibernate. I have tried to update my test project's app.config however the testdriven.net runner and the nunit gui runner don't seem to read these settings.
below is my test.dll's app.config.
<configuration>
<configSections>
<!-- Others sections -->
<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net"/>
</configSections>
<connectionStrings>
<add name="Test" connectionString="Data Source=SQL2008, 1080;Initial Catalog=TestCOM;Integrated Security=True"/>
</connectionStrings>
<log4net>
<appender name="GeneralLog" type="log4net.Appender.RollingFileAppender">
<file value="Logs.txt"/>
<appendToFile value="true"/>
<maximumFileSize value="100KB"/>
<rollingStyle value="Size"/>
<layout type="log4net.Layout.PatternLayout">
<conversionPattern value="%d{HH:mm:ss} [%t] %-5p %c - %m%n"/>
</layout>
</appender>
<logger name="NHibernate.SQL" additivity="false">
<level value="DEBUG"/>
<appender-ref ref="GeneralLog"/>
</logger>
</log4net>
<startup useLegacyV2RuntimeActivationPolicy="true">
<requiredRuntime version="v4.0.30319" />
</startup>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<qualifyAssembly
partialName="System.Data.SqlServerCe"
fullName="System.Data.SqlServerCe,
Version=3.5.1.0, Culture=neutral,
PublicKeyToken=89845dcd8080cc91"/>
<dependentAssembly>
<assemblyIdentity name="NHibernate"
publicKeyToken="AA95F207798DFDB4"
culture="neutral"/>
<bindingRedirect oldVersion="0.0.0.0-3.0.0.1001"
newVersion="3.0.0.1001"/>
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
I am getting the following error:
TestCase 'FieldGuideTests.Service.SchemaFacts.Can_Build_SQL_Schema'
failed: System.IO.FileLoadException : Could not load file or assembly 'NHibernate, Version=2.1.2.4000, Culture=neutral, PublicKeyToken=aa95f207798dfdb4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
at FieldGuideService.SessionFactoryManagers.SQL_SessionFactoryManager.CreateSessionFactory()
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论