|  | 
|  | 1 | +--- | 
|  | 2 | +title: Resolve errors related to dynamic binding and the dynamic type | 
|  | 3 | +description: These errors indicate an incorrect use of the `dynamic` type or an expression with runtime (or dynamic) binding. Learn about the errors and how to fix them. | 
|  | 4 | +f1_keywords: | 
|  | 5 | +  - "CS1962" | 
|  | 6 | +  - "CS1964" | 
|  | 7 | +  - "CS1965" | 
|  | 8 | +  - "CS1966" | 
|  | 9 | +  - "CS1967" | 
|  | 10 | +  - "CS1968" | 
|  | 11 | +  - "CS1969" | 
|  | 12 | +  - "CS1970" | 
|  | 13 | +  - "CS1971" | 
|  | 14 | +  - "CS1972" | 
|  | 15 | +  - "CS1973" | 
|  | 16 | +  - "CS1974" | 
|  | 17 | +  - "CS1975" | 
|  | 18 | +  - "CS1976" | 
|  | 19 | +  - "CS1977" | 
|  | 20 | +  - "CS1978" | 
|  | 21 | +  - "CS1979" | 
|  | 22 | +  - "CS1980" | 
|  | 23 | +  - "CS1981" | 
|  | 24 | +  - "CS7083" | 
|  | 25 | +  - "CS8133" | 
|  | 26 | +  - "CS8364" | 
|  | 27 | +  - "CS8416" | 
|  | 28 | +  - "CS9230" | 
|  | 29 | +helpviewer_keywords: | 
|  | 30 | +  - "CS1962" | 
|  | 31 | +  - "CS1964" | 
|  | 32 | +  - "CS1965" | 
|  | 33 | +  - "CS1966" | 
|  | 34 | +  - "CS1967" | 
|  | 35 | +  - "CS1968" | 
|  | 36 | +  - "CS1969" | 
|  | 37 | +  - "CS1970" | 
|  | 38 | +  - "CS1971" | 
|  | 39 | +  - "CS1972" | 
|  | 40 | +  - "CS1973" | 
|  | 41 | +  - "CS1974" | 
|  | 42 | +  - "CS1975" | 
|  | 43 | +  - "CS1976" | 
|  | 44 | +  - "CS1977" | 
|  | 45 | +  - "CS1978" | 
|  | 46 | +  - "CS1979" | 
|  | 47 | +  - "CS1980" | 
|  | 48 | +  - "CS1981" | 
|  | 49 | +  - "CS7083" | 
|  | 50 | +  - "CS8133" | 
|  | 51 | +  - "CS8364" | 
|  | 52 | +  - "CS8416" | 
|  | 53 | +  - "CS9230" | 
|  | 54 | +ms.date: 10/23/2025 | 
|  | 55 | +ai-usage: ai-assisted | 
|  | 56 | +--- | 
|  | 57 | +# Resolve warnings related to the dynamic type and dynamic binding | 
|  | 58 | + | 
|  | 59 | +This article covers the following compiler errors: | 
|  | 60 | + | 
|  | 61 | +<!-- The text in this list generates issues for Acrolinx, because they don't use contractions. | 
|  | 62 | +That's be design. The text closely matches the text of the compiler error / warning for SEO purposes. | 
|  | 63 | + --> | 
|  | 64 | +- [**CS1962**](#using-dynamic-in-type-declarations-and-constraints): *The `typeof` operator cannot be used on the `dynamic` type.* | 
|  | 65 | +- [**CS1964**](#dynamic-operation-restrictions): *Cannot apply dynamic conversion to an expression.* | 
|  | 66 | +- [**CS1965**](#using-dynamic-in-type-declarations-and-constraints): *Cannot derive from the `dynamic` type.* | 
|  | 67 | +- [**CS1966**](#using-dynamic-in-type-declarations-and-constraints): *Cannot derive from a constructed dynamic type.* | 
|  | 68 | +- [**CS1967**](#using-dynamic-in-type-declarations-and-constraints): *Cannot use the `dynamic` type as a type constraint.* | 
|  | 69 | +- [**CS1968**](#using-dynamic-in-type-declarations-and-constraints): *Cannot use a constructed dynamic type as a type constraint.* | 
|  | 70 | +- [**CS1969**](#missing-runtime-support-for-dynamic): *One or more types required to compile a dynamic expression cannot be found.* | 
|  | 71 | +- [**CS1970**](#using-dynamic-in-type-declarations-and-constraints): *Do not use '`System.Runtime.CompilerServices.DynamicAttribute`'. Use the '`dynamic`' keyword instead.* | 
|  | 72 | +- [**CS1971**](#dynamic-operation-restrictions): *The call to member needs to be dynamically dispatched, but cannot be because it is part of a base access expression. Consider casting the dynamic arguments or eliminating the base access.* | 
|  | 73 | +- [**CS1972**](#dynamic-operation-restrictions): *The indexer access needs to be dynamically dispatched, but cannot be because it is part of a base access expression. Consider casting the dynamic arguments or eliminating the base access.* | 
|  | 74 | +- [**CS1973**](#dynamic-operation-restrictions): *The dynamic argument type does not match the target parameter type for extension method.* | 
|  | 75 | +- [**CS1974**](#dynamic-dispatch-warnings): *Dynamic dispatch to a conditional method will fail at runtime.* | 
|  | 76 | +- [**CS1975**](#dynamic-operation-restrictions): *The constructor call needs to be dynamically dispatched, but cannot be because it is part of a constructor initializer. Consider casting the dynamic arguments.* | 
|  | 77 | +- [**CS1976**](#dynamic-operation-restrictions): *Cannot use a method group as an argument to a dynamically dispatched operation.* | 
|  | 78 | +- [**CS1977**](#dynamic-operation-restrictions): *Cannot use a lambda expression as an argument to a dynamically dispatched operation.* | 
|  | 79 | +- [**CS1978**](#dynamic-operation-restrictions): *Cannot use an expression as an argument to a dynamically dispatched operation.* | 
|  | 80 | +- [**CS1979**](#dynamic-operation-restrictions): *Query expressions with a source or join sequence of type dynamic are not allowed.* | 
|  | 81 | +- [**CS1980**](#missing-runtime-support-for-dynamic): *Cannot define a class or member that uses 'dynamic' because the compiler required type is missing.* | 
|  | 82 | +- [**CS1981**](#dynamic-dispatch-warnings): *The '`is dynamic`' pattern is misleading. Use '`is object`' instead.* | 
|  | 83 | +- [**CS7083**](#missing-runtime-support-for-dynamic): *Expression must be implicitly convertible to '`System.Object`', or the type '`dynamic`' is not available.* | 
|  | 84 | +- [**CS8133**](#dynamic-operation-restrictions): *Cannot deconstruct dynamic objects.* | 
|  | 85 | +- [**CS8364**](#dynamic-operation-restrictions): *An argument to '`nameof`' cannot use any dynamic operation.* | 
|  | 86 | +- [**CS8416**](#dynamic-operation-restrictions): *The async modifier cannot be used in the expression of a dynamic attribute.* | 
|  | 87 | +- [**CS9230**](#dynamic-operation-restrictions): *Cannot perform a dynamic invocation on an expression with type.* | 
|  | 88 | + | 
|  | 89 | +## Using `dynamic` in type declarations and constraints | 
|  | 90 | + | 
|  | 91 | +- **CS1962**: *The typeof operator cannot be used on the `dynamic` type.* | 
|  | 92 | +- **CS1965**: *Cannot derive from the `dynamic` type.* | 
|  | 93 | +- **CS1966**: *Cannot derive from a constructed dynamic type.* | 
|  | 94 | +- **CS1967**: *Cannot use the `dynamic` type as a type constraint.* | 
|  | 95 | +- **CS1968**: *Cannot use a constructed dynamic type as a type constraint.* | 
|  | 96 | +- **CS1970**: *Do not use '`System.Runtime.CompilerServices.DynamicAttribute`'. Use the '`dynamic`' keyword instead.* | 
|  | 97 | + | 
|  | 98 | +The [`dynamic` type](../builtin-types/reference-types.md#the-dynamic-type) provides late binding for operations at runtime. Use concrete types in contexts where the compiler needs type information at compile time, such as type declarations, constraints, inheritance, or reflection operations: | 
|  | 99 | + | 
|  | 100 | +- Use concrete types for reflection operations.  Use specific types instead of `dynamic` with the `typeof` operator (CS1962) | 
|  | 101 | +- Use concrete types for inheritance. Specify a concrete base class instead of `dynamic` (CS1965, CS1966): | 
|  | 102 | +- Use concrete type constraints. Specify concrete type constraints on generic parameters instead of `dynamic` (CS1967, CS1968): | 
|  | 103 | +- Use the `dynamic` keyword for variables. Always use the `dynamic` keyword to declare dynamic variables. Don't apply the `DynamicAttribute` directly (CS1970): | 
|  | 104 | + | 
|  | 105 | +For more information about the `dynamic` type and its proper usage, see [Using type dynamic](../../advanced-topics/interop/using-type-dynamic.md). | 
|  | 106 | + | 
|  | 107 | +## Dynamic operation restrictions | 
|  | 108 | + | 
|  | 109 | +- **CS1964**: *Cannot apply dynamic conversion to an expression.* | 
|  | 110 | +- **CS1971**: *The call to member needs to be dynamically dispatched, but cannot be because it is part of a base access expression. Consider casting the dynamic arguments or eliminating the base access.* | 
|  | 111 | +- **CS1972**: *The indexer access needs to be dynamically dispatched, but cannot be because it is part of a base access expression. Consider casting the dynamic arguments or eliminating the base access.* | 
|  | 112 | +- **CS1973**: *The dynamic argument type does not match the target parameter type for extension method.* | 
|  | 113 | +- **CS1975**: *The constructor call needs to be dynamically dispatched, but cannot be because it is part of a constructor initializer. Consider casting the dynamic arguments.* | 
|  | 114 | +- **CS1976**: *Cannot use a method group as an argument to a dynamically dispatched operation.* | 
|  | 115 | +- **CS1977**: *Cannot use a lambda expression as an argument to a dynamically dispatched operation.* | 
|  | 116 | +- **CS1978**: *Cannot use an expression as an argument to a dynamically dispatched operation.* | 
|  | 117 | +- **CS1979**: *Query expressions with a source or join sequence of type dynamic are not allowed.* | 
|  | 118 | +- **CS8133**: *Cannot deconstruct dynamic objects.* | 
|  | 119 | +- **CS8364**: *An argument to '`nameof`' cannot use any dynamic operation.* | 
|  | 120 | +- **CS8416**: *The async modifier cannot be used in the expression of a dynamic attribute.* | 
|  | 121 | +- **CS9230**: *Cannot perform a dynamic invocation on an expression with type.* | 
|  | 122 | + | 
|  | 123 | +While [dynamic binding](../operators/member-access-operators.md#member-access-expression-) provides flexibility at runtime, cast dynamic values to specific types when you need compile-time type information for certain operations. | 
|  | 124 | + | 
|  | 125 | +- **Cast dynamic arguments before calling base members:** Cast dynamic arguments to their specific types before calling base members, indexers, or constructors (CS1971, CS1972, CS1975): | 
|  | 126 | + | 
|  | 127 | +  ```csharp | 
|  | 128 | +  class Base | 
|  | 129 | +  { | 
|  | 130 | +      public virtual void Method(object obj) { } | 
|  | 131 | +      public virtual int this[int index] => 0; | 
|  | 132 | +      public Base(int value) { } | 
|  | 133 | +  } | 
|  | 134 | + | 
|  | 135 | +  class Derived : Base | 
|  | 136 | +  { | 
|  | 137 | +      public Derived(dynamic value) : base((int)value) { }  // Cast before calling base constructor | 
|  | 138 | +       | 
|  | 139 | +      public override void Method(object obj) | 
|  | 140 | +      { | 
|  | 141 | +          dynamic d = obj; | 
|  | 142 | +          base.Method((object)d);  // Cast before calling base method | 
|  | 143 | +      } | 
|  | 144 | +       | 
|  | 145 | +      public override int this[int index] | 
|  | 146 | +      { | 
|  | 147 | +          get | 
|  | 148 | +          { | 
|  | 149 | +              dynamic d = index; | 
|  | 150 | +              return base[(int)d];  // Cast before accessing base indexer | 
|  | 151 | +          } | 
|  | 152 | +      } | 
|  | 153 | +  } | 
|  | 154 | +  ``` | 
|  | 155 | + | 
|  | 156 | +- **Cast to specific types before passing delegates or lambdas:** Cast the dynamic object to its concrete type before passing method groups, lambda expressions, or delegates (CS1976, CS1977, CS1978): | 
|  | 157 | + | 
|  | 158 | +  ```csharp | 
|  | 159 | +  dynamic d = GetDynamicObject(); | 
|  | 160 | + | 
|  | 161 | +  // Avoid: | 
|  | 162 | +  d.ProcessData(Console.WriteLine);  // CS1976 | 
|  | 163 | +  d.ProcessData(x => x * 2);         // CS1977 | 
|  | 164 | +
 | 
|  | 165 | +  // Recommended: | 
|  | 166 | +  ((IProcessor)d).ProcessData(Console.WriteLine);  // Cast first | 
|  | 167 | +  ((IProcessor)d).ProcessData(x => x * 2);         // Cast first | 
|  | 168 | +  ``` | 
|  | 169 | + | 
|  | 170 | +- **Use concrete types for LINQ queries:** Use a concrete type instead of `dynamic` for LINQ query sources and join sequences (CS1979): | 
|  | 171 | + | 
|  | 172 | +  ```csharp | 
|  | 173 | +  dynamic data = GetData(); | 
|  | 174 | + | 
|  | 175 | +  // Avoid: | 
|  | 176 | +  var query = from item in data  // CS1979 | 
|  | 177 | +              select item; | 
|  | 178 | + | 
|  | 179 | +  // Recommended: | 
|  | 180 | +  IEnumerable<MyType> typedData = data; | 
|  | 181 | +  var query = from item in typedData | 
|  | 182 | +              select item; | 
|  | 183 | +  ``` | 
|  | 184 | + | 
|  | 185 | +- **Access tuple elements individually:** Access tuple elements individually instead of using deconstruction with dynamic tuples (CS8133): | 
|  | 186 | + | 
|  | 187 | +  ```csharp | 
|  | 188 | +  dynamic tuple = (1, 2); | 
|  | 189 | + | 
|  | 190 | +  // Avoid: | 
|  | 191 | +  var (a, b) = tuple;  // CS8133 | 
|  | 192 | +
 | 
|  | 193 | +  // Recommended: | 
|  | 194 | +  var a = tuple.Item1; | 
|  | 195 | +  var b = tuple.Item2; | 
|  | 196 | +  ``` | 
|  | 197 | + | 
|  | 198 | +- **Use compile-time expressions for operations requiring type information:** Use concrete types for operations that need compile-time type information (CS1964, CS1973, CS8364, CS8416, CS9230): | 
|  | 199 | + | 
|  | 200 | +  ```csharp | 
|  | 201 | +  dynamic value = GetValue(); | 
|  | 202 | + | 
|  | 203 | +  // Avoid: | 
|  | 204 | +  var name = nameof(value.Property);  // CS8364 | 
|  | 205 | +
 | 
|  | 206 | +  // Recommended: | 
|  | 207 | +  MyType typedValue = value; | 
|  | 208 | +  var name = nameof(typedValue.Property);  // Use concrete type | 
|  | 209 | +  ``` | 
|  | 210 | + | 
|  | 211 | +For more information about dynamic binding and its limitations, see [Using type dynamic](../../advanced-topics/interop/using-type-dynamic.md). | 
|  | 212 | + | 
|  | 213 | +## Missing runtime support for dynamic | 
|  | 214 | + | 
|  | 215 | +- **CS1969**: *One or more types required to compile a dynamic expression cannot be found. Are you missing a reference to 'Microsoft.CSharp.dll'?* | 
|  | 216 | +- **CS1980**: *Cannot define a class or member that uses 'dynamic' because the compiler required type cannot be found. Are you missing a reference?* | 
|  | 217 | +- **CS7083**: *Expression must be implicitly convertible to '`System.Object`', or the type '`dynamic`' is not available.* | 
|  | 218 | + | 
|  | 219 | +The compiler needs types from the `System.Runtime` namespace and the Dynamic Language Runtime (DLR) to generate code for dynamic operations (CS1969, CS1980, CS7083). Ensure your project includes the necessary references. The required types are included in all modern .NET (.NET 5 and later) projects. For .NET Framework projects, add a reference to `Microsoft.CSharp.dll` in your project file. | 
|  | 220 | + | 
|  | 221 | +For more information about dynamic type requirements, see [Using type dynamic](../../advanced-topics/interop/using-type-dynamic.md). | 
|  | 222 | + | 
|  | 223 | +## Dynamic dispatch warnings | 
|  | 224 | + | 
|  | 225 | +- **CS1974**: *The dynamically dispatched call to method can fail at run-time because one or more applicable overloads are conditional methods.* | 
|  | 226 | +- **CS1981**: *The '`is dynamic`' pattern is misleading. The runtime type of the subexpression is never '`dynamic`'. Consider using '`object`' instead.* | 
|  | 227 | + | 
|  | 228 | +When you call methods that have the `[Conditional]` attribute, avoid using dynamic dispatch. The compiler can't verify conditional method attributes with dynamic binding, which can cause runtime failures (CS1974). Cast the dynamic expression to its actual type first: | 
|  | 229 | + | 
|  | 230 | +```csharp | 
|  | 231 | +dynamic d = GetObject(); | 
|  | 232 | + | 
|  | 233 | +// Avoid: | 
|  | 234 | +d.ConditionalMethod(); // CS1974 - can fail at runtime | 
|  | 235 | +
 | 
|  | 236 | +// Recommended: | 
|  | 237 | +MyClass obj = (MyClass)d; | 
|  | 238 | +obj.ConditionalMethod(); // Compile-time checks ensure correctness | 
|  | 239 | +``` | 
|  | 240 | + | 
|  | 241 | +When you check whether a value is non-null, use `is object` instead of `is dynamic`. The `dynamic` keyword is a compile-time construct, and no object's runtime type is ever `dynamic` (CS1981): | 
|  | 242 | + | 
|  | 243 | +```csharp | 
|  | 244 | +// Avoid: | 
|  | 245 | +if (someValue is dynamic) // CS1981 - always evaluates to false | 
|  | 246 | +{ | 
|  | 247 | +    // This code never executes | 
|  | 248 | +} | 
|  | 249 | + | 
|  | 250 | +// Recommended: | 
|  | 251 | +if (someValue is object) // Correctly checks if non-null | 
|  | 252 | +{ | 
|  | 253 | +    // This code executes for non-null values | 
|  | 254 | +} | 
|  | 255 | +``` | 
|  | 256 | + | 
|  | 257 | +For more information about dynamic dispatch and runtime behavior, see [Using type dynamic](../../advanced-topics/interop/using-type-dynamic.md). | 
0 commit comments