Home > Software design >  Visual Studio 2022 can't add service reference and no assembly references node
Visual Studio 2022 can't add service reference and no assembly references node

Time:03-25

I have a VS2022 class library project that looks strange in a number of ways:

  1. Cannot add a service reference (see screenshot)
  2. There is no References node (for assembly references) - see screenshot
  3. The project properties UI looks very different

When I right-click on my class library project -> Add -> Service Reference, I'm taken to this screen that has only Connected Services and not Service References:

enter image description here

When I click Add a service dependency, I'm presented with all these options that are not what I need:

enter image description here

I need to add a service reference like this (only exists in my winforms project): enter image description here

Notice 2 things in the screenshot below: (1) Dependencies instead of References?? Also, note that I have a reference to System.ServiceModel, so I see no reason why I cannot add a service reference.

enter image description here

enter image description here

This Project Properties UI looks very different: enter image description here

Compare the above against my more traditional-looking Project Properties UI for a winforms project in the same solution (we're still in VS2022):

enter image description here

What is going on? I can't add a Service Reference, I don't have a References node (it's a Dependencies node instead), and the project properties UI is quite different.

CodePudding user response:

This looks like you've created a project based on the .NET SDK (not .NET Framework), and so VS offers a different experience for it - notably some features are new (like the look and functionality of the property pages) and some are missing (like support for .NET Framework specific tooling such as Service References).

When the project was created, it was probably created from the red template, but you're expecting the blue one: Class library templates in VS

The simplest solution is to stash your source files, create the project from scratch with the correct template, then retrieve your stashed files into the new project.

  • Related