{
  "id": 7157741,
  "title": "Why Your .NET MCP Tool Classes Crash at Runtime (And the Two-Line Fix)",
  "url": "https://urgent.news/2026/09/13/why-your-net-mcp-tool-classes-crash-at-runtime-and-the-two-line-fix",
  "topic": "tech",
  "section": "Tech",
  "published": "2026-09-13T19:28:37.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/tekspry/why-your-net-mcp-tool-classes-crash-at-runtime-and-the-two-line-fix-lcb"
  },
  "original_language": "en",
  "account": "When creating MCP servers in .NET using instance-based tool classes, such as those taking ILogger<T>, HttpClient, or repositories through constructor injection, users may have encountered a runtime crash. This issue is not flagged by warnings or compile-time errors, leading to silence at startup and a crash during production. The source material explains the root cause and provides a two-line fix in DotnetFastMCP v2.1 to address this problem.",
  "summary": "If you're building MCP servers in .NET with instance-based tool classes — the kind that take ILogger<T> , HttpClient , or a repository through constructor injection — there's a good chance you've already hit this at runtime: System.Reflection.TargetException: Non-static method requires a target. No warning at startup. No compile-time error. Just a crash the moment an AI model calls your tool in…",
  "key_points": [
    "Runtime crashes occur in .NET MCP tool classes with constructor injection.",
    "Issue not flagged by warnings or compile-time errors.",
    "DotnetFastMCP v2.1 provides two-line fix for problem."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}