Shared Project - reference not being updated

Zishan Qureshi 21 Reputation points
2020-10-08T13:23:03.917+00:00

Shared project.

I created a Shared project in VS 2017 (I'll call it SharedProject).
In another project (Project1), I added a reference to SharedProject. Project1 is able to see the classes/methods of SharedProject. So that's fine.

However, If I subsequently add a further class (in a separate .cs file) to SharedProject, the class and it's methods are not visible to Project1.
I have tried a clean and re-build in both SharedProject and Project1 and this has not resolved the issue.
One workaround is to add the additional classes to SharedProject in an existing .cs file that Project1 is already able to see.
I have now found that if I add a new .cs file to the SharedProject, I have to remove the reference to SharedProject in Project1, re-add that reference in Project1. Then class/file is then visible in Project1.

So, my question is, why aren't the changes in SharedProject immediately available to Project1 since Project1 already has a reference to SharedProject?

Any suggestion or ideas about why this is occurring and how to resolve it would be greatly appreciated.
Zishan

Developer technologies Visual Studio Other
{count} votes

Accepted answer
  1. Tianyu Sun-MSFT 34,436 Reputation points Microsoft External Staff
    2020-10-09T04:20:54.067+00:00

    Hello Zishan,

    The changes in SharedProject should be immediately available to Project1. May I ask, if you try to reproduce your issue again, I mean create another new project > Add Shared Project > Add references > Add a new .cs file in Shared Project, will this issue appear again?

    This will be useful to narrow down this issue, if this issue appears(always) again, the cause should be from VS, some extensions, impacts from caches and so on. If this issue doesn’t appear, or appear suddenly or appear only on a specified project, there should be some special reasons.

    I checked on my side by using VS2017 and VS2019, this issue didn’t appear. However, I noticed that once I unloaded the project and opened .csproj file then added a new .cs(class) file(without saving this file and after that I closed the .cs file) in Shared Project, after that I reloaded main project but the class and methods were not visible to main project immediately. This may be caused by not syncing(save, configure, update…) and I resolved it by changing something in newly created .cs file > saved it > unloaded main project > reloaded it. And I didn’t reproduce this issue for the second time.

    I may share you some suggestions:

    1. Update VS2017 to the latest version(or try to use VS2019 Community which Viorel mentioned above).
    2. Repair VS2017.
    3. Try to disable some related extensions and check again.
    4. Create a new project and test again.

    Sincerely,
    Tianyu

    • If the answer is helpful, please click "Accept Answer" and upvote it.
      Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.