Microsoft KB Archive/309805

= How to create .NET modules by using Visual C++ =

Article ID: 309805

Article Last Modified on 4/4/2007

-

APPLIES TO


 * Microsoft Visual C++ .NET 2002 Standard Edition
 * Microsoft Visual C++ .NET 2003 Standard Edition
 * Microsoft Visual C++ 2005 Express Edition

-



This article was previously published under Q309805



IN THIS TASK
SUMMARY
 * Using the Command Line
 * Using the Visual C++ .NET IDE or the Visual C++ 2005 IDE

REFERENCES



SUMMARY
A managed program that does not have assembly metadata in the manifest is called a module. By default, the file extension of a module that is produced by the compiler is &quot;.netmodule&quot;. You can only use the command /clr:noAssembly when a dynamic link library (DLL) is the output file of the compilation. If you compile with /c and /clr:noAssembly, specify the /NOASSEMBLY option in the linker phase to create a module.

There are two ways to use Managed C++ to create .NET modules. You can use the Microsoft Visual Studio .NET integrated development environment (IDE) or the Visual Studio 2005 IDE, or you can use the command line compiler/linker. The following section shows how to use both alternatives. For both you must have a Managed C++ source file called NetModuleTest.cpp.

back to the top

Using the Command Line
 Run the following command to compile the source:

cl /c /clr:noAssembly NetModuleTest.cpp

 Run the following command to link it:

link /NOASSEMBLY /DLL /NOENTRY NetModuleTest.obj



This generates NetModuleTest.obj and NetModuleTest.netmodule.

back to the top

Using the Visual C++ .NET IDE or the Visual C++ 2005 IDE

 * 1) In the project's Properties dialog box, select the Linker folder.
 * 2) Click the Advanced property page.
 * 3) Change the value of the Turn Off Assembly Generation property to Yes(/NOASSEMBLY).
 * 4) Build your project.

When you use the command line, the file extension for the output module that is generated by default is .netmodule. However, the extension for the IDE-generated module by default is .dll, which is due to a bug (see &quot;References&quot;). You can change that as follows:
 * 1) In the project's Properties dialog box, select the Linker folder.
 * 2) Click the General folder.
 * 3) Modify the Output File option to  .netmodule.
 * 4) Build your project.

back to the top

