2012-01-17 102 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