2013-08-21 60 views
2

我对我的控制器(大约36)进行了单元测试。当我运行它们。我得到同样的错误了所有的测试单元测试错误,无法加载文件或程序集

Unable to get type AdminPortal.Tests.Controller_Test.OwnedModuleControllerTest. Error: System.IO.FileLoadException: Could not load file or assembly 'AdminPortal.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. Signature missing argument. (Exception from HRESULT: 0x801312E3) 
File name: 'AdminPortal.Tests, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' ---> System.Runtime.InteropServices.COMException (0x801312E3): Signature missing argument. (Exception from HRESULT: 0x801312E3) 
    at System.Reflection.RuntimeAssembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) 
    at System.Reflection.RuntimeAssembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, RuntimeAssembly locationHint, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) 
    at System.Reflection.RuntimeAssembly.InternalLoadAssemblyName(AssemblyName assemblyRef, Evidence assemblySecurity, RuntimeAssembly reqAssembly, StackCrawlMark& stackMark, IntPtr pPrivHostBinder, Boolean throwOnFileNotFound, Boolean forIntrospection, Boolean suppressSecurityChecks) 
    at System.Reflection.RuntimeAssembly.InternalLoadFrom(String assemblyFile, Evidence securityEvidence, Byte[] hashValue, AssemblyHashAlgorithm hashAlgorithm, Boolean forIntrospection, Boolean suppressSecurityChecks, StackCrawlMark& stackMark) 
    at System.Reflection.Assembly.LoadFrom(String assemblyFile) 
    at Microsoft.VisualStudio.TestPlatform.MSTestFramework.TypeCache.LoadType(String typeName, String assemblyName). 

这里是我的集信息

using System.Reflection; 
using System.Runtime.InteropServices; 

// General Information about an assembly is controlled through the following 
// set of attributes. Change these attribute values to modify the information 
// associated with an assembly. 
[assembly: AssemblyTitle("AdminPortal.Tests")] 
[assembly: AssemblyDescription("")] 
[assembly: AssemblyConfiguration("")] 
[assembly: AssemblyCompany("")] 
[assembly: AssemblyProduct("AdminPortal.Tests")] 
[assembly: AssemblyCopyright("Copyright © 2013")] 
[assembly: AssemblyTrademark("")] 
[assembly: AssemblyCulture("")] 

// Setting ComVisible to false makes the types in this assembly not visible 
// to COM components. If you need to access a type in this assembly from 
// COM, set the ComVisible attribute to true on that type. 
[assembly: ComVisible(false)] 

// The following GUID is for the ID of the typelib if this project is exposed to COM 
[assembly: Guid("0412bc0c-30bc-4e0c-9a8d-bcbcd7876702")] 

// Version information for an assembly consists of the following four values: 
// 
//  Major Version 
//  Minor Version 
//  Build Number 
//  Revision 
// 
// You can specify all the values or you can default the Revision and Build Numbers 
// by using the '*' as shown below: 
[assembly: AssemblyVersion("1.0.0.0")] 
[assembly: AssemblyFileVersion("1.0.0.0")] 
+0

是这些测试本地或服务器上的失败?他们有工作的特定环境吗?服务器上的 –

+0

。他们过去了,但突然出现了一个错误,说不确定的测试。后来我意识到这是resharper问题,我修好了。现在他们只是不跑,并提出错误。 – Cybercop

+0

运行时(.NET)和环境(Visual Studio)的版本是否与本地服务器上的版本相同?看起来您的本地环境和服务器之间的版本可能不匹配。 –

回答

1

我花了一段时间来追踪下来这个问题。问题是我的测试项目在我的测试项目中隐式引用了另一个项目中未明确引用的类。只要将引用(对隐式引用的项目)添加到我的测试项目并重建,测试开始再次在测试浏览器中填充。张贴的链接是让我思考这个方向的暗示。从帖子看来,这是一个Visual Studio/Rhino Mocks问题。

when using generics and/or delegation, make sure all types implicitly referenced by your code are explicitly referenced in the project References 

http://kblite.blogspot.com.au/2010_09_01_archive.html

相关问题