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 ".netmodule". 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
- In the project's Properties dialog box, select the Linker folder.
- Click the Advanced property page.
- Change the value of the Turn Off Assembly Generation property to Yes(/NOASSEMBLY).
- 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 "References"). You can change that as follows:
- In the project's Properties dialog box, select the Linker folder.
- Click the General folder.
- Modify the Output File option to
YourModuleName.netmodule.
- Build your project.
back to the top
REFERENCES
For additional information, click the article number below
to view the article in the Microsoft Knowledge Base:
311416 Visual C++ .NET Does Not Create a .Netmodule File by Default When You Use /clr:noAssembly Option
For more information, visit the following Microsoft
Web site: