I added a couple of folders to my C# project and now when ever I try to run project from NUnit I always encounter following exception -
System.IO.FileNotFoundException: Could not find file 'x\x\x\x\bin\debug\project.dll
Project dll file is not generated and exception details are:
System.IO.FileNotFoundException...
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at NUnit.Core.AssemblyReader.CalcHeaderOffsets()
at NUnit.Core.AssemblyReader..ctor(S开发者_如何转开发tring assemblyPath)
at NUnit.Util.RuntimeFrameworkSelector.SelectRuntimeFramework(TestPackage package)
at NUnit.Util.DefaultTestRunnerFactory.GetTargetProcessModel(TestPackage package)
at NUnit.Util.DefaultTestRunnerFactory.MakeTestRunner(TestPackage package)
at NUnit.Util.TestLoader.LoadTest(String testName)
Is it a file path that you typed in? If so, use Windows explorer to copy/paste the correct path to avoid any typos.
If it is a reference dll that you added through VS, you should delete the reference and add it again to update its path.
As @Oded said, verify that the file exists and that the path is correct.
I am not sure if this would help you. I came here looking for the same error. I was using something like this in the test method to read a Json file that I just added to the project.
string currentDirectory = Directory.GetCurrentDirectory();
It was throwing the same error 'System.IO.FileNotFoundException : Could not find file' in debug folder.
I resolved it by changing the settings on the file. Right click > properties > set Copy to Output Directory to Copy Always. Screen shot of the above
I am not sure if that is a default setting on files that you add manually.
精彩评论