Innovative Application Packaging Cloud

Innovative Application Packaging Cloud
Automated Packaging Self-Service (APS) is an innovative cloud solution that provides smart application packaging, testing and documentation.

Sunday, November 04, 2012

How to determine if a File Is an Assembly ???

A file is an assembly if and only if it is managed, and contains an assembly entry in its metadata.

How to manually determine if a file is an assembly

1.      Start the Ildasm.exe (MSIL Disassembler).
2.      Load the file you wish to test.
3.      If ILDASM reports that the file is not a portable executable (PE) file, then it is not an assembly.

Ildasm.exe (MSIL Disassembler)

The MSIL Disassembler is a companion tool to the MSIL Assembler (Ilasm.exe). Ildasm.exe takes a portable executable (PE) file that contains Microsoft intermediate language (MSIL) code and creates a text file suitable as input to Ilasm.exe.
This tool is automatically installed with Visual Studio and with the Windows SDK. To run the tool, i recommend that you use the Visual Studio Command Prompt or the Windows SDK Command Prompt (CMD Shell). These utilities enable you to run the tool easily, without navigating to the installation folder.
·         If you have Visual Studio installed on your computer: On the taskbar, click Start, click All Programs, click Visual Studio, click Visual Studio Tools, and then click Visual Studio Command Prompt
OR
If you have the Windows SDK installed on your computer: On the taskbar, click Start, click All Programs, click the folder for the Windows SDK, and then click Command Prompt (or CMD Shell).
·         At the command prompt, type the following:
ildasm [options] [PEfilename] [options]
The following options are available for .exe, .dll, .obj, .lib, and .winmd files.
Option
Description
/out= filename
Creates an output file with the specified filename, rather than displaying the results in a graphical user interface.
/rtf
Produces output in rich text format. Invalid with the /text option.
/text
Displays the results to the console window, rather than in a graphical user interface or as an output file.
/html
Produces output in HTML format. Valid with the /output option only.
/?
Displays the command syntax and options for the tool.


The following additional options are available for .exe, .dll, and .winmd files.

Option
Description
/bytes
Shows actual bytes, in hexadecimal format, as instruction comments.
/caverbal
Produces custom attribute blobs in verbal form. The default is binary form.
/linenum
Includes references to original source lines.
/nobar
Suppresses the disassembly progress indicator pop-up window.
/noca
Suppresses the output of custom attributes.
/project
Displays metadata the way it appears to managed code, instead of the way it appears in the native Windows Runtime. If PEfilename is not a Windows metadata (.winmd) file, this option has no effect.
/pubonly
Disassembles only public types and members. Equivalent to /visibility:PUB.
/quoteallnames
Includes all names in single quotes.
/raweh
Shows exception handling clauses in raw form.
/source
Shows original source lines as comments.
/tokens
Shows metadata tokens of classes and members.
/visibility: vis[+vis...]
Disassembles only types or members with the specified visibility. The following are valid values for vis:
PUB — Public
PRI — Private
FAM — Family
ASM — Assembly
FAA — Family and Assembly
FOA — Family or Assembly
PSC — Private Scope


The following options are valid for .exe, .dll, and .winmd files for file or console output only.

Option
Description
/all
Specifies a combination of the /header, /bytes, /stats, /classlist, and /tokens options.
/classlist
Includes a list of classes defined in the module.
/forward
Uses forward class declaration.
/headers
Includes file header information in the output.
/item: class[::member[(sig]]
Disassembles the following depending upon the argument supplied:
·         Disassembles the specified class.
·         Disassembles the specified member of the class.
·         Disassembles the memberof the class with the specified signature sig. The format of sig is:
[instance] returnType(parameterType1, parameterType2, …, parameterTypeN)
Note   In the .NET Framework versions 1.0 and 1.1, sig must be followed by a closing parenthesis: (sig). Starting with the Net Framework 2.0 the closing parenthesis must be omitted: (sig.
/noil
Suppresses MSIL assembly code output.
/stats
Includes statistics on the image.
/typelist
Produces the full list of types, to preserve type ordering in a round trip.
/unicode
Uses Unicode encoding for the output.
/utf8
Uses UTF-8 encoding for the output. ANSI is the default.


The following options are valid for .exe, .dll, .obj, .lib, and .winmd files for file or console output only.

Option
Description
/metadata[=specifier]
Shows metadata, where specifier is:
MDHEADER — Show the metadata header information and sizes.
HEX — Show information in hex as well as in words.
CSV — Show the record counts and heap sizes.
UNREX — Show unresolved externals.
SCHEMA — Show the metadata header and schema information.
RAW — Show the raw metadata tables.
HEAPS — Show the raw heaps.
VALIDATE — Validate the consistency of the metadata.
You can specify /metadata multiple times, with different values for specifier.
The following options are valid for .lib files for file or console output only.
Option
Description
/objectfile=filename
Shows the metadata of a single object file in the specified library.

Gacutil.exe (Global Assembly Cache Tool)
The Global Assembly Cache tool allows you to view and manipulate the contents of the global assembly cache and download cache.
This tool is automatically installed with Visual Studio and with the Windows SDK. To run the tool, i recommend that you use the Visual Studio Command Prompt or the Windows SDK Command Prompt (CMD Shell). These utilities enable you to run the tool easily, without navigating to the installation folder.
·         If you have Visual Studio installed on your computer: On the taskbar, click Start, click All Programs, click Visual Studio, click Visual Studio Tools, and then click Visual Studio Command Prompt.
OR
If you have the Windows SDK installed on your computer: On the taskbar, click Start, click All Programs, click the folder for the Windows SDK, and then click Command Prompt (or CMD Shell).
·         At the command prompt, type the following:
Copy
 
gacutil [options] [assemblyName | assemblyPath | assemblyListFile]
Argument
Description
assemblyName
The name of an assembly. You can supply either a partially specified assembly name such as myAssembly or a fully specified assembly name such as myAssembly, Version=2.0.0.0, Culture=neutral, PublicKeyToken=0038abc9deabfle5.
assemblyPath
The name of a file that contains an assembly manifest.
assemblyListFile
The path to an ANSI text file that lists assemblies to install or uninstall. To use a text file to install assemblies, specify the path to each assembly on a separate line in the file. The tool interprets relative paths, relative to the location of the assemblyListFile. To use a text file to uninstall assemblies, specify the fully qualified assembly name for each assembly on a separate line in the file. See the assemblyListFile contents examples later in this topic.
Option
Description
/cdl
Deletes the contents of the download cache.
/f
Specify this option with the /i or /il options to force an assembly to reinstall. If an assembly with the same name already exists in the global assembly cache, the tool overwrites it.
/h[elp]
Displays command syntax and options for the tool.
/i assemblyPath
Installs an assembly into the global assembly cache.
/if assemblyPath
Installs an assembly into the global assembly cache. If an assembly with the same name already exists in the global assembly cache, the tool overwrites it.
Specifying this option is equivalent to specifying the /i and /f options together.
/il assemblyListFile
Installs one or more assemblies specified in assemblyListFile into the global assembly cache.
/ir assemblyPath
scheme
id
description
Installs an assembly into the global assembly cache and adds a reference to count the assembly. You must specify the assemblyPath, scheme, id,and description parameters with this option. For a description of the valid values you can specify for these parameters, see the /r option.
Specifying this option is equivalent to specifying the /i and /r options together.
/l [assemblyName]
Lists the contents of the global assembly cache. If you specify the assemblyName parameter, the tool lists only the assemblies matching that name.
/ldl
Lists the contents of the downloaded files cache.
/lr [assemblyName]
Lists all assemblies and their corresponding reference counts. If you specify the assemblyName parameter, the tool lists only the assemblies matching that name and their corresponding reference counts.
/nologo
Suppresses the Microsoft startup banner display.
/r [assemblyName | assemblyPath]
scheme
id
description
Specifies a traced reference to an assembly or assemblies to install or uninstall. Specify this option with the /i, /il, /u, or /ul options.
To install an assembly, specify the assemblyPath, scheme, id,and description parameters with this option. To uninstall an assembly, specify the assemblyName, scheme, id,and description parameters.
To remove a reference to an assembly, you must specify the same scheme, id, and description parameters that were specified with the /i and /r (or /ir) options when the assembly was installed. If you are uninstalling an assembly, the tool also removes the assembly from the global assembly cache if it is the last reference to remove and if Windows Installer has no outstanding references to the assembly.
The scheme parameter specifies the type of installation scheme. You can specify one of the following values:
·         UNINSTALL_KEY: Specify this value if the installer adds the application to Add/Remove Programs in Microsoft Windows. Applications add themselves to Add/Remove Programs by adding a registry key to HKLM\Software\Microsoft\Windows\CurrentVersion.
·         FILEPATH: Specify this value if the installer does not add the application to Add/Remove Programs.
·         OPAQUE: Specify this value if supplying a registry key or file path does not apply to your installation scenario. This value allows you to specify custom information for the id parameter.
The value to specify for the id parameter depends on the value specified for the scheme parameter:
·         If you specify UNINSTALL_KEY for the scheme parameter, specify the name of the application set in the HKLM\Software\Microsoft\Windows\CurrentVersion registry key. For example, if the registry key is HKLM\Software\Microsoft\Windows\CurrentVersion\MyApp, specify MyApp for the id parameter.
·         If you specify FILEPATH for the scheme parameter, specify the full path to the executable file that installs the assembly as the id parameter.
·         If you specify OPAQUE for the scheme parameter, you can supply any piece of data as the id parameter. The data you specify must be enclosed in quotation marks ("").
The description parameter allows you to specify descriptive text about the application to install. This information is displayed when references are enumerated.
/silent
Suppresses the display of all output.
/u assemblyName
Uninstalls an assembly from the global assembly cache.
/uf assemblyName
Forces a specified assembly to uninstall by removing all references to the assembly.
Specifying this option is equivalent to specifying the /u and /f options together.
NoteNote
You cannot use this option to remove an assembly that was installed using Microsoft Windows Installer. If you attempt this operation, the tool displays an error message.
/ul assemblyListFile
Uninstalls one or more assemblies specified in assemblyListFile from the global assembly cache.
/u[ngen] assemblyName
Uninstalls a specified assembly from the global assembly cache. If the specified assembly has existing reference counts, the tool displays the reference counts and does not remove the assembly from the global assembly cache.
NoteNote
In the .NET Framework version 2.0, /ungen is not supported. Instead, use the uninstall command of the Ngen.exe (Native Image Generator).
In the .NET Framework versions 1.0 and 1.1, specifying /ungen causes Gacutil.exe to remove the assembly from the native image cache. This cache stores the native images for assemblies that have been created using the Ngen.exe (Native Image Generator).
/ur assemblyName
scheme
id
description
Uninstalls a reference to a specified assembly from the global assembly cache. To remove a reference to an assembly, you must specify the same scheme, id, and description parameters that were specified with the /i and /r (or /ir) options when the assembly was installed. For a description of the valid values you can specify for these parameters, see the /r option.
Specifying this option is equivalent to specifying the /u and /r options together.
/?
Displays command syntax and options for the tool.



Examples

The following command installs the assemblies specified in the file assemblyList.txt into the global assembly cache. 
gacutil /il assemblyList.txt
The following command removes the assemblies specified in the file assemblyList.txt from the global assembly cache. 
gacutil /ul assemblyList.txt

What is the difference between a private assembly and a shared assembly?

  
1. Location and visibility:

A private assembly is normally used by a single application, and is stored in the application's directory, or a subdirectory beneath. A shared assembly is normally stored in the global assembly cache, which is a repository of assemblies maintained by the .NET runtime. Shared assemblies are usually libraries of code which many applications will find useful, e.g. the .NET framework classes.

2. Versioning:

The runtime enforces versioning constraints only on shared assemblies, not on private assemblies

3. The assembly which is used only by a single application is called as private assembly. Thus the assembly is private to your application. Suppose that you are creating a general purpose DLL which provides functionality which will be used by variety of applications. Now, instead of each client application having its own copy of DLL you can place the DLL in 'global assembly cache'. Such assemblies are called as shared assembly
MsiAssemblyName  Table Entries for Assemblies.

The information authored into the MsiAssemblyName Table must match the information in the manifest file of the assembly. If the information in the manifest and MsiAssemblyName Table do not match, removal of the application can leave the assembly on the computer.
For Win32 assemblies there must be a row in the MsiAssemblyName Table for each of the following entries in the Name field: type, name, version, language, publicKeyToken and processorArchitecture. The corresponding value for each name can be entered into the Value field. The name-value pairs in MsiAssemblyName Table must match the type, name, version, language, publicKeyToken and processorArchitecture attributes in the manifest of the assembly. 
For private common language runtime assemblies (.NET Frameworkversions 1.0 and 1.1), the MsiAssemblyName Table must include a row for each of the following entries in the Name field: Name, Version, and Culture. The corresponding value for each Name can be entered into the Value field.
For global common language runtime assemblies (.NET Framework versions 1.0 and 1.1), the MsiAssemblyName Table must include a row for each of the following entries in the Name field: Name, Version, Culture, and PublicKeyToken. The corresponding value for each Name can be entered into the Value field.

21 comments:

Shailu said...

SUPER INFORMATION
VERY NICE
KEEP ON POSTING
THANK U BOSS

Shailu said...

Hi

Shailu said...

THANK U VERY MUCH FOR POSTING WITH PICTURES.

john son said...

Thanks for sharing this article.
Software testing training

peterson said...

Your information about CLR is really interesting and innovative. Also I want you to share latest updates about this CLR. Can you update it in your website? Thanks for sharing
Dot net training in Chennai

kovalan Jayamurugan said...

Thanks for your informative article on software testing. LoadRunner is popular automation software testing tool that used to validate a software application by generating actual load. Further, it gives precise information about a software application or environment. Loadrunner Training in Chennai

kovalan Jayamurugan said...

Thanks for sharing informative article on mobile testing. It helped me to understand the future of mobile application development and need of mobile application testing training. Think of joining mobile application testing training in Chennai from reputed IT placement or training academy.

Stephen said...

Testing is the only way to deliver reliable products in the Information Technology market. Articles like this are vital in improvising one's ability as a software testing professional. Thank you so much for sharing this information in here. Keep blogging.

Software testing training in chennai | Software testing course | Software testing training institutes in chennai | Software testing training institute in chennai

for IT the said...

Great Article

Dot Net Training Institutes in Chennai | .net training online | Dot Net Training in Chennai | .Net Training in Chennai | ASP.NET Training



C# Training | ASP.NET Training | ASP.NET MVC Training in Chennai

Dot Net Interview Questions

Nikshitha S said...

The usage of third party storage system for the data storage can be avoided in cloud computing and we can store, access the data through internet.
cloud computing training in chennai | cloud computing courses in chennai

jhansi joe said...

Hi Admin,
your post really made my day good, i have gathered more information from your blog. Thanks for sharing such an informative post.
Regards,
Salesforce Training in Chennai|Salesforce Training|Salesforce Training institutes in Chennai

Nikshitha S said...

Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
Python Training in Chennai | Python Course in Chennai

Priya R said...

Excellent post!!!. The strategy you have posted on this technology helped me to get into the next level and had lot of information in it.
salesforce training in chennai | salesforce training institute in chennai

Nandhini said...

Well Said, you have furnished the right information that will be useful to anyone at all time. Thanks for sharing your Ideas.
PHP Training in Chennai | PHP Course in Chennai

revathi said...

Excellent Post.. I am a regular contributor of your blog. Android Training Institute in Chennai | Android Training in Velachery.

Unknown said...

Your Blog is nice and informative with the impressive content.
Web Designing Training Institute in Chennai | Web Designing Training in Chennai | Web Designing Course in Chennai | No.1 Web Designing Training in Chennai

Evelin Harriet said...

Thanks for your great information!
erp software in chennai | erp solutions in chennai | erp software development company in chennai

Shivani Yuvanjalin said...

Thank you for this valuable information. I have got some important suggestions from it. Get your business to the next level in simple steps.
erp software company in chennai | erp software providers in chennai.

sivanesan said...

Nice blog. Thank you for sharing. The information you shared is very effective for learners I have got some important suggestions from it. erp in chennai.

Brave Technologies said...

Thank you for this valuable information.We provides lowest price of erp Software for our clients.
erp in Chennai

manju said...

Your blog is really very informative and useful for us. Dot Net Training Institute in Chennai | Dot Net Training Institute in Velachery.