C# 单元测试仅在生成服务器上失败

C# 单元测试仅在生成服务器上失败,c#,.net,spring,C#,.net,Spring,它抛出一个异常,如下所示: 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

它抛出一个异常,如下所示:

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.
我不知道确切的原因,但是很多单元测试只在构建服务器上失败,引发的异常与我上面写的类似

在my 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)


请帮忙,欢迎任何建议

MyAssemblyB的所有依赖项是安装在gac中还是安装在bin中?必须是这样的。

MyAssemblyB的所有依赖项是安装在gac中还是安装在bin中?必须是这样。

在生成服务器上运行单元测试之前是否编译代码?在生成服务器上运行单元测试之前是否编译代码?似乎所有引用的程序集都复制到bin文件夹中。程序集的引用路径是否正确?您可能需要从bin文件夹重新添加引用。还要仔细检查程序集是否正在复制到输出目录。可能与context.xml配置有关,我将更新我的问题。似乎所有引用的程序集都已复制到bin文件夹。程序集的引用路径是否正确?您可能需要从bin文件夹重新添加引用。还要仔细检查程序集是否被复制到输出目录。可能与context.xml配置有关,我将更新我的问题。