8

コントローラーの単体テストがあります (約 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).

これが私のassemblyinfoクラスです

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")]
4

1 に答える 1

10

この問題を追跡するのにしばらく時間がかかりました。問題は、テスト プロジェクトで明示的に参照されていない別のプロジェクトのクラスを、テスト プロジェクトが暗黙的に参照していたことです。(暗黙的に参照されたプロジェクトへの) 参照をテスト プロジェクトに追加して再ビルドするとすぐに、テスト エクスプローラーにテストが再び表示され始めました。@wal が投稿したリンクは、その方向性を考えるきっかけになりました。投稿から、これは Visual Studio / Rhino Mocks の問題のようです。

ジェネリックや委任を使用する場合は、コードによって暗黙的に参照されるすべての型がプロジェクトの参照で明示的に参照されていることを確認してください。

出典: C# コンパイラのバグか、それとも不明瞭で苛立たしい何かですか? [代替]

于 2015-04-16T19:28:47.057 に答える