In the context of assemblies in C#, what does activation scoping refer to?

I'm reading the documentation on Assemblies in the C# documentation, and the term activation scoping is used without much context. I understand the concept of scope by itself. Here is the context I found the term in:

Assemblies form the fundamental units of deployment, version control, reuse, activation scoping, and security permissions for .NET-based applications. An assembly is a collection of types and resources that are built to work together and form a logical unit of functionality. Assemblies take the form of executable (.exe) or dynamic link library (.dll) files, and are the building blocks of .NET applications. They provide the common language runtime with the information it needs to be aware of type implementations.

Assemblies in .NET

1 answer

  • answered 2019-12-07 01:29 David Browne - Microsoft

    Yes, this is vague.

    "Activation" does not have a precise technical meaning in the CLR, or in C#. But it is a technical term in COM, the Component Object Model, which is the native Windows component model that predates and co-exists with .NET.

    In COM Activation means "The process of loading an object in memory, which puts it into the running state." (https://docs.microsoft.com/en-us/windows/win32/com/com-glossary)

    You can see a holdover from this terminology in the naming of the System.Activator type, which has similar functionality to the COM activator function CoCreateInstance.

    In .NET a Type lives in a specific Assembly, and a Type name is unique within an Assembly. At runtime Types with the same name might be contained in other Assemblies that are currently loaded into your AppDomain. But whenever you are creating an object instance (ie an "activation"), you either specify the Type (which implies a specific Assembly), or the Assembly and Type name.

    In the normal case of writing a type name in code, the compiler will identify which referenced Assembly to use for the target Type, and if multiple Types with the same name are found at compile time, the compiler will either give you a warning CS0436, or an error CS0433.

    In the case of Reflection, you can load a Type by name, but you always have to specify an Assembly to load the type from. Notice that there's not an overload of Activator.CreateInstance that just takes a Type name, and Type.GetType also requires you to specify an Assembly.

    In either case you are "activating" the object from a specific Assembly. So the Assembly defines the "scope" for the Type "activation".