qr code generator asp net c# Lab: Set Assembly Attributes and Display Them at Runtime in C#

Encoding QR Code ISO/IEC18004 in C# Lab: Set Assembly Attributes and Display Them at Runtime

Lab: Set Assembly Attributes and Display Them at Runtime
QR Code JIS X 0510 Generator In Visual C#.NET
Using Barcode creation for .NET Control to generate, create QR Code ISO/IEC18004 image in Visual Studio .NET applications.
www.OnBarcode.com
QR Code Scanner In Visual C#.NET
Using Barcode reader for VS .NET Control to read, scan read, scan image in .NET applications.
www.OnBarcode.com
In this lab, you will set the attributes on an assembly and then display them in the console. If you encounter a problem completing an exercise, the completed projects are available on the companion CD in the Code folder. 1. Create a new console application, and call it AssemblyAttrDemo. 2. Open the assemblyinfo file (AssemblyInfo.cs for C# and AssemblyInfo.vb for Visual Basic). In C#, you will find it in the Properties folder. In Visual Basic, click the Show All Files button and look for it under the My Project folder.
Barcode Encoder In Visual C#
Using Barcode encoder for .NET Control to generate, create barcode image in .NET framework applications.
www.OnBarcode.com
Bar Code Decoder In C#.NET
Using Barcode scanner for .NET framework Control to read, scan read, scan image in VS .NET applications.
www.OnBarcode.com
Lesson 2: Assembly Attributes
Make Denso QR Bar Code In VS .NET
Using Barcode encoder for ASP.NET Control to generate, create QR Code image in ASP.NET applications.
www.OnBarcode.com
Print QR Code In Visual Studio .NET
Using Barcode generator for VS .NET Control to generate, create Quick Response Code image in .NET framework applications.
www.OnBarcode.com
3. Set the AssemblyDescription attribute to This is a demo of the AssemblyDescription attribute . 4. Open the main code file in the new project, and add a using statement (or Imports in Visual Basic) to the System.Reflection namespace. 5. In the startup method of the project, create an instance of the Assembly class and instantiate it with the assembly from the currently executing code. 6. Create a new local variable to hold an instance of the Type class, and assign it the type of the AssemblyDescriptionAttribute class. 7. Call the Assembly instance s GetCustomAttributes method, specifying the Type instance you built in step 6 and false for inheritance. Then store the result in a new local variable that holds an array of objects. 8. If the length of the array of objects is greater than zero, create a new variable to store an AssemblyDescriptionAttribute object and cast the first member of the object array to the new variable. 9. Write out to the console the description that the AssemblyDescriptionAttribute variable holds. Your code might look something like this:
Creating QR Code ISO/IEC18004 In VB.NET
Using Barcode generation for .NET framework Control to generate, create QR Code image in .NET framework applications.
www.OnBarcode.com
Encode Data Matrix ECC200 In Visual C#.NET
Using Barcode creator for .NET framework Control to generate, create Data Matrix image in .NET applications.
www.OnBarcode.com
' VB Imports System.Reflection Class Program Public Shared Sub Main(ByVal args() As String) Dim a As Assembly = Assembly.GetExecutingAssembly Dim attrType As Type = GetType(AssemblyDescriptionAttribute) Dim attrs() As Object = a.GetCustomAttributes(attrType, False) If (attrs.Length > 0) Then Dim desc As AssemblyDescriptionAttribute = _ CType(attrs(0), AssemblyDescriptionAttribute) Console.WriteLine("Description is: {0}", desc.Description) End If End Sub End Class // C# using System.Reflection;
Paint UPC-A Supplement 2 In C#.NET
Using Barcode creation for .NET Control to generate, create UPC-A Supplement 5 image in VS .NET applications.
www.OnBarcode.com
Matrix 2D Barcode Generation In Visual C#.NET
Using Barcode creation for Visual Studio .NET Control to generate, create Matrix 2D Barcode image in Visual Studio .NET applications.
www.OnBarcode.com
14
EAN13 Printer In Visual C#.NET
Using Barcode maker for Visual Studio .NET Control to generate, create EAN-13 image in .NET applications.
www.OnBarcode.com
Code11 Creation In Visual C#
Using Barcode generator for .NET framework Control to generate, create USD - 8 image in VS .NET applications.
www.OnBarcode.com
Reflection
Scanning UPC Code In None
Using Barcode reader for Software Control to read, scan read, scan image in Software applications.
www.OnBarcode.com
Bar Code Creator In Objective-C
Using Barcode printer for iPhone Control to generate, create barcode image in iPhone applications.
www.OnBarcode.com
class Program { static void Main(string[] args) { Assembly a = Assembly.GetExecutingAssembly(); Type attrType = typeof(AssemblyDescriptionAttribute); object[] attrs = a.GetCustomAttributes(attrType, false); if (attrs.Length > 0) { AssemblyDescriptionAttribute desc = (AssemblyDescriptionAttribute)attrs[0]; Console.WriteLine("Description is: {0}", desc.Description); } } }
Read UPC A In Visual C#.NET
Using Barcode reader for VS .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
Bar Code Printer In .NET
Using Barcode generator for Reporting Service Control to generate, create barcode image in Reporting Service applications.
www.OnBarcode.com
10. Build the project, and resolve any errors. Verify that the console application successfully shows the description in the console window.
Data Matrix 2d Barcode Generation In .NET Framework
Using Barcode creator for Reporting Service Control to generate, create Data Matrix image in Reporting Service applications.
www.OnBarcode.com
EAN / UCC - 13 Generator In Visual Studio .NET
Using Barcode creation for Reporting Service Control to generate, create USS-128 image in Reporting Service applications.
www.OnBarcode.com
Lesson Summary
Recognize Bar Code In Visual Studio .NET
Using Barcode scanner for .NET Control to read, scan read, scan image in Visual Studio .NET applications.
www.OnBarcode.com
GS1 - 13 Maker In None
Using Barcode generator for Online Control to generate, create UPC - 13 image in Online applications.
www.OnBarcode.com
To specify assembly metadata, use common assembly attributes. Query an assembly for individual attributes.
Lesson Review
You can use the following questions to test your knowledge of the information in Lesson 2, Assembly Attributes. The questions are also available on the companion CD if you prefer to review them in electronic form.
NOTE Answers
Answers to these questions and explanations of why each answer choice is right or wrong are located in the Answers section at the end of the book.
1. What does using the AssemblyCultureAttribute with a specific culture indicate about an assembly A. The assembly s entry point is meant to be used only on machines that support a specific locale. B. The assembly is a satellite assembly. C. It does not indicate anything; it is merely informative. D. It allows the resources in the assembly to be translated into the specified locale.
Lesson 2: Assembly Attributes
2. What does specifying an asterisk as the revision number part of the version in the AssemblyVersionAttribute (for example, 1.0.0.* ) indicate to the compiler A. Specifying an asterisk here does not indicate anything; asterisks are valid parts of a version number. B. Specifying an asterisk here indicates that this assembly will work with any other assemblies with versions that start with 1.0.0 . C. Specifying an asterisk indicates that the asterisk should be replaced with an autoincrementing number by the compiler. D. Specifying an asterisk here indicates that the asterisk should be replaced with a random number by the compiler.
Copyright © OnBarcode.com . All rights reserved.