簡體   English   中英

System.IO.FileNotFoundException: 找不到文件 'x\\x\\x\\x\\bin\\debug\\project.dll

[英]System.IO.FileNotFoundException: Could not find file 'x\x\x\x\bin\debug\project.dll

我在 C# 項目中添加了幾個文件夾,現在每當我嘗試從 NUnit 運行項目時,我總是遇到以下異常 -

System.IO.FileNotFoundException: 找不到文件 'x\\x\\x\\x\\bin\\debug\\project.dll

未生成項目 dll 文件,異常詳細信息為:

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(String 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)

它是您輸入的文件路徑嗎? 如果是這樣,請使用 Windows 資源管理器復制/粘貼正確的路徑以避免任何拼寫錯誤。

如果是您通過VS添加的引用dll,則應刪除該引用並重新添加以更新其路徑。

正如@Oded 所說,驗證文件是否存在並且路徑是否正確。

我不確定這是否對你有幫助。 我來到這里尋找同樣的錯誤。 我在測試方法中使用類似的東西來讀取我剛剛添加到項目中的 Json 文件。

字符串 currentDirectory = Directory.GetCurrentDirectory();

它在調試文件夾中拋出了相同的錯誤“System.IO.FileNotFoundException:Could not find file”。

我通過更改文件上的設置解決了它。 右鍵單擊> 屬性> 將復制到輸出目錄設置為始終復制。 以上截圖

我不確定這是否是您手動添加的文件的默認設置。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM