17. Assemblies || C# 10 Flashcards

1
Q

Again, what is an ‘assembly’?

A

An assembly is a basic unit of deployment in .NET and is also the container for all types. An assembly contains compiled types with their Intermediate Language (IL) code, runtime resources, and information to assist with versioning and referencing other assemblies. An assembly also defines a boundary for type resolution. In .NET, an assembly comprises a single file with a .dll extension.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is inside of an assembly?

A

An assembly contains four kinds of things:
1. An assembly manifest - Provides information to the CLR, such as the assembly’s name, version, and the assemblies that it references;
2. An application manifest - Provides information to the operating system, such as how the assembly should be deployed and whether administrative elevation is required;
3. Compiled types - the compiled IL code and metadata of the types defined within the assembly;
4. Resources - Other data embedded within the assembly, such as images and localizable text;

Of these, only the assembly manifest is mandatory, although an assembly nearly always contains compiled types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the purpose of assembly manifest?

A

The assembly manifest serves two purposes:
1. It describes the assembly to the managed hosting environments;
2. It acts as a directory to the modules, types and resources in the assembly;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What data is stored in assembly manisfest?

A

Here’s summary of the functionally significant data stored in the manifest:

  • The simple name of the assembly;
  • A version number (AssemblyVersion);
  • A public key and signed hash of the assembly, if strongly named;
  • A list of referenced assemblies, including their version and public key;
  • A list of types defined in the assembly;
  • The culture it targets, if a satelite assembly (AssemblyCulture);

The manisfest can also store the following informational data:

  • A full title and description (AssemblyTitle and AssemblyDescription);
  • Company and copyright information (AssemblyCompany and AssemblyCopyright);
  • A display version (AssemblyInformationalVersion);
  • Additional attributes for custom data;
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an ‘application manifest’ and how/when does it get used?

A

An application manifest is an XML file that communicates information about the assembly to the OS. An application manifest is embedded into the startup executable as a Win32 resource during the build process. If present, the manifest is read and processed before teh CLR loads the assembly - and can influence how Windows launches the application’s process.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a module in an assembly?

A

Intermediate container in which the contents of an assembly are packaged. A module corresponds to a file contents of an assembly. The reason for this extra layer of containership is to allow an assembly to span multiple files.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What do you know about strongly named assemblies?

A

Strongly naming an assembly was important in .NET Framework for two reasons:
1. It allowed the assembly to be loaded into the Global assembly cache.
2. It allowed the assembly to be referenced by other strongly named assemblies.
Strongly naming is much less important in .NET 5 and .NET Core, because these runtimes do not have a global assembly cache, nor do they impose the second restriction.
A strongly named assembly has a unique identity. It works by adding two bits of metada to the manifest:
1. A unique number that belongs to the authors of the assembly;
2. A signed hash of the assembly, proving that the unique number holder produced the assembly.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the ‘Authenticode’? What is the difference from strong-name signing?

A

Authenticode is a code-signing system whose purpose is to prove the identity of the publisher. Authenticode and strong-name signing are independent: you can sign an assembly with either or both systems.
Although strong-name signing can prove that assemblies A, B and C came from the same party, it can’t tell you who that party was. To know that the party was a John Doe you need Authenticode.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

In what scenario do we want to know what is the party/company/individual the assembly came from?

A

When downloading programs from the internet we want to know that a program came from whoever was named by the Certificate Authority and was not modified in transit.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What would you do to simulate running OS on a different language?

A

To simulate running on an OS with a different language, you must change the CurrentUICulture using the Thread class:
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("de");

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Why sometimes it is enough to set “de” as an culture code, while other time we need to specify code with a “-“ like sv-SE. What does it mean?

A

so, “sv” is a culture and “SE” is a subculture. It is better represented in for example German Austrian subcultures de-AT, and German German subculture de-De. It represents the regional variation of that language.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is an ‘Assembly load context’ and what does it do?

A

Assembly load context, in short, handles assemblies loading and resolution.
By subclassing AssemblyLoadContext and overriding its assembly resolution method (Load), you can control how a plug-in finds its dependencies. For example, you might decide that each plug-in should reside in its own folder, and its dependencies should also reside in that folder.
ALCs have another purpose: by instantiating a separate AssemblyLoadContext for each assembly, you can keep each isolated, ensuring that their dependencies load in parallel and do not interfere with one another (nor the host application)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly