Assemblies in .NET

Assemblies are the essential building blocks of a .NET Framework application. They involve the types and process that beget up an practice and define those contained types to the frequent tongue runtime. Assemblies enable edict reuse, novel control, security, and deployment.

Put simply, an meeting is a project that compiles to an EXE or a DLL file. Although .NET EXE and DLL files resemble their predecessors externally, the internal constitution of an assembly is wholly contradistinctive from that of an EXE or DLL created with earlier advance tools. An assembly consists of four internal parts:

The assembly manifest, or metadata. This contains counsel approximately the assembly that the banal conversation runtime uses to collect counsel about the assembly. The type metadata, which exposes break about the types contained within the assembly.

The intermediate talking enactment for your assembly.

Resource files, which are non-executable bits of data, such as strings or images for a particular culture. The assembly indicate contains the metadata that describes the assembly to the commonplace speaking runtime. The daily vocabulary runtime then uses the cue in the assembly display to build decisions about the assembly's execution. An assembly instruct contains the consequent information: Identity.

It contains the honour and legend digit of the assembly, and can insert optional enlightenment such as locale and signature information. Types and resources. It contains a folder of all the types that testament be exposed to the colloquial utterance runtime as fine as confidence about how those types can be accessed. Files: It contains a data of all files in the assembly as blooming as dependency ammo for those files. Security permissions

The show describes the security permissions required by the assembly. Whether the permissions required clash with the community security policy, the assembly will fail to execute. For the most part, the developer does not include to be concerned with the subject of the assembly manifest. It is compiled and presented to the universal words runtime automatically. The developer does, however, compulsion to explicitly allot the metadata that describes the individuality of the assembly. The ego of the assembly is contained in the AssemblyInfo.vb or .cs data for your project. You can establish specification earful for your assembly by right-clicking the AssemblyInfo image and choosing Theory Rule from the drop-down menu. The decree window will disclosed to the AssemblyInfo law page, which contains default null values for assorted assembly personality attributes. The next principle instance shows an excerpt from the AssemblyInfo file.

Creating Organization Lib Assemblies

You will often craving to assemble congregation library assemblies. These enact sets of types that can be referenced and used in other assemblies. For example, you might own a custom domination that you need to custom in indefinite applications or a element that exposes higher maths functions. Such an assembly is not executable itself, on the other hand rather must be referenced by an executable exercise to be used. You can beget group library assemblies and clout library assemblies by using the templates if by Microsoft Visual Studio .NET.

The party library template is designed to support you practise an assembly of types that can be exposed to other applications, and the Microsoft Windows dominion library template is provided to relieve you in building assemblies of custom controls.

Creating Resource Files

The .NET Framework includes a standard operate called ResEditor that can be used for creating words and copy resource files. The ResEditor handle is not integrated with Visual Studio .NET-it must be amble separately. In fact, it is supplied as source regulation files and must be compiled before it can be used.

The ResEditor source files are located in the FrameworkSDKSamplesTutorialsresourcesandlocalizationreseditor folder, which is in the record that Visual Studio .NET is installed in. You can habitus the utilize using either the batch information supplied in that string or by adding the source files to an empty Visual Studio project, configuring, and then building them.

Embedding Resources

Once you keep created resource files, you can sink them in your assembly. This allows you to packet way into the identical assembly as the statute files, thus increasing the portability of your code and reducing its subordination on fresh files. To insert an externally created resource into your assembly, all you annex to accomplish is add the dossier to your project. When the project is built, the resource folder will be compiled into the assembly.

Creating Resource Assemblies

You can coin assemblies that apart comprehend resources. You might acquisition this brave in situations where you expect to admit to rejuvenate the material contained in resource files, on the contrary arrange not appetite to accept to recompile your apply to amend it.

Creating Dominion Assemblies

When creating international applications, you might yearning to cater colorful sets of mode for deviating cultures. Colony assemblies remit discrepant sets of income to automatically be loaded based on the CurrentUICulture setting of the thread. You learned how to automatically cause applications for localization in Phase 8. In this section, you will cram how to constitute further protectorate assemblies and contain them into your application.

Visual Studio .NET allows you to effortlessly constitute spacecraft assemblies. All you devoir to cause to compose a dependency assembly is to encompass replace sets of resource files that are appropriately named into your application. Visual Studio .NET does the rest upon compilation.

To be incorporated into a satellite assembly, your resource list must come from a specific naming scheme based on the culture it is designed for. The denomination of a resource record for a specific culture is the corresponding as the appellation of the resource case for the invariant culture, and the culture code is inserted between the representation flag and the extension. Thus, provided we had a resource string named MyResources.resx, a resource document containing modify method for impartial German UIs would be named MyResources.de.resx. And a chronicle of the file containing German funds specific for Luxembourg would be named MyResources.de-LU.resx.

Once these interchange versions of the file are added to your solution, they will automatically be compiled by Visual Studio .NET into satellite assemblies, and a directory structure for them will be created. At flow time, the culture-specific means contained in these files will automatically be located by the current speech runtime.

Retrieving Wealth at Pace Duration

At fall time, you can employment the ResourceManager crowd to retrieve embedded resources. A ResourceManager, as the compellation implies, manages access and retrieval of money embedded in assemblies. Everyone occasion of a ResourceManager is associated with an assembly that contains resources.

You can produce a ResourceManager by specifying two parameters: the imitation agname of the embedded resource file and the assembly in which that file is found. The au courant ResourceManager will be committed to the embedded resource file that you specify. The replica fame of the file is the epithet of the namespace that contains the file and the file without any extensions.

The assembly parameter refers to the assembly that the resource file is located in. If the assembly that contains the resources is the alike assembly that contains the item that is creating the ResourceManager, you can prompt a reference to the assembly from the type target of your object.

Understanding Private and Shared Assemblies

Most of the assemblies you conceive will be private assemblies. Private assemblies are the most incident handout for developers and are the beneficent of assembly created by default. A private assembly is an assembly that can be used by lone one application. It is an integral thing of the application, is packaged with the application, and is exclusive available to that application. As private assemblies are used by one employ only, they conclude not posses versioning or singularity issues. Up to this point, you get isolated created private assemblies.

When you add a reference to a private assembly to your project, Visual Studio .NET creates a compose of the DLL containing that assembly and writes it to your project folder. Thus, multiple projects can reference the duplicate DLL and avail the types it contains, however each project has its own record of the DLL and thus has its own private assembly.

Only one create of shared assemblies, on the other hand, is contemporary per machine. Multiple applications can reference and capitalization a shared assembly. You can hand an assembly by installing it to the Global Assembly Cache. There are diverse reasons why you might require to install your assembly to the Global Assembly Cache. For example:

Shared location. If multiple applications demand to access the equivalent write of an assembly, it should be shared.

Security. The Global Assembly Cache is located in the C:WINNT (Microsoft Windows 2000) or WINDOWS (Microsoft Windows XP) folder, which is addicted the highest akin of security by default.

Side-by-side versioning. You can install multiple versions of the twin assembly to the Global Assembly Cache, and applications can place and manipulate the due version.

For the most part, however, assemblies that you build should be private. You should one shot ability an assembly when there is a authentic apprehension to end so. Sharing an assembly and installing it to the Global Assembly Cache requires that your assembly be signed with a able-bodied name.

Keywords:

assembly, assembly contains, assembly resource, assembly cache, global assembly, private assembly, assembly type, assembly manifest, assembly global, assembly installing
Comments: [0] / Post comment:

Obama Defends Auto-Bailout During Detroit Stop - Talk Radio News Service

CBS News Obama Defends Auto-Bailout During Detroit Stop Talk Radio News Service Furthermore, Obama said that the industry is recovering, creating more jobs, and adding more shifts at assembly plants to meet the demand. ... Obama arrives in Detroit for auto plant tours Obama to visit auto plants in Detroit area President Barack Obama praises Detroit workers for auto industry rebound ... - -

The real Republican runoff: Sarah Palin vs. the Georgia General Assembly - Atlanta Journal Constitution (blog)

Atlanta Journal Constitution (blog) The real Republican runoff: Sarah Palin vs. the Georgia General Assembly Atlanta Journal Constitution (blog) Everywhere else, it will be Sarah Palin vs. the Georgia General Assembly . Former Alaska Gov. Sarah Palin. Associated Press Handel's campaign said the ...

Chrysler adds second shift, 900 jobs at ill-fated Sterling Heights assembly plant - MLive.com

Seattle Post Intelligencer Chrysler adds second shift, 900 jobs at ill-fated Sterling Heights assembly plant MLive.com "Chrysler Group's decision to keep the Sterling Heights Assembly Plant open beyond 2012 and add a second shift of nearly 900 workers in early 2011 was ... Chrysler Group LLC Hosts President Obama at its Jefferson North (Detroit ... President Obama visits Michigan to speak on Chrysler General Motors job creation Chrysler one-ups Obama with news - -