Wednesday, April 6, 2011

What is a private assembly in .Net?

I understand access modifiers at the class level and below, but why would an entire assembly be private? I assume by default, assemblies are public?

From stackoverflow
  • Well, in the context of assemblies, private means the assembly cannot be referenced by another application outside the directory it's contained in. Therefore, private to the application it's being used for.

    As for your question about the default being public....someone correct me if I'm wrong, but there is no public. It would be shared. A shared assembly can obviously be referenced by multiple applications and must reside in the GAC. All the rules of the GAC would then apply.

    John Rudy : Technically, you can share assemblies without them residing in the GAC, but it's extremely cumbersome and invasive. See http://www.devcity.net/Articles/254/1/article.aspx for more; but generally I agree that shared assemblies SHOULD be in the GAC. :)
    Omar Abid : I think they can be called both shared and public, here's a quote from the 'Visual Basic Programming 2008' book 'Public assemblies are designed for shared use among multiple .NET applications.'
  • The private in private assembly is not an access modifier. This is just a term used for assembles that are specific to one application - i.e. in this application's directory, as opposed to shared assemblies in the Global Assembly Cache.

    Omar Abid : I began to understand... but that was very confusing!!

0 comments:

Post a Comment