473,626 Members | 3,245 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Exposing internal members of an assembly

Hi,

I am trying to have a set of base classes and interfaces of an
application framework in their own assembly. That way, concrete
implementations of the API will reference that assembly and implement
the abstract classes and interfaces.

The problem is that some parts of the API are "internal" in the sense
that they are internal to the implementation. If I declare these parts
as internal in the API, the implementations will not be able to access
them.

The reason behind using "internal" members is to eliminate the need for
the proxy design pattern so I can pass objects between the implemation
and the GUI directly whilst ensuring that the appropriate access levels
are maintained.

Any thoughts?

Thank you,

Apr 20 '06 #1
5 2011
In "Programmin g .Net Components, 2nd Edition" (O'Reilly, July 2005, ISBN
0-596-10207-0) Juval Lowy shows how to do just want you want, assuming you
are in C# 2.0 (2005).

Section 2.2.8 of his book talks about a new attribute called
InteralsVisible To. In the AssemblyInfo.cs file, add this attribute:

[assembly: InternalsVisibl eTo("YourDllOrE xe")]

Any clients in the assemblies YourDllOrExe.EX E or YourDllOrExe.DL L will be
able to use any classes in your original dll and call both public and
internal members.

Haven't tried this yet myself, just happened to read about it last night so
it was good timing. It's more meant for situations where for whatever reason
a team decides to break a single DLL into multiple DLLs but parts in
different DLLs rely on internal members from the original.

Personally I think you ought to think about your design a bit, as you are
essentially exposing internal members and circumventing the whole of idea of
it being internal, but if you insist, well above is a way to do it.

Robert

<mm******@gmail .com> wrote in message
news:11******** **************@ u72g2000cwu.goo glegroups.com.. .
Hi,

I am trying to have a set of base classes and interfaces of an
application framework in their own assembly. That way, concrete
implementations of the API will reference that assembly and implement
the abstract classes and interfaces.

The problem is that some parts of the API are "internal" in the sense
that they are internal to the implementation. If I declare these parts
as internal in the API, the implementations will not be able to access
them.

The reason behind using "internal" members is to eliminate the need for
the proxy design pattern so I can pass objects between the implemation
and the GUI directly whilst ensuring that the appropriate access levels
are maintained.

Any thoughts?

Thank you,


----== Posted via Newsfeeds.Com - Unlimited-Unrestricted-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Apr 20 '06 #2
Thanks a lot for your reply. Although your solution works, the base
assembly (Framework API) must be aware of its clients which is not
really practical.

Regarding the design, the problem is that the implementation must
specify methods that are internal to itself, so its kinda weird.

I found a possible but cumbersome solution and that is to use "modules"
which are assemblies without manifests. Basically, I can make a module
and include in an assembly and the assembly would have access to the
module's internal members. The problem with this is that it can only be
done with the command line compiler. VS 2005 doesn't support it.

Apr 20 '06 #3
<mm******@gmail .com> wrote:
I am trying to have a set of base classes and interfaces of an
application framework in their own assembly. That way, concrete
implementations of the API will reference that assembly and implement
the abstract classes and interfaces.

The problem is that some parts of the API are "internal" in the sense
that they are internal to the implementation. If I declare these parts
as internal in the API, the implementations will not be able to access
them.

The reason behind using "internal" members is to eliminate the need for
the proxy design pattern so I can pass objects between the implemation
and the GUI directly whilst ensuring that the appropriate access levels
are maintained.

Any thoughts?


So you want the derived classes to have access to the members in the
base classes, but you don't want other classes to have access to those
members? If so, you just need protected access.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 20 '06 #4
That will deny derived classes from using each other which is what the
framework is all about. The primary problem is that the framework API
will reside in a different assembly.
For example, I can use the "protected internal" access level but that
would mean that classes in the implementation will not have access to
"protected internal" members.

Apr 20 '06 #5
<mm******@gmail .com> wrote:
That will deny derived classes from using each other which is what the
framework is all about.
Ah - that wasn't clear.
The primary problem is that the framework API will reside in a different
assembly.


It sounds like the members should basically be public then. Yes,
there's a risk that components which shouldn't use those members will
use them - but I suspect the risk is small in reality.

--
Jon Skeet - <sk***@pobox.co m>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Apr 20 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
7158
by: Andrew R. Thomas-Cramer | last post by:
Can I simply mark a class as internal, or should I change all its public members to internal as well? If I can mark the class only as internal, it makes modifications easy.
3
5744
by: Dave Veeneman | last post by:
Is there a way to expose an internal class as a public property of its parent object? Let's say I have a Customer object with Public accessibility. It has an Addresses collection property that it populated with Address objects. This property has Public accessibility, as well. To keep the assembly interface clean, I want to hide the objects on which the property is based (The Address and Addresses objects) from users outside the assembly....
7
9812
by: Jesper | last post by:
I need to grant a class access to protected fields of another class in the way its possible in C++ with the friend keyword. However I would like to keep the class protected towards other class within the same program/assembly. The two classes are not 'related' (inherited). How can I do this. I cant see how the keyword Internal can be used for this purpose.
19
3562
by: Martin Oddman | last post by:
Hi, I have a compiling problem. Please take a look at the code below. I have an application that is built upon three tiers: one data tier (Foo.DataManager), one business tier (Foo.Kernel) and one web presentation tier (Foo.WebFiles). The data tier shall only be accessible thru the business tier so I do NOT want a reference to the data tier in the presentation tier. In the business tier I have a class with the name CategoryItem that...
6
11992
by: Sgt. Sausage | last post by:
I know it's not possible, but I need a protected internal interface: protected internal interface ISomeInterface{ // yadda yadda yadda } Basically, I need an interface that is completely accessable from within the assembly (internal), but is not valid outside
6
2333
by: Plamen Doykov | last post by:
Hi all I have converted a simple project from ASP.NET 1 to 2.0 with the latest prerelease of Visual Studio 2005. The problem is I can't access internal members from the code behind. It gives: error CS0122: 'Class' is inaccessible due to its protection level This happens only when access members from code behind, not from the other classes. It compiles OK when making the class and its members public. However, I don't want to do that....
9
2155
by: JT | last post by:
Here is the overall structure I will be referring to: End-program ProvideWorkFlow.dll Forms and methods that properly manipulate calls to methods in AccessUtils AccessUtils (a web service) Hide.dll methods and data I want to remain hidden I have a DLL, Hide.dll, that contains methods that I want to handle for
4
7562
by: =?Utf-8?B?QkogU2FmZGll?= | last post by:
We have a class that has a public property that is of type List<T>. FXCop generates a DoNotExposeGenericLists error, indicating "System.Collections.Generic.List<Tis a generic collection designed for performance not inheritance and, therefore, does not contain any virtual members. The following generic collections are designed for inheritance and should be exposed instead of System.Collections.Generic.List<T>. *...
4
1705
by: bob_jenkins | last post by:
C# allows code to be generated, but the generated code is in its own assembly. Is there a way for that generated code to access internal classes in the assembly that produced it? To have the generated code pretend to be part of the assembly that produced it? Maybe some compilation option? I want the generated code for efficiency, but I don't want to pay for it by making all sorts of classes public that would otherwise be internal.
0
8269
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8642
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8512
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7203
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5576
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4094
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
1815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1515
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.