0

There is a similar question here but didn´t found a solution.

In Visual Studio 2017, I have a solution with 3 projects.

  • A Shared Project with the file I wan´t do link
  • A Console Project
  • A Windows Service Project

As you can see in the image, I successfully added the App.config as a link to the Console Project.

Solution

When I try to add the same file to the Windows Service Project, the message "There is already a link to App.config" is displayed.

What I´m doing wrong?

Stephen Kennedy
  • 20,585
  • 22
  • 95
  • 108
Igor
  • 13
  • 4
  • Confirm there is no link of the same file on target project. That's what the error is saying – codein Nov 05 '19 at 13:55
  • @codein I double checked. I also tried to delete everything and create again. – Igor Nov 05 '19 at 14:09
  • I know I have added the same file as a link across many files in the same solution (the file is usually in the solution folder, rather than any one project's). – Richard Nov 05 '19 at 14:15
  • @Richard I will try to put the file in the solution folder and report back. – Igor Nov 05 '19 at 14:34
  • @Richard your solution worked! This should be the answer! For some reason you can´t add multiple links if the file is in a project. Thank you! :) – Igor Nov 05 '19 at 14:49
  • OK, amended the answer to include that. – Richard Nov 05 '19 at 14:51

1 Answers1

0

Are you sure you have added as a link?

The error message is what you get when you try to add a file (not a link) that is already in one project into another.

This is reflected in your image. Linked project entries get a different icon overlay in Solution Explorer (the blue box in the bottom right):

enter image description here

To add a file as a link you need to use the drop down on the Add Existing Item dialog. This gives an "Add as Link" option:

enter image description here

Not, when I have a file I want in multiple projects I put it in the solution folder, and link from all applicable projects. This seems to work (and, IMO, keeps things cleaner).

Richard
  • 106,783
  • 21
  • 203
  • 265
  • Thanks for your answer. What I'm trying to do is exactly the same process of the linked file you mentioned, but for the project that doesn't have the linked file yet. Do I have to link de linked one? – Igor Nov 05 '19 at 14:32