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 9124965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T06:41:26+00:00 2026-06-17T06:41:26+00:00

I have two class library projects: DataAccessLibrary and ServiceLayerLibrary . ServiceLayerLibrary needs access to

  • 0

I have two class library projects: DataAccessLibrary and ServiceLayerLibrary.
ServiceLayerLibrary needs access to the DataAccessLibrary‘s methods and properties, but other projects must not have access to DataAccessLibrary.

How can I achieve this?

  • 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-17T06:41:28+00:00Added an answer on June 17, 2026 at 6:41 am

    Have your members in DataAcceessLibrary internal and make use of friend assemblies so that ServiceLibrary may access them.

    The internal keyword (in C#) gives access to other classes within the same assembly. Friend is the equivalent keyword in VB.Net. However, if you want another assembly to have access to another assembly’s “internal” stuff (in C#), then you can use the method from the web link below called “Friend Assemblies” where it exposes one assembly’s “internal” stuff to another assembly. Nowhere in this process do you actually use a keyword friend or friendly in C#. It is simply what they have called this relationship where you say [assembly:InternalsVisibleTo(“MyAssembly”)]. This is useful in situations where you have one assembly that utilizes functionality from another assembly that you do not want to make public. You can also use this technique with a strongly-named assembly like so [assembly: InternalsVisibleTo(“MyAssembly, PublicKey=xXxXx”)].

    Example:

    using System.Runtime.CompilerServices;
    using System;
    
    [assembly: InternalsVisibleTo("ServiceLibrary")]
    
    // The class is internal by default. 
    class FriendClass
    {
        public void Test()
        {
            Console.WriteLine("Sample Class");
        }
    }
    
    // Public class that has an internal method. 
    public class ClassWithFriendMethod
    {
        internal void Test()
        {
            Console.WriteLine("Sample Method");
        }
    }    
    

    You may also use an alternative signing approach which might be better if you need public members in your DataAccessLibrary. It can be achieved by using LinkCommand with StrongNameIdentityPermission ( see http://www.codeproject.com/Articles/339909/Limiting-the-accessibility-Another-way-of-Friend-A ).

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

Sidebar

Related Questions

I have two solutions, one is a class library and the other is a
I have two projects which is calling a Class Library. Can i in my
Having two projects: one is a class library (a .dll assembly) and the other
I have a Visual Studio solution with two projects: MyApp.MvcUI and MyApp.Domain (class library).
I have two projects in one solution : Class Library for my BLL and
I have a console application and two class library projects. The console application has
Here is situation: I have two projects. ConsoleApp and Class Library. Console app references
I have an solution in VS 2008 which contains two class library projects and
I have two projects in the same solution, VS2k10. One is a class library,
I have a Visual Studio solution with two projects : A class library MyLib

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.