Tutorial by Examples: assembly

Assemblies are the building block of any Common Language Runtime (CLR) application. Every type you define, together with its methods, properties and their bytecode, is compiled and packaged inside an Assembly. using System.Reflection; Assembly assembly = this.GetType().Assembly; Assembl...
using System; using System.Reflection; using System.Reflection.Emit; class DemoAssemblyBuilder { public static void Main() { // An assembly consists of one or more modules, each of which // contains zero or more types. This code creates a single-module // a...
This example shows the usage of the ILGenerator by generating code that makes use of already existing and new created members as well as basic Exception handling. The following code emits a DynamicAssembly that contains an equivalent to this c# code: public static class UnixTimeHelper { priva...
The family of x86 assembly languages represents decades of advances on the original Intel 8086 architecture. In addition to there being several different dialects based on the assembler used, additional processor instructions, registers and other features have been added over the years while still r...
# make this routine available outside this translation unit .globl string_to_integer string_to_integer: # function prologue push %ebp mov %esp, %ebp push %esi # initialize result (%eax) to zero xor %eax, %eax # fetch pointer to the string mov 8(%ebp), %e...
Example of calling an extension method as an extension and as a regular method. public Class MyClass Sub Main() 'Extension called directly on the object. Dim Version = Assembly.GetExecutingAssembly.GetVersionFromAssembly() 'Called as a regular method. ...
This attribute is used to give a name to this particular assembly. [assembly: AssemblyTitle("MyProduct")]
This attribute is used to describe the product that this particular assembly is for. Multiple assemblies can be components of the same product, in which case they can all share the same value for this attribute. [assembly: AssemblyProduct("MyProduct")]
Having a global allows for better DRYness, you need only put values that are different into AssemblyInfo.cs for projects that have variance. This use assumes your product has more than one visual studio project. GlobalAssemblyInfo.cs using System.Reflection; using System.Runtime.InteropServices...
This attribute applies a version to the assembly. [assembly: AssemblyVersion("1.0.*")] The * character is used to auto-increment a portion of the version automatically every time you compile (often used for the "build" number)
Using .NET's rich reflection APIs, you can gain access to an assembly's metadata. For example, you can get this assembly's title attribute with the following code using System.Linq; using System.Reflection; ... Assembly assembly = typeof(this).Assembly; var titleAttribute = assembly.GetCust...
AssemblyConfiguration: The AssemblyConfiguration attribute must have the configuration that was used to build the assembly. Use conditional compilation to properly include different assembly configurations. Use the block similar to the example below. Add as many different configurations as you com...
Often it is useful to be able to load all of the profiles in one or more assemblies into a configuration. AutoMapper provides the method AddProfiles method, which has several overloads that allow profiles to be loaded by passing the Assembly, specifying the assembly name, or specifying a type contai...
Use conditional compilation to ensure that code only compiles for the intended instruction set (such as x86). Otherwise code could become invalid if the program is compiled for another architecture, such as ARM processors. #![feature(asm)] // Any valid x86 code is valid for x86_64 as well. Be ca...
Another way to .Install installers is by using Castle's FromAssembly class. It gives an array of functions to locate installers in the loaded assemblies. For example: //Will locate IInstallers in the current assembly that is calling the method container.Install(FromAssembly.This()); For more d...
Whenever we want our assembly to install in GAC then it is must to have a strong name. For strong naming assembly we have to create a public key. To generate the .snk file. To create a strong name key file Developers command prompt for VS2015 (with administrator Access) At the command prompt...
Step 1: Create an empty project via File -> New Project. Step 2: Right click the project solution and select Build Dependencies->Build Customizations. Step 3: Check the checkbox ".masm". Step 4: Press the button "ok". Step 5: Create your assembly file and type in th...
; IF d0 == 10 GO TO ten, ELSE GO TO other CMP #10,d0 ; compare register contents to immediate value 10 ; instruction affects the zero flag BEQ ten ; branch if zero flag set other: ; do whatever needs to be done for d0 != 10 BRA ...
The Z80 has a specific instruction to implement loop counts: DJNZstanding for "decrement B register and jump if not zero". So, B is the register of choice to implement loops on this processor. FOR...NEXT needs to be implemented "backwards", because the register counts down to zer...
To run ARM assembly code you will need a machine with an ARM processor. If you are on Linux you can use the following commands to compile your program: as -o prog_object.o my_prog_source.s Link to get the executable: ld -o run_prog prog_object.o Run using: ./run_prog If you run echo $? it wil...

Page 1 of 2