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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T00:53:10+00:00 2026-05-24T00:53:10+00:00

In my solution I have a DLL project, say Project1 , that owns a

  • 0

In my solution I have a DLL project, say Project1, that owns a class, say class A. This class has some properties, so vital that must only be set in this DLL. Any other projects that references this DLL can only use the getters. So far I have handled the situation by accessing the setters internally, like:

public class A
{
  int Num1 
  {
    get; 
    internal set;
  }

  int Num2 
  {
    get; 
    internal set;
  }
} 

Right now I have to add another project, Project2, to the solution that not only must use class A (both getters and setter) but also, Project1 has a reference to this new project. So I decided to separate class A in a different definition dll, on the top of the hierarcy. That is the point, my problem araises. Now all the setters are invisible to Project1 and Project2. If I remove the internal accessor then setters will be available to any assembly that references the definition dll. I do not want this because the information on the class A is so important, it must not be set mistakenly.

How can I limit the access to the setters of class A from outside of Project1 and Project2?

Only solution comes to my mind is using InternalsVisibleTo. I do not know, it doesn’t sound perfect. Also combining Project1 and Project2 would be another another solution, but these two are responsible for completely different tasks, it is not the best option designwise.

  • 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-24T00:53:10+00:00Added an answer on May 24, 2026 at 12:53 am

    You can keep the internal protector on it, but give another assembly the trust to access the internal members.

    [assembly: InternalsVisibleTo("AssemblyName")]
    

    You can do this at the class level, or on the entire assembly itself if you want.

    InternalsVisibleToAttribute Class

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

Sidebar

Related Questions

Let's say you have a class library project that has any number of supplemental
In my project I have a DLL for some WPF/XAML controls that need to
I have a solution with a C++ dll project and a C# project that
I have a Visual Studio 2010 solution that contains 3 projects: a dll project,
Say I have some C++ project which builds an exe or dll file. The
I have a dll project in a solution that I want to debug. The
I have a solution in VS 2008 that creates a DLL. I then use
I have a dll project that references Microsoft.Practices.EnterpriseLibrary.Common.dll (= the dll ) from my
I have small solution, startup project dll project. In the dll project i have
My C# WinForms solution has two projects. A DLL which is the main project

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.