Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

MethodImplAttributes Enumeration

Specifies flags for the attributes of a method implementation.

Namespace:  System.Reflection
Assemblies:   System.Reflection.Primitives (in System.Reflection.Primitives.dll)
  mscorlib (in mscorlib.dll)

Public Enumeration MethodImplAttributes

Member nameDescription
AggressiveInliningSpecifies that the method should be inlined wherever possible.
Supported by the XNA FrameworkCodeTypeMaskSpecifies flags about code type.
Supported by the XNA FrameworkForwardRefSpecifies that the method is not defined.
Supported by the XNA FrameworkILSpecifies that the method implementation is in Microsoft intermediate language (MSIL).
Supported by the XNA FrameworkInternalCallSpecifies an internal call.
Supported by the XNA FrameworkManagedSpecifies that the method is implemented in managed code.
Supported by the XNA FrameworkManagedMaskSpecifies whether the method is implemented in managed or unmanaged code.
Supported by the XNA FrameworkMaxMethodImplValSpecifies a range check value.
Supported by the XNA FrameworkNativeSpecifies that the method implementation is native.
Supported by the XNA FrameworkNoInliningSpecifies that the method cannot be inlined.
NoOptimizationSpecifies that the method is not optimized by the just-in-time (JIT) compiler or by native code generation (see Ngen.exe) when debugging possible code generation problems.
Supported by the XNA FrameworkOPTILSpecifies that the method implementation is in Optimized Intermediate Language (OPTIL).
Supported by the XNA FrameworkPreserveSigSpecifies that the method signature is exported exactly as declared.
Supported by the XNA FrameworkRuntimeSpecifies that the method implementation is provided by the runtime.
Supported by the XNA FrameworkSynchronizedSpecifies that the method is single-threaded through the body. Static methods (Shared in Visual Basic) lock on the type, whereas instance methods lock on the instance. You can also use the C# lock statement or the Visual Basic SyncLock statement for this purpose.
Supported by the XNA FrameworkUnmanagedSpecifies that the method is implemented in unmanaged code.

The attributes are combined using the bitwise OR operation as follows:

Code implementation masks:

  • CodeTypeMask

  • IL

  • Native


  • Runtime

Managed masks:

  • ManagedMask

  • Unmanaged

  • Managed

Implementation information and interop masks:

  • ForwardRef

  • PreserveSig

  • InternalCall

  • Synchronized

  • NoInlining

  • NoOptimization

  • MaxMethodImplVal


Locking on the instance or on the type, as with the Synchronized flag, is not recommended for public types, because code other than your own can take locks on public types and instances. This might cause deadlocks or other synchronization problems.

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

XNA Framework

Supported in: 3.0, 2.0, 1.0

.NET for Windows Phone apps

Supported in: Windows Phone 8.1, Windows Phone Silverlight 8.1, Windows Phone Silverlight 8
© 2015 Microsoft