# CS1061 — Member not found on type
## Pattern
`error CS1061: 'T' does not contain a definition for 'X' and no accessible extension method 'X' accepting a first argument of type 'T' could be found`
## Root Causes (ordered by likelihood)
1. SharpDX API drift — method signature changed between SharpDX versions bundled with different NT8 releases
2. `Series<double>` used where `ISeries<double>` is required (or vice versa) — interface vs concrete type mismatch
3. Calling a method on the wrong base class (e.g., calling an `Indicator`-only method from a `Strategy` context)
4. Null-conditional access on a type that doesn't support the member (wrong type inferred)
## Fix Strategies
### Strategy 1: SharpDX API drift
- **Detect**: The error references a method on a SharpDX type (`RenderTarget`, `Brush`, `TextFormat`, `Factory`, etc.). Common drifted methods: `Dispose()` signature, `DrawText` parameter count, `CreateSolidColorBrush` overloads.
- **Lookup**: NT8 8.x ships SharpDX 2.6.3. Check the SharpDX 2.6.3 API for the exact method signature. The NT8 API reference also documents the expected SharpDX calls in `OnRender`.
- **Fix**: Match the call site to the SharpDX 2.6.3 signature. For `Dispose`, use the parameterless overload. For `DrawText`, confirm the parameter order matches the 2.6.3 overload.
- **Verify**: The method call matches the SharpDX 2.6.3 signature exactly.
```csharp
// SharpDX 2.6.3 RenderTarget.DrawText signature:
// void DrawText(string text, TextFormat textFormat, RectangleF layoutRect, Brush defaultForegroundBrush)
// Wrong (extra parameter from newer SharpDX):
RenderTarget.DrawText(text, format, rect, brush, DrawTextOptions.None);
// Correct for NT8 / SharpDX 2.6.3:
RenderTarget.DrawText(text, format, rect, brush);
```
### Strategy 2: Series<T> vs ISeries<T> mismatch
- **Detect**: The error references a method or property on `Series<double>` or `ISeries<double>` that doesn't exist on the other. Common: `GetValueAt`, `IsValidDataPoint`, `Count`, indexer `[int]`.
- **Lookup**: `ISeries<T>` is the interface; `Series<T>` is the concrete implementation. NT8 API methods that accept data series typically take `ISeries<double>`. Custom helper methods may declare `Series<double>` when they should accept `ISeries<double>`.
- **Fix**: Change the parameter or variable type to `ISeries<double>` if the method needs to accept both built-in series (like `Close`) and custom `Series<T>` fields. If the concrete type is needed for mutation, keep `Series<T>`.
- **Verify**: The type used matches what the calling code passes in, and the method exists on that type.
```csharp
// Wrong: Close is ISeries<double>, not Series<double>
private void Process(Series<double> data) { ... }
Process(Close); // CS1061 or CS1503
// Correct:
private void Process(ISeries<double> data) { ... }
Process(Close); // OK
```
### Strategy 3: Method exists on base class but not on the declared type
- **Detect**: The method is documented in NT8 but the variable is typed as a more specific or less specific class than the one that declares the method. Example: calling `AddDataSeries` on a variable typed as `NinjaScriptBase` instead of `Indicator`.
- **Lookup**: Check the NT8 class hierarchy. `NinjaScriptBase` → `Indicator` → specific indicator. Methods like `AddDataSeries`, `AddPlot`, `AddLine` are on `Indicator`, not `NinjaScriptBase`.
- **Fix**: Change the variable type to the class that actually declares the method, or cast to that type before calling.
- **Verify**: The method is declared on the type used at the call site.
### Strategy 4: Calling instance method on null or wrong type via var inference
- **Detect**: The error says the method doesn't exist on the inferred type. The variable was declared with `var` and the compiler inferred a different type than expected.
- **Lookup**: Hover over the variable in the editor (or read the declaration) to see the inferred type. Compare it to the type that declares the method.
- **Fix**: Replace `var` with the explicit type, or cast the expression to the correct type before calling the method.
- **Verify**: The explicit type declares the method and the call compiles.
## NT8-Specific SharpDX Method Reference (SharpDX 2.6.3)
| Method | Correct Signature |
|--------|-------------------|
| `DrawText` | `(string, TextFormat, RectangleF, Brush)` |
| `DrawRectangle` | `(RectangleF, Brush, float)` |
| `FillRectangle` | `(RectangleF, Brush)` |
| `DrawLine` | `(Vector2, Vector2, Brush, float)` |
| `CreateSolidColorBrush` | `(Color4)` |
| `Dispose` (all SharpDX objects) | `()` — parameterless |
## Example Fix
```diff
protected override void OnRender(ChartControl chartControl, ChartScale chartScale)
{
using (var brush = RenderTarget.CreateSolidColorBrush(SharpDX.Color.White))
{
- // CS1061: 'RenderTarget' does not contain a definition for 'DrawText' with 5 args
- RenderTarget.DrawText("DEEP6", _textFormat, _rect, brush, DrawTextOptions.None);
+ // Correct: SharpDX 2.6.3 DrawText takes 4 args
+ RenderTarget.DrawText("DEEP6", _textFormat, _rect, brush);
}
}
```