Accessing an Internal Class in Multi-file Assemblies

  • Thread starter msnews.microsoft.com
  • Start date
M

msnews.microsoft.com

How can we access an internal class in a referenced file in a multi-file
assembly. All documentation states the obvious purpose of the internal
keyword on a class, but when referencing an assembly, I fear it means
single-file assembly. That means even if the assembly is strong-named and
versioned, it will not reach internal classes. So much for code reuse while
hiding classes from external objects. I can't find examples or explanations
of how to do this.

Here is a layout of the problem:

_______________________________________________
namespace ns1 (with strong name)
Lib1.dll --------------------------------------------------
internal Class1
public Class2

App1.exe ------------------------------------------------
- Problem - references Lib1.dll in this multi-file assembly but can
only reach Class1 if it is public (a bad thing).
_______________________________________________
namespace ns2 (without strong name - any external application)
App2.exe -------------------------------------------------
- No Problem - references Lib1.dll and can access Class2 but as
expected not Class1


Thanks for any response.
-VinceB
 
J

Joe

msnews.microsoft.com said:
How can we access an internal class in a referenced file in a multi-file
assembly. All documentation states the obvious purpose of the internal
keyword on a class, but when referencing an assembly, I fear it means
single-file assembly. That means even if the assembly is strong-named and
versioned, it will not reach internal classes. So much for code reuse while
hiding classes from external objects. I can't find examples or explanations
of how to do this.

Here is a layout of the problem:

_______________________________________________
namespace ns1 (with strong name)
Lib1.dll --------------------------------------------------
internal Class1
public Class2

App1.exe ------------------------------------------------
- Problem - references Lib1.dll in this multi-file assembly but can
only reach Class1 if it is public (a bad thing).
_______________________________________________
namespace ns2 (without strong name - any external application)
App2.exe -------------------------------------------------
- No Problem - references Lib1.dll and can access Class2 but as
expected not Class1

Hi VinceB,

App1.exe and Lib1.dll are separate assemblies. The strong name isn't a
factor here.

Joe
 
S

Suzanne Cook [MS]

I think that Joe was implying that you have these two files compiled as
different assemblies, causing internal methods from one to not be visible to
the other. You need to compile one as a netmodule ("csc /t:module" from the
command line), and include that when compiling the other ("csc /addmodule
lib.netmodule"), so that they will be in the same assembly.

Suzanne Cook
My .NET CLR Loader blog: http://blogs.gotdotnet.com/suzcook/
--
Please do not respond directly to this alias. This alias is for newsgroup
purposes only. This posting is provided "AS IS" with no warranties, and
confers no rights.


msnews.microsoft.com said:
One more clarification please.

This means if I want a secure API DLL to be used by my EXE and unknown and
possibly rogue clients, I either give clients everything or limit my rich
EXE or duplicate code or pass out instances of an interface or something.

I want multiple modules in an app that can be updated automatically from the
web but if they can't see each other unless all classes are public, I see
one big DLL.


Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top