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

  • Home
  • SEARCH
  • 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 9274977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:28:48+00:00 2026-06-18T16:28:48+00:00

I’m quite new to c# programming. So lets assume we have two assemblies Asm1,

  • 0

I’m quite new to c# programming.
So lets assume we have two assemblies Asm1, Asm2 in which two classes are defined as Follows:

//Asm1
namespace ClassLibrary1
{
public class A//: B
  {
    B b = new B { i = 2};
    public int MyProperty { get { return b.i; } }
  }
}

//Asm2
namespace ClassLibrary2
{
  public class B
  {
    public int i;
  } 
}

Asm1 references Asm2
Now we have a runnable assembly say,asm3, that uses Asm1 with following piece of code:

//Asm3
A a = new A();
System.Console.Write(a.MyProperty.ToString());

the above codes compiles right with no error.

But things go wrong when we make little change in class A and have it inherited from class B.
In this case line: A a = new A(); doesn’t compile and produces error.
But when we add asm2 as a reference to asm3 it works. please tell me why is that.
why do an assembly ,with no direct dependency to another assembly, have to reference it?
thanks in advance.

  • 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-06-18T16:28:50+00:00Added an answer on June 18, 2026 at 4:28 pm

    In this case the compiler requires access to the assembly where the base class of a type that you use (namely A), is declared. The exact rules are somewhat complex.

    It is reported that with .NET 4.0 and Visual Studio 2010, if you in one assembly inherited a class from a second assembly which exposed types from an unreferenced third assembly (and your own project did not expose any of these types), it would work fine. But when upgrading to .NET 4.5 and Visual Studio 2012, the same code and reference combination fails, and you must refer the third assembly.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a small JavaScript validation script that validates inputs based on Regex. I

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.