c# - 重命名项目 → "Could not resolve this reference. Could not locate the assembly"

标签 c# .net visual-studio fody fody-costura

每次构建解决方案时,我都会收到以下警告:

Warning Could not resolve this reference. Could not locate the assembly "WordAPI". Check to make sure the assembly exists on disk. If this reference is required by your code, you may get compilation errors. OfferteHost

然而,一切似乎都工作得很好,这只是一个警告,但它却困扰着我。

它是如何开始的?

我重命名了解决方案中的一个项目。使用右键单击 -> 重命名选项。我还使用搜索和替换来重命名项目中所有文件的命名空间。更改了 AssemblyInfo.cs 文件。在应用程序选项卡上的项目属性中,我更改了程序集名称默认命名空间。我也在使用Costura.Fody如果这很重要的话。

我如何尝试修复它?

  • 我更改了执行的项目文件中的HintPath 组装:

    <HintPath>..\WordAPI\bin\Debug\WordAPI.dll</HintPath>
    
  • 从我的执行程序集中删除了引用并读取了它。
  • 删除了解决方案中的调试/发布文件夹并重建了解决方案

我真的找不到解决方案,很想开始一个空白解决方案并复制其中的所有内容...


我的引用的属性:

enter image description here

文件资源管理器中项目的位置:

enter image description here

最佳答案

假设 WordAPI 与可执行文件位于同一解决方案中,则引用不应使用 HintPath。使用“解决方案”->“项目”选择删除和​​添加引用。可执行文件 csproj 中的引用应如下所示:

<ProjectReference Include="..\WordAPI.csproj">
  <Project>{GUID}</Project>
  <Name>WordAPI</Name>
</ProjectReference>

正如评论中所述,HintPath 不应指向 Debug 目录,因为相同的路径用于 Debug 和 Release 构建配置,这可能是问题的根源。

如果没有有关您的项目、解决方案、构建路径、构建配置的更多详细信息,很难给出更好的答案。

关于c# - 重命名项目 → "Could not resolve this reference. Could not locate the assembly",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35032531/

相关文章:

c# - 从 Uri 对象 C# 获取文件扩展名或 "HasExtension"类型 bool

C# - ExecuteNonQuery 需要一个打开且可用的连接。连接的当前状态是关闭的

visual-studio - 与 Visual Studio 一起使用 Meld

visual-studio - 容器和自定义目录中的 Visual C++ Build Tools 2015

c++ - OpenCV 奇怪的内存损坏

c# - Twilio C#sendmessage突然返回null

c# - 如何通过C#程序打开程序并赋予该程序焦点

c# - 来自 mysql 查询的组合框项目每秒刷新一次

c# - 如何以 Func 类型的表达式作为参数调用方法

.net - FileSystemWatcher 工作完成了吗?