Mar 8, 2009

.Net Interview Questions | Assembly - Part -2

6. How strong name being defined? OR What is strong name?
A strong name consists of the assembly's identity—its simple text name, version number, and culture information (if provided)—plus a public key and a digital signature. It is generated from an assembly file (the file that contains the assembly manifest, which in turn contains the names and hashes of all the files that make up the assembly), using the corresponding private key. There are SDK tools to sign an assembly with strong name. Assemblies with the same strong name are expected to be identical.

7. How to Sign an Assembly with strong Name?
The Windows Software Development Kit (SDK) provides several ways to sign an assembly with a strong name:
• Using the Assembly Linker(Al.exe) provided by the Windows SDK.
• Using assembly attributes to insert the strong name information in your code. You can use either the AssemblyKeyFileAttribute or the AssemblyKeyNameAttribute, depending on where the key file to be used is ocated.
Note: In the .NET Framework version 2.0, some compilers issue warning messages when attributes are used.
To create and sign an assembly with a strong name using the Assembly Linker
At the command prompt, type the following command:
al /out: /keyfile:
In this command, assembly name is the name of the assembly to sign with a strong name, module name is the name of the code module used to create the assembly, and file name is the name of the container or file that contains the key pair.
The following example signs the assembly MyAssembly.dll with a strong name using the key file sgKey.snk.
al /out:MyAssembly.dll MyModule.netmodule /keyfile:sgKey.snk

To sign an assembly with a strong name using attributes
In a code module, add the AssemblyKeyFileAttribute or the AssemblyKeyNameAttribute, specifying the name of the file or container that contains the key pair to use when signing the assembly with a strong name.
The following code example uses the AssemblyKeyFileAttribute with a key file called sgKey.snk, located in the directory where the assembly is compiled. This assumes that the assembly is compiled using the command-line compilers vbc.exe and csc.exe.
Visual Basic

C#
[assembly:AssemblyKeyFileAttribute(@"sgKey.snk")]


8. What is delay signing?
When signing an assembly, you might not always have access to a private key. For example, an organization might have a closely guarded key pair that developers do not have access to on a daily basis. While the public key might be available, access to the private key is restricted to a few individuals. In such a case, you can use delayed or partial signing to provide the public key, deferring the addition of the private key until the assembly is handed off.
Delay signing can be enabled in the Signing pane of the Project Designer as follows.
To delay sign an assembly
• With the project node selected in Solution Explorer, from the Project menu, click Properties (or right-click the project node in Solution Explorer, and click Properties).
• In the Project Designer, click the Signing tab.
• Select the Sign the assembly check box.
• Specify a key file. (ie key.snk)
• Select the Delay sign only check box. Note that a delay signed project will not run and cannot be debugged. You can, however, use the Strong Name Tool (Sn.exe) with the -Vr option to skip verification during development.

9. What is version number and Culture into Manifest?
Version number:- A major and minor version number, and a revision and build number. The common language runtime uses these numbers to enforce version policy.For example ... - 1.02.0012.0113
Culture:- This relates to Satellite assembly. This information should be used only to Pick an assembly as a satellite assembly containing culture- or language-specific information.

10. What do you mean by satellite assemblies?
The assemblies which contains only culture information are known as satellite assemblies.This assembly is used to get language specific resources for an application.
To know how to create satellite assmblies refer to http://msdn.microsoft.com/en-us/library/21a15yht(VS.71).aspx

.Net Interview Questions | [Assembly]

0 comments:

Post a Comment