You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/build/reference/choosing-the-format-of-netmodule-input-files.md
+11-12Lines changed: 11 additions & 12 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2,32 +2,31 @@
2
2
description: "Learn more about: Choosing the Format of .netmodule Input Files"
3
3
title: "Choosing the Format of .netmodule Input Files"
4
4
ms.date: "11/04/2016"
5
-
ms.assetid: 4653d1bd-300f-4083-86f5-d1a06f44e61c
6
5
---
7
-
# Choosing the Format of .netmodule Input Files
6
+
# Choosing the format of .netmodule input files
8
7
9
-
An MSIL .obj file (compiled with [/clr](clr-common-language-runtime-compilation.md)) can also be used as a .netmodule file. .obj files contain metadata and native symbols. .netmodules only contain metadata.
8
+
You can use an MSIL `.obj` file (compiled with [`/clr`](clr-common-language-runtime-compilation.md)) as a `.netmodule` file. `.obj` files contain metadata and native symbols. `.netmodules` only contain metadata.
10
9
11
-
You can pass an MSIL .obj file to any other Visual Studio compiler via the /addmodule compiler option (but be aware that the .obj file becomes part of the resulting assembly and must be shipped with the assembly). For example, Visual C# and Visual Basic have the /addmodule compiler option.
10
+
Pass an MSIL `.obj` file to any other Visual Studio compiler with the `/addmodule` compiler option. The `.obj` file becomes part of the resulting assembly and must be shipped with the assembly. For example, Visual C# and Visual Basic have the `/addmodule` compiler option.
12
11
13
12
> [!NOTE]
14
-
> In most cases, you will need to pass to the linker the .obj file from the compilation that created the .net module. Passing a .dll or .netmodule MSIL module file to the linker may result in LNK1107.
13
+
> In most cases, you need to pass to the linker the `.obj` file from the compilation that created the .net module. Passing a `.dll` or `.netmodule` MSIL module file to the linker might result in LNK1107.
15
14
16
-
.obj files, along with their associated .h files, which you reference via #include in source, allow C++ applications to consume the native types in the module, whereas in a .netmodule file, only the managed types can be consumed by a C++ application. If you attempt to pass a .obj file to #using, information about native types will not be available; #include the .obj file's .h file instead.
15
+
`.obj` files, along with their associated `.h` files, which you reference via #include in source, allow C++ applications to consume the native types in the module. In a `.netmodule` file, only the managed types can be consumed by a C++ application. If you attempt to pass a `.obj` file to #using, information about native types isn't available. Instead, #include the `.obj` file's `.h` file.
17
16
18
17
Other Visual Studio compilers can only consume managed types from a module.
19
18
20
-
Use the following to determine whether you need to use a .netmodule or a .obj file as module input to the MSVC linker:
19
+
Use the following guidance to determine whether you need to use a `.netmodule` or a `.obj` file as module input to the MSVC linker:
21
20
22
-
- If you are building with a Visual Studio compiler other than Visual C++, produce a .netmodule and use the .netmodule as input to the linker.
21
+
- If you're building with a Visual Studio compiler other than Visual C++, produce a `.netmodule` and use the `.netmodule` as input to the linker.
23
22
24
-
- If you are using the MSVC compiler to produce modules and if the module(s) will be used to build something other than a library, use the .obj files produced by the compiler as module input to the linker; do not use the .netmodule file as input.
23
+
- If you're using the MSVC compiler to produce modules and if the modules are used to build something other than a library, use the `.obj` files produced by the compiler as module input to the linker. Don't use the `.netmodule` file as input.
25
24
26
-
- If your modules will be used to build a native (not a managed) library, use .obj files as module input to the linker and generate a .lib library file.
25
+
- If your modules are used to build a native (not a managed) library, use `.obj` files as module input to the linker and generate a `.lib` library file.
27
26
28
-
- If your modules will be used to build a managed library, and if all module input to the linker will be verifiable (produced with /clr:safe), use .obj files as module input to the linker and generate a .dll (assembly) or .netmodule (module) library file.
27
+
- If your modules are used to build a managed library, and if all module input to the linker is verifiable (produced with `/clr:safe`), use `.obj` files as module input to the linker and generate a `.dll` (assembly) or `.netmodule` (module) library file.
29
28
30
-
- If your modules will be used to build a managed library, and if one or more modules input to the linker will be produced with just /clr, use .obj files as module input to the linker and generate a .dll (assembly). If you want to expose managed types from the library and if you also want C++ applications to consume the native types in the library, your library will consist of the .obj files for the libraries component modules (you will also want to ship the .h files for each module, so they can be referenced with #include from source code).
29
+
- If your modules are used to build a managed library, and if one or more modules input to the linker are produced with just `/clr`, use `.obj` files as module input to the linker and generate a `.dll` (assembly). If you want to expose managed types from the library and if you also want C++ applications to consume the native types in the library, your library consists of the `.obj` files for the libraries component modules. You also want to ship the `.h` files for each module, so they can be referenced with #include from source code.
Specifies that an assembly manifest should not be inserted into the output file.
10
+
Specifies that the compiler shouldn't insert an assembly manifest into the output file.
12
11
13
12
## Syntax
14
13
@@ -18,27 +17,27 @@ Specifies that an assembly manifest should not be inserted into the output file.
18
17
19
18
## Remarks
20
19
21
-
By default, **/LN** is not in effect (an assembly manifest is inserted into the output file).
20
+
By default, `/LN` isn't in effect, and the compiler inserts an assembly manifest into the output file.
22
21
23
-
When **/LN** is used, one of the [/clr (Common Language Runtime Compilation)](clr-common-language-runtime-compilation.md) options must also be used.
22
+
When you use `/LN`, you must also use one of the [/clr (Common Language Runtime Compilation)](clr-common-language-runtime-compilation.md) options.
24
23
25
-
A managed program that does not have an assembly metadata in the manifest is called a module. If you compile with [/c (Compile Without Linking)](c-compile-without-linking.md) and **/LN**, specify [/NOASSEMBLY (Create a MSIL Module)](noassembly-create-a-msil-module.md) in the linker phase to create the output file.
24
+
A managed program that doesn't have assembly metadata in the manifest is called a module. If you compile with [/c (Compile Without Linking)](c-compile-without-linking.md) and `/LN`, specify [`/NOASSEMBLY `(Create a MSIL Module)](noassembly-create-a-msil-module.md) in the linker phase to create the output file.
26
25
27
-
You may want to create modules if you want to take a component-based approach to building assemblies. That is, you can author types and compile them into modules. Then, you can generate an assembly from one or more modules. For more information on creating assemblies from modules, see [.netmodule Files as Linker Input](netmodule-files-as-linker-input.md) or [Al.exe (Assembly Linker)](/dotnet/framework/tools/al-exe-assembly-linker).
26
+
Create modules if you want to take a component-based approach to building assemblies. You can author types and compile them into modules. Then, you can generate an assembly from one or more modules. For more information on creating assemblies from modules, see [`.netmodule` Files as Linker Input](netmodule-files-as-linker-input.md) or [`Al.exe `(Assembly Linker)](/dotnet/framework/tools/al-exe-assembly-linker).
28
27
29
-
The default file extension for a module is .netmodule.
28
+
The default file extension for a module is `.netmodule`.
30
29
31
-
In releases before Visual Studio 2005, a module was created with **/clr:noAssembly**.
30
+
In releases before Visual Studio 2005, you created a module with `/clr:noAssembly`.
32
31
33
-
The MSVC linker accepts .netmodule files as input and the output file produced by the linker will be an assembly or .netmodule with no run-time dependence on any of the .netmodules that were input to the linker. For more information, see [.netmodule Files as Linker Input](netmodule-files-as-linker-input.md).
32
+
The MSVC linker accepts `.netmodule` files as input. The output file produced by the linker is an assembly or `.netmodule` with no run-time dependence on any of the `.netmodule`s that you input to the linker. For more information, see [`.netmodule `Files as Linker Input](netmodule-files-as-linker-input.md).
34
33
35
34
### To set this compiler option in the Visual Studio development environment
36
35
37
-
- Specify [/NOASSEMBLY (Create a MSIL Module)](noassembly-create-a-msil-module.md) in the linker phase to create the output file.
36
+
- Specify [`/NOASSEMBLY` (Create a MSIL Module)](noassembly-create-a-msil-module.md) in the linker phase to create the output file.
38
37
39
38
### To set this compiler option programmatically
40
39
41
-
-This compiler option cannot be changed programmatically.
40
+
-You can't change this compiler option programmatically.
The **safe_cast** operation returns the specified expression as the specified type, if successful; otherwise, throws `InvalidCastException`.
11
+
The **`safe_cast`** operation returns the specified expression as the specified type. If the operation isn't successful, it throws an`InvalidCastException`.
13
12
14
13
## All Runtimes
15
14
@@ -23,7 +22,7 @@ The **safe_cast** operation returns the specified expression as the specified ty
23
22
24
23
## Windows Runtime
25
24
26
-
**safe_cast**allows you to change the type of a specified expression. In situations where you fully expect a variable or parameter to be convertible to a certain type, you can use **safe_cast** without a **try-catch** block to detect programming errors during development. For more information, see [Casting (C++/CX)](../cppcx/casting-c-cx.md).
25
+
Use **`safe_cast`** to change the type of a specified expression. If you expect a variable or parameter to be convertible to a certain type, use **`safe_cast`** without a **try-catch** block to detect programming errors during development. For more information, see [Casting (C++/CX)](../cppcx/casting-c-cx.md).
27
26
28
27
### Syntax
29
28
@@ -41,15 +40,15 @@ An expression that evaluates to a handle to a reference or value type, a value t
41
40
42
41
### Remarks
43
42
44
-
**safe_cast** throws `InvalidCastException` if it cannot convert *expression* to the type specified by *type-id*. To catch `InvalidCastException`, specify the [/EH (Exception Handling Model)](../build/reference/eh-exception-handling-model.md) compiler option, and use a **try/catch** statement.
43
+
**`safe_cast`** throws `InvalidCastException` if it can't convert *expression* to the type specified by *type-id*. To catch `InvalidCastException`, specify the [/EH (Exception Handling Model)](../build/reference/eh-exception-handling-model.md) compiler option, and use a **try/catch** statement.
45
44
46
45
### Requirements
47
46
48
47
Compiler option: `/ZW`
49
48
50
49
### Examples
51
50
52
-
The following code example demonstrates how to use **safe_cast** with the Windows Runtime.
51
+
The following code example demonstrates how to use **`safe_cast`** with the Windows Runtime.
A handle to a reference or value type, a value type, or a tracking reference to a reference or value type.
98
97
99
-
*expression*<br/>
98
+
*`expression`*
100
99
An expression that evaluates to a handle to a reference or value type, a value type, or a tracking reference to a reference or value type.
101
100
102
101
### Remarks
103
102
104
103
The expression `safe_cast<`*type-id*`>(`*expression*`)` converts the operand *expression* to an object of type *type-id*.
105
104
106
-
The compiler will accept a [static_cast](../cpp/static-cast-operator.md) in most places that it will accept a **safe_cast**. However, **safe_cast**is guaranteed to produce verifiable MSIL, whereas a **`static_cast`**could produce unverifiable MSIL. See [Pure and Verifiable Code (C++/CLI)](../dotnet/pure-and-verifiable-code-cpp-cli.md) and [Peverify.exe (PEVerify Tool)](/dotnet/framework/tools/peverify-exe-peverify-tool) for more information on verifiable code.
105
+
The compiler accepts a [`static_cast`](../cpp/static-cast-operator.md) in most places that it accepts a **`safe_cast`**. However, **`safe_cast`**always produces verifiable MSIL, whereas a **`static_cast`**might produce unverifiable MSIL. For more information on verifiable code, see [Pure and Verifiable Code (C++/CLI)](../dotnet/pure-and-verifiable-code-cpp-cli.md) and [`Peverify.exe` (PEVerify Tool)](/dotnet/framework/tools/peverify-exe-peverify-tool).
107
106
108
-
Like **`static_cast`**, **safe_cast** invokes user-defined conversions.
107
+
Like **`static_cast`**, **`safe_cast`** invokes user-defined conversions.
109
108
110
109
For more information about casts, see [Casting Operators](../cpp/casting-operators.md).
111
110
112
-
**safe_cast**does not apply a **`const_cast`** (cast away **`const`**).
111
+
**`safe_cast`**doesn't apply a **`const_cast`** (cast away **`const`**).
113
112
114
-
**safe_cast** is in the cli namespace. See [Platform, default, and cli Namespaces](platform-default-and-cli-namespaces-cpp-component-extensions.md) for more information.
113
+
**`safe_cast`** is in the cli namespace. For more information, see [Platform, default, and cli Namespaces](platform-default-and-cli-namespaces-cpp-component-extensions.md).
115
114
116
-
For more information on **safe_cast**, see:
115
+
For more information on **`safe_cast`**, see:
117
116
118
117
-[C-Style Casts with /clr (C++/CLI)](c-style-casts-with-clr-cpp-cli.md)
119
-
120
118
-[How to: Use safe_cast in C++/CLI](../dotnet/how-to-use-safe-cast-in-cpp-cli.md)
121
119
122
120
### Requirements
@@ -125,7 +123,7 @@ Compiler option: `/clr`
125
123
126
124
### Examples
127
125
128
-
One example of where the compiler will not accept a **`static_cast`** but will accept a **safe_cast** is for casts between unrelated interface types. With **safe_cast**, the compiler will not issue a conversion error and will perform a check at runtime to see if the cast is possible
126
+
One example of where the compiler doesn't accept a **`static_cast`** but accepts a **`safe_cast`** is for casts between unrelated interface types. With **`safe_cast`**, the compiler doesn't issue a conversion error and performs a check at runtime to see if the cast is possible.
0 commit comments