I have a solution consisting of about 10 important DLL files which are developed inside the same solution, when I release this solution, all the DLL files (public classes and functions inside) are open and usable to all others. How can I make the classes and functions inside a dll file visible and usable only by the same solution?!
Regards.
From your question, I understand that you know beforehand (i.e. at compile-time) what assemblies will be shipped together.
Therefore, there are two solutions:
Either, you mark your types as
internaland deploy all of your code in one assembly. As you appear to be shipping all of the assemblies together, there’s not really an inevitable reason to not combine everything in one assembly before shipping (except for licensing issues).If you can do that, you can still develop everything as separate projects and use some build tool to create an umbrella project file that includes all of your code.
Or, you make your types
internaland declare the other assemblies in your solution as friends.Declare the
InternalsVisibleToAttributeon an assembly whose internal types should be visible to another assembly in your solution.Note that I’ve interpreted “visible” in the sense of “visible” to the compiler, so someone referencing your assembly can code against your APIs. If you want to prevent your code from really being visible in any fashion, you’ll have to use obfuscation as suggested in CodeCaster‘s comment, and even that is probably not unbreakable.