Dot Net Mafia

Group site for developer blogs dealing with (usually) Ionic, .NET, SharePoint, Office 365, Mobile Development, and other Microsoft products, as well as some discussion of general programming related concepts.

This Blog



Corey Roth [MVP]

A SharePoint MVP bringing you the latest time saving tips for Ionic, SharePoint, and Office 365.

Linking Files in Visual Studio

I saw this feature in Visual Studio again the other day and honestly I had kind of forgotten about it.  After discussing it with some colleagues, most of them didn’t even know the feature existed.  What I am talking about is the ability to create a link between files in Visual Studio.  What this allows you to do is actually create a link to a file instead of just making a copy.  Now, I don’t want to get into a discussion of why you would never want to do this or how this is not a proper way to implement code reuse.  Keep in mind though that you can use it to link other types of non-code files such as an XML file.  However, for today’s purpose, I’m just going to link a class into another project.  Consider my following example with two class libraries. I want to reuse Class1.cs inside ClassLibrary2.


I have a simple class that looks like this.

using System;


namespace ClassLibrary1


    public class Class1


        public Class1()




        public void DoSomething()


            int x = 5;




This class clearly has so much valuable code in it that I have to reuse it in ClassLibrary2, but not make a reference to ClassLibrary2.  This is where the Add as Link functionality comes in.  The process is simple, using the Add Existing Item menu on the project’s context menu.  Navigate to the existing item in the other class library and then make note of the arrow next to the Add button, click on it and choose Add as Link instead.


Once you do that you will have a link to the file in your other class library.  You can open it and edit it as normal from the linked location, but it will actually edit the file link.  You can tell it is linked in Solution Explorer by the icon.


Notice the link icon on Class1.cs in ClassLibrary2.  If you click on the linked file, you can see the path to the file it has linked in the properties (although its cut off here in my screenshot).


Once you are done here, you can make changes to the file from either class library and the original file gets updated.  Keep in mind though, if you delete the original file, the link will be broken and you will get an error when trying to view any links.  I don’t know how useful this feature will be to all of you, but I think there is a time and place for everything.  I can definitely see this being useful in some cases.  This isn’t a new feature either.  I think its been around since at least Visual Studio 2003, but I could be wrong.



Wayne Odom said:

Dug for 20 minutes before I figured this out.  Was trying to figure out what the little arrow was about on the files.   Good blog entry.

June 3, 2010 1:03 PM

Josh Painter said:

Just did a google search for this and you came up first. Small world. Thanks! :)

September 24, 2010 12:10 AM

CoreyRoth said:

@Josh Indeed.  I hope it helped!

September 24, 2010 8:40 AM

Dave said:

I use it for resource files common between a server project and a client project. Very handy!

October 14, 2010 10:55 AM

marandescu said:

As Josh, I ended up on your blog following a google search for this feature. straight to the point, thanks :)

January 20, 2011 9:11 AM

MarceQ said:

I didn't have the Add As Link Option, I just have the standard Add and the "Show previous versions" options...   anybody knows why?

I'm using VS 2010 Professional....

February 15, 2011 10:22 AM

Thomas said:

Thanks for that very userful peace of information!

March 9, 2011 2:05 AM

Rahul Techie said:

Not able to see this option for Web Site

July 5, 2011 11:56 PM

Castle include WCF hosting - Programmers Goodies said:

Pingback from  Castle include WCF hosting - Programmers Goodies

October 10, 2011 10:25 PM

The Red Circuit - TFS Build With Octopus Deploy (Part 2) said:

Pingback from  The Red Circuit - TFS Build With Octopus Deploy (Part 2)

January 23, 2012 5:26 PM

One App for 7.1 and 7.0 | PHP Developer Resource said:

Pingback from  One App for 7.1 and 7.0 | PHP Developer Resource

May 23, 2012 12:26 PM

Mable John said:

Thank you

June 29, 2012 3:05 AM

Shared Projects für Plugins and Workflows – xRM & .Net Development said:

Pingback from  Shared Projects für Plugins and Workflows – xRM & .Net Development

July 7, 2014 2:02 AM

Creating Linked Files in Visual Studio | Zaruba Answers said:

Pingback from  Creating Linked Files in Visual Studio | Zaruba Answers

December 13, 2014 1:27 AM

Leave a Comment


About CoreyRoth

Corey Roth is an independent SharePoint consultant specializing in ECM, Apps, and Search.
2018 dotnetmafia.
Powered by Community Server (Non-Commercial Edition), by Telligent Systems