问题描述
我正在使用Visual Studio 2017并创建.Net标准库。在此库中,我通过使用WCF连接服务选项添加对WCF服务的引用。由于这个项目是一个类库,我在控制台应用程序(可执行项目)中添加它的引用。
在我的.net标准项目中,我正在调用一个方法来自WCF服务库。当我运行项目时,我收到错误 -
System.IO.FileNotFoundException:'无法加载文件或程序集'System.ServiceModel.Primitives,Version = 4.1.1.0, Culture = neutral,PublicKeyToken = b03f5f7f11d50a3a'或其依赖项之一。系统找不到指定的文件。'
因此,在包管理器控制台中,我安装了System.ServiceModel.Primitives包。 net标准库项目,但我仍然得到同样的错误。如果我也为可执行项目安装了相同的NuGet,那么错误就会消失。
我的问题是,我是否必须安装所有NuGet包两次(一次用于类库,然后一次在可执行项目上)?
我尝试过:
我试过在可执行项目中添加对System.ServiceModel和System.ServiceModel.Primitives dll的引用
I am using Visual Studio 2017 and creating .Net Standard Library. In this library, I am adding reference to WCF Service by using WCF Connected Service option. As this project is a class library, I am adding its reference in a console app (Executable project).
In my .net standard project, I am calling a method from WCF service library. When I run the project, I get error -
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.ServiceModel.Primitives, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.'
So, In package manager console, I install System.ServiceModel.Primitives package for .net standard library project, but I still get the same error. If I also install the same NuGet for executable project, then the error goes away.
My question is, do I have to install all NuGet packages two times (once for class library and then once on executable project)?
What I have tried:
I have tried adding reference to System.ServiceModel and System.ServiceModel.Primitives dll in executable project
推荐答案
这篇关于我是否需要在.NET标准库或可执行项目或两者上安装NuGet包?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!