Click here to Skip to main content
15,562,015 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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
Posted
Updated 25-Jul-17 14:49pm

1 solution

Yes, you have to "install-package" on every project that's going to use it, but you're only installing the executable files once in the solution. Each project is going to have references added to it where they will point to the common folder for the binaries for that library.

When you build the project, the required .DLL's will end up in the bin folder for your build, \bin\Debug, \bin\Release. Those files need to go with each of your project deployables.
 
Share this answer
 
Comments
MiniGoel2017 25-Jul-17 20:08pm    
oh, but my executable project is not using NuGet. Its mainly calling .net standard class library project functionality, which is using NuGet functionality. Do I still need to install NuGet for executable project?
Dave Kreskowiak 25-Jul-17 20:58pm    
No project "uses Nuget". You don't install Nuget.

Nuget is a tool used by Visual Studio to install library packages into your projects.
MiniGoel2017 25-Jul-17 21:34pm    
Sorry for the confusing term I used. I meant my executable project is not using those library packages. Its mainly calling .net standard class library project, which is using those installed library project functionality. Do I still need to install those library project via nuget for executable project?
Dave Kreskowiak 25-Jul-17 21:47pm    
The class library project, if it's handling ALL communication and object management with the WCF service you're calling, those packages should only be needed in the class library project.

If your .EXE is also messing around with the objects you're passing back and forth with the service, then it too is going to need the packages.

If your class library and .EXE create and pass business objects between themselves, the packages are not needed. Your class library would have to create and translate between these business objects and the objects being passed back and forth to the service.

MiniGoel2017 26-Jul-17 11:39am    
So my class library is handling all the operations and executable project is only calling class library method. So as per you, it should not ask in executable project,but it is. Please check this for more info.
https://social.msdn.microsoft.com/Forums/vstudio/en-US/954059c8-adb6-4fe2-939a-e60da1587545/do-i-need-to-install-nuget-package-on-net-standard-library-or-executable-project-or-both?forum=wcf

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900