{"record":{"id":"58b3b290ff09685a","repo":"dotnet/BenchmarkDotNet","slug":"missing-extension-on-source-source-must-have","errorCode":null,"errorMessage":"Missing extension on source '{source}', must have the extension '.dll' or '.exe'.","messagePattern":"Missing extension on source '(.+?)', must have the extension '\\.dll' or '\\.exe'\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"src/BenchmarkDotNet.TestAdapter/VSTestAdapter.cs","lineNumber":237,"sourceCode":"#if NETFRAMEWORK\n            var appBase = Path.GetDirectoryName(assemblyPath);\n            var setup = new AppDomainSetup { ApplicationBase = appBase };\n            var domainName = $\"Isolated Domain for {type.Name}\";\n            var appDomain = AppDomain.CreateDomain(domainName, null, setup);\n            return appDomain.CreateInstanceAndUnwrap(\n                type.Assembly.FullName, type.FullName, false, BindingFlags.Default, null, null, null, null);\n#else\n            return Activator.CreateInstance(type);\n#endif\n        }\n\n        private static void ValidateSourceIsAssemblyOrThrow(string source)\n        {\n            if (string.IsNullOrEmpty(source))\n                throw new ArgumentException($\"'{nameof(source)}' cannot be null or whitespace.\", nameof(source));\n\n            if (!Path.HasExtension(source))\n                throw new NotSupportedException($\"Missing extension on source '{source}', must have the extension '.dll' or '.exe'.\");\n\n            var extension = Path.GetExtension(source);\n            if (!string.Equals(extension, \".dll\", StringComparison.OrdinalIgnoreCase) && !string.Equals(extension, \".exe\", StringComparison.OrdinalIgnoreCase))\n                throw new NotSupportedException($\"Unsupported extension on source '{source}', must have the extension '.dll' or '.exe'.\");\n        }\n    }\n}\n","sourceCodeStart":219,"sourceCodeEnd":245,"githubUrl":"https://github.com/dotnet/BenchmarkDotNet/blob/b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3/src/BenchmarkDotNet.TestAdapter/VSTestAdapter.cs#L219-L245","documentation":"ValidateSourceIsAssemblyOrThrow throws NotSupportedException (via Path.HasExtension returning false) when the source string has no extension. The adapter only accepts benchmark assemblies with a '.dll' or '.exe' extension; an extension-less path cannot be a managed assembly.","triggerScenarios":"Source passed without a file extension, e.g. a directory path or a malformed filename like 'MyBenchmarks' (no '.dll'). Path.HasExtension returns false.","commonSituations":"Passing a project/output directory instead of the assembly file; a typo or truncated path; tooling that strips the extension before forwarding to the adapter.","solutions":["Point the adapter at the compiled assembly file (e.g. bin/Debug/net8.0/MyBenchmarks.dll).","If you only have a project path, build it first and resolve the output .dll/.exe.","Fix the calling code/tool that is dropping the extension."],"exampleFix":"// before\nvar source = \"MyBenchmarks\"; // no extension -> throws\n\n// after\nvar source = \"bin/Debug/net8.0/MyBenchmarks.dll\";","handlingStrategy":"validation","validationCode":"static string RequireAssemblyPath(string source)\n{\n    if (!Path.HasExtension(source))\n        throw new ArgumentException($\"source '{source}' must be a .dll/.exe\", nameof(source));\n    return source;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Pass the compiled assembly file, not the project directory or output folder.","Build the project first and resolve the output .dll/.exe path.","Audit tooling that may strip the extension before forwarding."],"tags":["benchmarkdotnet","testadapter","vstest","validation","source-path"],"backgroundTag":null,"analyzedSha":"b515068b61ad1c9c9aa938b8ece4af1e7d6d85a3","analyzedAt":"2026-08-13T19:12:24.196Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}