2 回答

TA贡献1799条经验 获得超6个赞
通过将 CarLotMVC.csproj 文件中的一个部分从本书的解决方案复制到我的项目中,我找到了解决此问题的方法。
首先导航到本书解决方案代码中的 ..\pro-csharp-7-master\Chapter_29\CarLotMVC\CarLotMVC 目录,然后在文本编辑器中打开 CarLotMVC.csproj 文件。
找到以下元素并将其复制到剪贴板:
<ItemGroup>
<ProjectReference Include="..\AutoLotDAL.Models\AutoLotDAL.Models.csproj">
<Project>{9a917d7c-885e-4d9a-818f-9955871a4fbb}</Project>
<Name>AutoLotDAL.Models</Name>
</ProjectReference>
<ProjectReference Include="..\AutoLotDAL\AutoLotDAL.csproj">
<Project>{7e5a8812-c303-4ae0-a6e7-4ac96ec11624}</Project>
<Name>AutoLotDAL</Name>
</ProjectReference>
</ItemGroup>
通过打开 AutoLotDAL 项目中的 AutoLotDAL.csproj 和 AutoLotDAL.csproj 中的 AutoLotDAL.Models.csproj 并将 ProjectGuid 标记与复制的元素中指定的值进行比较,确认项目 guid 与 AutoLotDAL 和 AutoLotDAL.Models 项目中的 guid 匹配从书中的解决方案。
以下是我的 AutoLotDAL.csproj 中的第 7 行:
<ProjectGuid>{7E5A8812-C303-4AE0-A6E7-4AC96EC11624}</ProjectGuid>
使用相同的文件转到您的项目目录并在文本编辑器中打开它。找到以下块(我的文件中的第 185 行):
<ItemGroup>
<Folder Include="App_Data\" />
<Folder Include="Models\" />
</ItemGroup>
并将解决方案文件中的元素粘贴到它之后。
现在,在同一个文件中找到以下元素(我的文件中的第 49 行):
<Reference Include="AutoLotDAL">
<HintPath>..\AutoLotDAL\bin\Debug\AutoLotDAL.dll</HintPath>
</Reference>
<Reference Include="AutoLotDAL.Models">
<HintPath>..\AutoLotDAL.Models\bin\Debug\AutoLotDAL.Models.dll</HintPath>
</Reference>
并注释掉或删除这些行。
保存文件并再次尝试添加控制器。该项目通过这些更改为我工作。
- 2 回答
- 0 关注
- 163 浏览
添加回答
举报