The topic in this part is listed below. The code snippets if any are based on the new C++ .NET syntaxes.
AssemblyInfo.cpp contains definitions of the standard metadata items that you can modify as shown below.
|
And stdafx.cpp is shown below.
// stdafx.cpp : source file that includes just the standard includes
// Meta1.pch will be the pre-compiled header
// stdafx.obj will contain the pre-compiled type information
#include "stdafx.h"
2. Open AssemblyInfo.cpp. Find the following part.
[assembly:AssemblyTitleAttribute("Meta1")];
[assembly:AssemblyDescriptionAttribute("")];
[assembly:AssemblyConfigurationAttribute("")];
[assembly:AssemblyCompanyAttribute("testing")];
[assembly:AssemblyProductAttribute("Meta1")];
[assembly:AssemblyCopyrightAttribute("Copyright (c) testing 2007")];
[assembly:AssemblyTrademarkAttribute("")];
[assembly:AssemblyCultureAttribute("")];
Metadata is added to C++ code by enclosing declarations in square brackets ([]). The assembly: part at the start means that this is an attribute that applies to an assembly, as opposed to a type within an assembly. There’s a set of standard attributes that you can use to change the metadata compiled into an assembly, and most of them are listed in AssemblyInfo.cpp.
3. Edit the AssemblyCompanyAttribute line to contain some suitable name, like this:
[assembly:AssemblyCompanyAttribute("My Acme Company, Inc.")];
Figure 3
4. Now build the project, which automatically creates the assembly for you. If you run it, it is a classic “Hello World” example.
Figure 4
5. How can you be sure that the metadata in the assembly reflects your change? One way to find out is to use ILDASM. ILDASM is part of the .NET SDK. For Visual C++ .Net 2003, it is located in the \Program Files\Microsoft Visual Studio .NET 2003\SDK\v1.1\Bin directory. You can either start it from there or open a Microsoft Visual Studio .NET Command Prompt using the Programs → Microsoft Visual Studio .NET 2003 → Visual Studio .NET Tools → Visual Studio .NET 2003 Command Prompt entry on the Start menu.
Figure 5
The following image is for Visual C++ Express Edition 2005.
Figure 6
6. A console window will open that has the path set to include all the Visual Studio .NET and .NET SDK directories, so you can simply type ildasm to start the program. Type the executable, ildasm.
Figure 7
Figure 8
![]() |
Figure 9
7. When the ILDASM window opens, use the File menu to browse for the Meta1.exe executable and open it. You should see something like the following figure.
Figure 10
Figure 11
8. Double-click MANIFEST, which will open a separate window displaying the assembly metadata.
Figure 12
Scroll down until you find the AssemblyCompanyAttribute line, which should read something like this:
.assembly Meta1
{
.custom instance void [mscorlib]System.Reflection.AssemblyDelaySignAttribute::.ctor(bool) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyTitleAttribute::.ctor(string) = ( 01 00 00 00 00 )
.custom instance void [mscorlib]System.Reflection.AssemblyCompanyAttribute::.ctor(string) = ( 01 00 15 4D 79 20 41 63 6D 65 20 43 6F 6D 70 61 // ...My Acme Compa
6E 79 2C 20 49 6E 63 2E 00 00 ) // ny, Inc...
.custom instance void [mscorlib]System.Reflection.AssemblyDescriptionAttribute::.ctor(string) = ( 01 00 00 00 00 )
Although the contents are given in hex, you can see that the metadata does reflect the change you made to the project.