Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5977933
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T21:26:31+00:00 2026-05-22T21:26:31+00:00

In Visual Studio, when do you have to add a reference to a dll?

  • 0

In Visual Studio, when do you have to add a reference to a dll? I always try to have a minimum of references in my projects, I try to only include the ones that are really necessary.

I would think that I only need a reference if I have a using statement in my source. But that’s not always enough.

For instance, I have a very simple program that is using System and Microsoft.Practices.EnterpriseLibrary.Data:

using System;
using Microsoft.Practices.EnterpriseLibrary.Data;

public class SimpleConnection {
    private static void Main() {
        var database = DatabaseFactory.CreateDatabase();
        var command =
            database.GetSqlStringCommand(
                "select table_name from information_schema.tables");
        using (var reader = database.ExecuteReader(command)) {
            while (reader.Read()) {
                Console.WriteLine(reader.GetString(0));
            }
        }
    }
}

I would think I only have to reference System and Microsoft.Practices.EnterpriseLibrary.Data. But that’s not true. If I don’t reference System.Data, the code won’t compile.

The type
‘System.Data.Common.DbCommand’ is
defined in an assembly that is not
referenced. You must add a reference
to assembly ‘System.Data,
Version=2.0.0.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089’.

How can I know beforehand when I have to add a reference to something I’m not using?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T21:26:32+00:00Added an answer on May 22, 2026 at 9:26 pm

    You have to add a reference to an assembly the class resides in, and any dependencies, that includes

    • return types from other assembly (ie. a method returns a DbCommand)
    • base class or interface from other assembly (ie. a class derives from DbCommand or implements an interface)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

When I add a reference to my dll in Visual Studio project, I am
Is there a way to have Visual Studio 2008 automatically add heading information to
As part of my Visual Studio utilities add-in SamTools , I have a mouse
I am trying to create a Visual Studio 2008 add in, so I have
I want certain projects in my solution opened in Visual Studio have different icons..Just
Every time I add a reference to a web project in visual studio 2008
Every time you start Visual Studio, the first time you click Add Reference to
In Visual Studio 2008 I can add a project reference and set Copy Local
We have a VB project that loads a reference to a .Net dll (which
I'm need some guidance in the way to add references in Visual Studio 2010.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.