2012-01-17 98 views
1

它抛出一个异常,这是这样的:单元测试只在构建服务器失败

Initialization method MyAssemblyA.Initialize threw exception. 
Spring.Objects.Factory.ObjectCreationException: Spring.Objects.Factory.ObjectCreationException: 

Error thrown by a dependency of object 'messageSource' defined in 'assembly  
[MyOtherAssembly.Test, Version=1.1.1016.1, Culture=neutral, PublicKeyToken=null], 
resource [MyOtherAssembly.context.xml] 

line 256' : Initialization of object failed : Could not load file or assembly 'MyAssemblyB' 
or one of its dependencies. The system cannot find the file specified. 

我完全不知道为什么,但很多单元测试都在构建服务器只失败而抛出的异常与我上面写的类似。

在我的context.xml我有这样的事情:

<object name="messageSource" type="Spring.Context.Support.ResourceSetMessageSource, Spring.Core"> 
    <property name="resourceManagers"> 
     <list> 
     <ref object="resMgrCoreServiceErrors"/> 
     <ref object="resMgrPersonnelErrors"/> 
     </list> 
    </property> 
    </object> 

    <object name="resMgrCoreServiceErrors" 
      type="Spring.Objects.Factory.Config.ResourceManagerFactoryObject, Spring.Core"> 
    <property name="baseName" value="MyOtherAssembly.Resources.ErrorRes"/> 
    <property name="assemblyName" value="MyOtherAssembly"/> 
    </object> 

    <object name="resMgrPersonnelErrors" 
      type="Spring.Objects.Factory.Config.ResourceManagerFactoryObject, Spring.Core"> 
    <property name="baseName" value="MyOtherAssemblyB.Resources.ErrorRes"/> 
    <property name="assemblyName" value="MyOtherAssemblyB"/> 
    </object> 

其中ErrorRes是一个资源文件(的.resx)。

请帮忙,欢迎任何建议!

+0

在构建服务器上运行Unite之前,您是否编译过代码? – CloudyMarble 2012-01-17 07:15:32

回答

1

是MyAssemblyB的所有依赖关系安装在gac中还是在bin中?必须是这方面的东西。

+0

看来,所有引用的程序集都被复制到bin文件夹中。 – lex87 2012-01-17 08:20:10

+0

组件的参考路径是否正确?您可能需要重新添加来自bin文件夹的引用。再次检查组件是否被复制到输出目录。 – stuartmclark 2012-01-17 09:17:13

+0

也许与co​​ntext.xml配置有关,我会更新我的问题。 – lex87 2012-01-17 09:34:05