DA0012: Significant amount of Reflection

Rule Id

DA0012

Category

.NET Framework Usage

Profiling methods

Sampling

Message

You may be using Reflection excessively. It is an expensive operation.

Rule type

Warning

Calls to the System.Reflection methods such as InvokeMember and GetMember or to Type methods such as MemberInvoke are a significant proportion of the profiling data. When possible, consider replacing these methods with early binding to the methods of dependent assemblies.

Reflection is a flexible facility of the .NET Framework that can be used to perform late binding of your application to a dependent run-time Assembly or to create and dynamically execute new types during run-time. However, these techniques can decrease performance if they are used frequently or called in tight loops.

For more information, see the Reflection and Late Binding section of Chapter 5 — Improving Managed Code Performance in the Improving .NET Application Performance and Scalability volume of the Microsoft Patterns and Practices library on MSDN.

Double-click the message in the Errors List window to navigate to the Function Details View of the profiling data. Examine the calling functions of the System.Type or System.Reflection method to find the sections of the program that make the most frequent use of .NET Reflection APIs. Avoid using methods that return metadata. When the performance of your application is critical, you might need to avoid using late binding and creating types dynamically at run-time.

Community Additions

ADD
Show: