Jean Paul's Blog

There are 2 types of People in the World, One who Likes SharePoint and..

    Advertisements
  • Microsoft MVP

  • MindCracker MVP

  • CodeProject MVP

  • eBook on SharePoint 2010

  • eBook on Design Patterns

  • eBook on Windows Azure

  • NLayers Framework @ CodePlex

  • MSDN Forums

  • .Net vs. Java

    Due to Public Demand
  • Advertisements

Archive for December, 2010

For Beginners: Adding References in Visual Studio

Posted by Paul on December 2, 2010

This is a simple post that shows how to add reference to projects in Visual Studio.

Project 1: Run Visual Studio and choose File>New Project>Console Application

image

Project 2: This time from the Solution Explorer choose Add>New Project

image

In the appearing dialog, choose Class Library

Projects

Now in the solution explorer, you can see two projects as shown below.

image

Now we have to refer the ClassLibrary1 project in the ConsoleApplication1.

For this, right click on the References item under ConsoleApplication1 and choose Add Reference.

image

The following dialog will appear.

image

The first tab .NET refers to .Net libraries you can refer to.  They will be residing in the GAC (Global Assembly Cache)

The COM tab refers to the registered COM servers in your machine.

The Projects tab refers to your existing projects in the solution.  It will not show the project from where Add Reference is invoked.

The Browse tab helps us to locate the library by exploring through your machine folders.

The Recent tab remembers your recently added references.  It is easier to locate them.

Projects Tab

Our tab of interest is Projects tab.  Click on the Projects tab and you will be able to see the ClassLibrary1.  Select it and click Ok.

image

That completes adding the reference.

Testing

From the ConsoleApplication1, you can select the Program.cs and type the following.

namespace ConsoleApplication1

{

    class Program

    {

        static void Main(string[] args)

        {

            ClassLibrary1.Class1 class1 = new ClassLibrary1.Class1();

        }

    }

}

If you can build the entire thing, you are done successfully.

Advertisements

Posted in C# | Tagged: , , | Leave a Comment »