How to create .NET modules by using Visual C++ (309805)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2002)
  • Microsoft Visual C++ .NET (2003)
  • Microsoft Visual C++ 2005 Express Edition

This article was previously published under Q309805

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

  1. Run the following command to compile the source:

    cl /c /clr:noAssembly NetModuleTest.cpp

  2. 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 "References"). 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 YourModuleName.netmodule.
  4. 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:

Modification Type:MajorLast Reviewed:1/6/2006
Keywords:kbHOWTOmaster KB309805 kbAudDeveloper