.net NUnit“无法加载文件或程序集'MyTestProject'
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/399972/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
NUnit "could not load file or assemby 'MyTestProject'
提问by NeedHack
I'm setting up a new 64 bit machine to run as a build server. When I try to load my NUnit test assembly into NUnit GUI I get the following error.
我正在设置一台新的 64 位机器作为构建服务器运行。当我尝试将 NUnit 测试程序集加载到 NUnit GUI 时,出现以下错误。
There is nothing obvious missing, all the dependencies seem to be present. All the DLLs are compiled for the x86 platform.
没有什么明显的缺失,所有的依赖似乎都存在。所有的 DLL 都是为 x86 平台编译的。
Using NUnit 2.4.7. I have tried upgrading to 2.4.8 but the same error occurs.
使用 NUnit 2.4.7。我曾尝试升级到 2.4.8,但发生了同样的错误。
System.IO.FileNotFoundException: Could not load file or assembly 'MyTestProject' or one of it's dependencies. The system cannot find the file specified.
System.IO.FileNotFoundException: 无法加载文件或程序集“MyTestProject”或其依赖项之一。该系统找不到指定的文件。
System.IO.FileNotFoundException...
System.IO.FileNotFoundException...
Server stack trace:
at System.Reflection.Assembly.nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
at System.Reflection.Assembly.Load(String assemblyString)
at NUnit.Core.Builders.TestAssemblyBuilder.Load(String path)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, Boolean autoSuites)
at NUnit.Core.Builders.TestAssemblyBuilder.Build(String assemblyName, String testName, Boolean autoSuites)
at NUnit.Core.TestSuiteBuilder.BuildSingleAssembly(TestPackage package)
at NUnit.Core.TestSuiteBuilder.Build(TestPackage package)
at NUnit.Core.SimpleTestRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Core.ProxyTestRunner.Load(TestPackage package)
at NUnit.Core.RemoteTestRunner.Load(TestPackage package)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Int32 methodPtr, Boolean fExecuteInContext, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg, Int32 methodPtr, Boolean fExecuteInContext)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Core.TestRunner.Load(TestPackage package)
at NUnit.Util.TestDomain.Load(TestPackage package)
at NUnit.Util.TestLoader.LoadTest(String testName)
采纳答案by NeedHack
The solution was to build the test project for "AnyCPU" instead of 32-bit. I can work around the restriction that made us use 32 bit.
解决方案是为“AnyCPU”而不是 32 位构建测试项目。我可以解决使我们使用 32 位的限制。
Thank you David and Joe90 for the suggestions. I've certainly learned a couple of new things. fuslogvw.exe is awesome, I didn't previously know it existed.
感谢 David 和 Joe90 的建议。我当然学到了一些新东西。fuslogvw.exe 很棒,我以前不知道它存在。
回答by RedGreenCode
If you do need to build the test project for x86, you can use nunit-x86.
如果确实需要为 x86 构建测试项目,则可以使用 nunit-x86。
See "NUnit on 64-Bit Platforms" at http://www.nunit.org/index.php?p=nunit-gui&r=2.4.2.
请参阅http://www.nunit.org/index.php?p=nunit-gui&r=2.4.2上的“64 位平台上的 NUnit” 。
回答by David Schmitt
Activate the Fusion log with fuslogvw.exe(Run as Administrator from the Visual Studio Command Prompt) to see what the assembly loader tries to load and all occurring errors.
使用fuslogvw.exe(从 Visual Studio 命令提示符以管理员身份运行)激活 Fusion 日志以查看程序集加载器尝试加载的内容以及所有发生的错误。
回答by Eric Mariacher
The solution was found following this post: "Could not load file or assembly 'X.dll' or one of its dependencies. The specified module could not be found." - on host serverand more specifically by using http://dependencywalker.com/
在这篇文章之后找到了解决方案:“无法加载文件或程序集‘X.dll’或其依赖项之一。找不到指定的模块。” - 在主机服务器上,更具体地说是通过使用http://dependencywalker.com/

