【发布时间】:2018-11-08 09:01:15
【问题描述】:
我的网络项目使用.NET Framework 4.7.2 并使用一些参考,例如
System.IOSystem.NetSystem.Net.HttpSystem.Net.Http.Formatting
我的项目在本地运行良好。
但是,当我在目标目录(在线)上发布我的 Web 项目时,查看它在 /bin/ 中包含的内容:
-
System.IO不见了 -
System.Net存在 -
System.Net.Http不见了 -
System.Net.Http.Formatting在场
因此,当我使用我的网站时,我得到了明显的错误Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
所有引用在Properties 中都有Copy Local = True,但某些dll 总是被忽略。如果我将 dll 从本地目录复制到目标目录,我会收到错误 Server Error in '/' Application. Cannot load a reference assembly for execution. Exception Details: System.BadImageFormatException: Cannot load a reference assembly for execution. Exactly the same problem as this one.
但是删除/重建解决方案或添加编译选项解决方案对我不起作用
我需要怎么做才能将这些丢失的 dll 放到目标文件夹中?
【问题讨论】:
-
检查你的 nuget 清单
-
是吗?
System.IO和System.Net.Http软件包已安装 -
这是一个项目还是单独的项目?如果说你有 web 应用程序,然后为数据、模型等单独的项目,它们之间可能存在参考差异
-
一个使用双项目的解决方案。一个dll的.NET Web+源码(不使用
System.Net.Http,而是使用System.IO) -
我们最近遇到了类似的问题,这是由于一个项目与另一个项目引用的 dll 版本不同