50+ .Net Assemblies Interview Questions and Answers

Spread the love

Dot Net Assemblies Interview Questions

What Is An Assembly?

Assemblies are the fundamental constructing blocks required for any utility to perform within the .NET realm. They are partially compiled code libraries that kind the basic unit of deployment, versioning, activation scoping, reuse, and safety. Typically, assemblies present a set of varieties and sources that work collectively to kind a logical unit of performance. They are the smallest deployable items of code in .NET. Compared to the executable recordsdata assemblies are way more dependable, safer, and simple to handle. An meeting incorporates much more than the Microsoft Intermediate Language (MSIL) code that’s compiled and run by the Common Language Runtime (CLR). In different phrases, you possibly can say that an meeting is a set of a number of modules and lessons compiled in MSIL, and metadata that describes the meeting itself, in addition to the functionalities of the meeting lessons.

What Is Namespace?

The namespace key phrase is used to declare a scope. This namespace scope enables you to manage code and offers you a solution to create globally distinctive varieties.

Within a namespace, you possibly can declare a number of of the next varieties:

  • Another namespace
  • Class
  • Interface
  • Struct
  • Enum
  • Delegate

Whether or not you explicitly declare a namespace in a C# supply file, the compiler provides a default namespace. This unnamed namespace, typically known as the worldwide namespace, is current in each file. Any identifier within the world namespace is accessible to be used in a named namespace.

Namespaces implicitly have public entry and this isn’t modifiable.

It is feasible to outline a namespace in two or extra declarations.e.g: namespace MyCompany.Proj1{ class MyClass { }} namespace MyCompany.Proj1{ class MyClass1 { }}

Namespaces have the next properties:

  • They manage massive code tasks.
  • They are delimited by utilizing the . operator.
  • The utilizing directive obviates the requirement to specify the identify of the namespace for each class.
  • The world namespace is the “root” namespace: world::System will at all times check with the .NET Framework namespace System.

Explain About Using Directive?

The utilizing directive has two makes use of:

  • To permit using varieties in a namespace so that you just wouldn’t have to qualify using a sort in that namespace
  • To create an alias for a namespace or a sort. This is known as a utilizing alias directive.
  • The scope of a utilizing directive is restricted to the file by which it seems. Create a utilizing alias to make it simpler to qualify an identifier to a namespace or sort.Namespaces are available two classes: user-defined and system-defined. User-defined namespaces are namespaces outlined in your code.

Name The Different Components Of An Assembly?

An meeting is a logical unit that’s made up of the next 4 various kinds of parts:

  • Assembly manifest
  • MSIL supply code
  • Type metadata
  • Resources

What Is An Application Domain?

A boundary that the widespread language runtime establishes round objects created throughout the identical utility scope. Application domains assist isolate objects created in a single utility from these created in different functions in order that run-time conduct is predictable. Multiple utility domains can exist in a single course of.

What Are The Different Types Of Assemblies? Explain Them In Detail?

The following are the 2 kinds of assemblies:

Private Assembly: Refers to the meeting that’s utilized by a single utility. Private assemblies are stored in a neighborhood folder by which the consumer utility has been put in.

Public or Shared Assembly: Refers to the meeting that’s allowed to be shared by a number of functions. A shared meeting should reside in Global Assembly Cache (GAC) with a robust identify assigned to it.

For instance, think about that you’ve got created a DLL containing details about your business logic. This DLL can be utilized by your consumer utility. In order to run the consumer utility, the DLL have to be included in the identical folder by which the consumer utility has been put in. This makes the meeting non-public to your utility. Now suppose that the DLL must be reused in several functions. Therefore, as a substitute of copying the DLL in each consumer utility folder, it may be positioned within the world meeting cache utilizing the GAC device. These assemblies are referred to as shared assemblies.

What Is A Satellite Assembly?

Satellite assemblies are assemblies which can be used to deploy language and tradition particular sources for an utility. In an utility, a separate product ID is assigned to every language and a satellite tv for pc meeting is put in in a language particular sub-directory.

What Is Global Assembly Cache?

Each pc the place the widespread language runtime is put in has a machine-wide code cache referred to as the worldwide meeting cache. The world meeting cache shops assemblies particularly designated to be shared by a number of functions on the pc.

You ought to share assemblies by putting in them into the worldwide meeting cache solely when you could. As a common guideline, preserve meeting dependencies non-public, and find assemblies within the utility listing until sharing an meeting is explicitly required. In addition, it’s not vital to put in assemblies into the worldwide meeting cache to make them accessible to COM interop or unmanaged code.

There are a number of methods to deploy an meeting into the worldwide meeting cache:

  • Use an installer designed to work with the worldwide meeting cache. This is the popular choice for putting in assemblies into the worldwide meeting cache.
  • Use a developer device referred to as the Global Assembly Cache device (Gacutil.exe), supplied by the Windows Software Development Kit (SDK).
  • Use Windows Explorer to pull assemblies into the cache.

Assemblies deployed within the world meeting cache should have a robust identify. When an meeting is added to the worldwide meeting cache, integrity checks are carried out on all recordsdata that make up the meeting. The cache performs these integrity checks to make sure that an meeting has not been tampered with, for instance, when a file has modified however the manifest doesn’t mirror the change.

Is Versioning Applicable To Private Assemblies?

No, versioning will not be relevant to non-public assemblies as these assemblies reside of their particular person folders. Versioning could be utilized to GAC solely.

What Is Metadata?

An meeting metadata describes each information sort and member outlined within the code. It shops the outline of an meeting, resembling identify, model, tradition, public key of an meeting together with the categories exported, different assemblies depending on this meeting, and safety permissions wanted to run the applying. In addition, it shops the outline of varieties, such because the identify, visibility, base class, interfaces carried out, and members, resembling strategies, fields, properties, occasions, and nested varieties.

It additionally shops attributes. Metadata is saved in binary format. Therefore, metadata of an meeting is sharable amongst functions that execute on varied platforms. It may also be exported to different functions to provide details about the providers and varied options of an utility.

What Is Assembly Manifest?

Assemblies keep all their data in a particular unit referred to as the manifest. Every meeting has a manifest.

The followings are the contents of an Assembly Manifest:

Assembly identify: Represents a textual content string that specifies the meeting’s identify.

Version quantity: Represents a serious and minor model quantity, in addition to a revision and construct quantity. The CL.R makes use of those numbers to implement model coverage.

Culture: Represents data of the tradition or language, which the meeting helps. An meeting is a container of solely sources containing culture- or language-specific data.

Strong identify data: Represents the general public key from the writer, if a robust identify is assigned to an meeting.

List of all recordsdata within the meeting: Represents a hash of every file contained within the meeting and a file identify.

Type reference data: Represents the data used on the runtime to map a sort reference to the file that incorporates its declaration and implementation.

Information on referenced assemblies: Represents a listing of different assemblies which can be statically referenced by the meeting. Each reference consists of the names of dependent assemblies, meeting metadata (model, tradition, working system, and so on), and public key, if the meeting is robust named.

What Is The Value Of The Copy Local Property When You Add An Assembly In The Gac?

False.

What Is Native Image Generator?

The Native Image Generator (Ngen.exe) is a device that creates a local picture from an meeting and shops that picture to native picture cache on the pc. Whenever, an meeting is run, this native picture is mechanically used to compile the unique meeting. In this manner, this device improves the efficiency of the managed utility by loading and executing an meeting sooner.

Note that native photos are recordsdata that encompass compiled processor-specific machine code. The Ngen.exe device installs these recordsdata on to the native pc.

Name The Msil Disassembler Utility That Parses Any .web Framework Assembly And Shows The Information In Human Readable Format?

The Ildasm.exe utility.

What Is The Significance Of The Strong Name Tool?

The Strong Name utility (sn.exe) helps in creating distinctive public-private key pair recordsdata which can be referred to as robust identify recordsdata and signing assemblies with them. It additionally permits key administration, signature era, and signature verification.

How Can Different Versions Of Private Assemblies Be Used In The Same Application Without A Re-build?

You can use completely different variations of personal assemblies in the identical utility with no re-build by specifying the meeting model within the AssemblyInfo.cs or AssemblyInfo.vb file.

What Is Global Assembly Cache (gac) ?

GAC is a central repository (cache) in a system by which assemblies are registered to share amongst varied functions that execute on native or distant machines. .NET Framework offers the GAC device (gacutil.exe utility), which is used to view and change the content of GAC of a system. Adding new assemblies to GAC and eradicating assemblies from GAC are a number of the duties that may be carried out by utilizing the gacutil.exe utility. GAC can include a number of variations of the identical .NET meeting. CLR checks GAC for a requested meeting earlier than utilizing data of configuration recordsdata.

The gacutil.exe /i <meeting identify> – is the command that’s used to put in an meeting in GAC. Users use the Command Prompt of Visual Studio to put in an meeting in GAC by utilizing this command.

You can see all of the assemblies put in within the GAC utilizing the GAC viewer, which is positioned on the <WinDrive>:<WinDir>meeting listing, the place <WinDir> is home windows in Windows XP or home windows in Windows Vista or WinNT in Windows 2000. Apart from the record of assemblies, the meeting viewer additionally exhibits related data, resembling the worldwide meeting identify, model, tradition, and the general public key token.

Where Is The Information Regarding The Version Of The Assembly Stored?

Information for the model of meeting is saved contained in the meeting manifest.

Discuss The Concept Of Strong Names?

Whenever, an meeting is deployed in GAC to make it shared, a robust identify must be assigned to it for its distinctive identification. A powerful identify incorporates an meeting’s full id – the meeting identify, model quantity, and tradition data of an meeting. A public key and a digital signature, generated over the meeting, are additionally contained in a robust identify. A powerful identify makes an meeting an identical in GAC.

What Is The Difference Between .exe And .dll Files?

EXE:

  • It is an executable file, which could be run independently.
  • EXE is an out-process part, which signifies that it runs in a separate course of.
  • It can’t be reused in an utility.
  • It has a essential perform.

DLL:

  • It is Dynamic Link Library that’s used as part of EXE or different DLLs. It can’t be run independently.
  • It runs within the utility course of reminiscence, so it’s referred to as as in-process part.
  • It could be reused in an utility.
  • It doesn’t have a essential perform.

Which Utility Allows You To Reference An Assembly In An Application?

An meeting could be referenced by utilizing the gacutil.exe utility with the /r choice. The /r choice requires a reference sort, a reference ID, and an outline.

The Assemblyinfo.cs File Stores The Assembly Configuration Information And Other Information, Such As The Assembly Name, Version, Company Name, And Trademark Information. (true/false)?

True.


Spread the love