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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T18:23:32+00:00 2026-05-23T18:23:32+00:00

I have 2 library projects: AProject and BProject and one web project: WebProject. AProject

  • 0

I have 2 library projects: AProject and BProject and one web project: WebProject.
AProject has a class:

public class WorkerManager {
    public Worker Get(long workerId) {
        ....
        ....
    }

    public Worker Get(Guid companyId, long workerId) {
        ....
        ....
    }
}

I would like classes from BProject to be able to use the first version of the Worker Get:

WorkerManager  a=new WorkerManager ();
a.Get(8);

And I would like this method to be hidden for the web project.

If I make the Worker Get(long workerId) internal, then BProject will not be able to use this method, and if I make it public the web project gets access to this method.

How can I prevent access to the web project and allow access to the BProject?

  • 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-23T18:23:32+00:00Added an answer on May 23, 2026 at 6:23 pm

    It sounds like you need Friend Assemblies.

    They basically allow you to make your class internal, but specify that BProject should have access to the internal classes of AProject.

    Update

    I’ve never actually had to use Friend Assemblies, so I won’t be able to give you any better direction than Google can.

    Other people have mentioned using interfaces, and I agree that this is generally a good approach. Whether or not it works for you will depend on the structure of your code, though. Let’s say you move the WorkerManager class to a new Project (C). Project C depends on Project B. Project A depends on both C and B. WebProject depends on A and B.

             /-------------\
    WebProject -> A -> C -> B
                   \-------/
    

    Project B now defines an interface like the following:

    public interface IWorkerManager 
    {
        public Worker Get(long workerId);
    }
    

    And WorkerManager in Project C implements the interface:

    public class WorkerManager : IWorkerManager {...}
    

    Now Project A can produce IWorkerManagers via a factory, so your Web Project never has to say new WorkerManager().

    public class WorkerManagerFactory
    {
        public IWorkerManager Get() {return new WorkerManager();}
    }
    

    Now it’s still possible for Project A to access the other methods:

    new WorkerManager().Get(compGuid, workerId);
    

    … but Web Project can only access what’s been defined by the interface:

    new WorkerManagerFactory().Get().Get(workerId);
    

    This illustrates one way that you might achieve what you’re looking for. You could find better solutions by leveraging Dependency Injection, but this explanation is getting well beyond the scope of the original question.

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

Sidebar

Related Questions

I have a solution that contains two projects. One project is an ASP.NET Web
I have two projects in the same solution, VS2k10. One is a class library,
Let's say I have a project that is a class library. I have a
I have a VS solution that contains 6 library projects and 1 web folder
I have an solution in VS 2008 which contains two class library projects and
I have a visual studio 2008 solution with multiple c# library projects, a Web
I have three web application projects that share a common library of custom server
I have a workspace containing 2 projects: A project that has 2 products: a
I have 2 projects ( source code) . The project A is the library
I have a test project using Log4net. When I add a class library (from

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.