Reputation: 1740
I have a few differenet namespaces in my solution and I want to use an object called "Doctor" from namespece BL_Backend inside another namespace called DAL. I've tried adding a Refference to DAL (a refference for BL_Backend), and then adding "using BL_Backend;" but it wouldn't work. still classes such as Doctor won't appear as known ones inside namespace DAL.
namespace BL_Backend
{
…
namespace DAL
{
…
//Here create object as "Doctor" for BL_Backend class
}
}
For example, when i call a constructor of a doctor from DAL it says this constructor does not exists but when i write the exact same command at namespace bl_backend it works fine.
thanks alot!
Upvotes: 0
Views: 2168
Reputation: 475
Classes without a modifier are internal by default, so ensure that your modifier is public. As a second option pay attention to the build order - its not a problem in VS12+ anymore, but in further versions it was.
Upvotes: 0
Reputation: 236328
I assume Doctor
is declared as internal class in BL_Backend
assembly. Note - if class does not have public
access modifier, then by default it will be internal
:
namespace BL_Backend
{
class Doctor // this class is internal
{
}
}
Internal classes are visible only within assembly they are defined (well, there is attribute InternalsVisibleTo which allows other assemblies to see internal classes, but without applying this attribute, class is not visible to other assemblies).
Upvotes: 1
Reputation: 33391
If you want to use a class Doctor
from an assembly BL_Backend
in a DAL
you must add a reference in DAL
to the BL_Backend
not vise versa.
Upvotes: 0