{"record":{"id":"4628469e0bb535da","repo":"microsoft/aspire","slug":"builder-gettype-fullname-is-missing-build","errorCode":null,"errorMessage":"'{builder.GetType().FullName}' is missing Build().","messagePattern":"'(.+?)' is missing Build\\(\\)\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/Aspire.Hosting.RemoteHost/Ats/ReferenceExpressionRef.cs","lineNumber":355,"sourceCode":"    }\n\n    private static void AppendValueProvider(object builder, object valueProvider)\n    {\n        var appendValueProviderMethod = builder.GetType().GetMethod(\n            \"AppendValueProvider\",\n            BindingFlags.Instance | BindingFlags.Public,\n            binder: null,\n            [typeof(object), typeof(string)],\n            modifiers: null)\n            ?? throw new InvalidOperationException($\"'{builder.GetType().FullName}' is missing AppendValueProvider(object, string).\");\n\n        appendValueProviderMethod.Invoke(builder, [valueProvider, null]);\n    }\n\n    private static object BuildReferenceExpression(object builder)\n    {\n        var buildMethod = builder.GetType().GetMethod(\"Build\", BindingFlags.Instance | BindingFlags.Public)\n            ?? throw new InvalidOperationException($\"'{builder.GetType().FullName}' is missing Build().\");\n\n        return buildMethod.Invoke(builder, null)\n            ?? throw new InvalidOperationException($\"'{builder.GetType().FullName}.Build()' returned null.\");\n    }\n\n    private static object CreateConditionalReferenceExpression(\n        object condition,\n        string matchValue,\n        object whenTrue,\n        object whenFalse)\n    {\n        var referenceExpressionType = GetRequiredHostingType(HostingTypeNames.ReferenceExpression, condition);\n        var valueProviderType = GetRequiredHostingType(HostingTypeNames.ValueProviderInterface, condition);\n\n        var createConditionalMethod = referenceExpressionType.GetMethod(\n            \"CreateConditional\",\n            BindingFlags.Public | BindingFlags.Static,\n            binder: null,","sourceCodeStart":337,"sourceCodeEnd":373,"githubUrl":"https://github.com/microsoft/aspire/blob/25830f84bd145686607ad00c057b3f84e2e51d43/src/Aspire.Hosting.RemoteHost/Ats/ReferenceExpressionRef.cs#L337-L373","documentation":"BuildReferenceExpression reflectively locates the public parameterless Build() method on the ReferenceExpression.Builder and invokes it to produce the final expression. If no such method exists, this InvalidOperationException is thrown naming the builder's type.","triggerScenarios":"ToValueReferenceExpression finishes appending literal/value parts and calls BuildReferenceExpression(builder); GetMethod(\"Build\", Public|Instance) returns null because the object is not the expected builder or the API changed.","commonSituations":"Version mismatch between the RemoteHost code and the loaded Aspire.Hosting assembly; passing a wrong object; trimming removing Build() in AOT builds.","solutions":["Verify the builder is ReferenceExpression.Builder from a compatible Aspire.Hosting version.","Align package versions across Aspire.Hosting / RemoteHost projects.","Add trimming preservation for ReferenceExpression.Builder.Build if publishing AOT/trimmed.","Confirm AppendLiteral/AppendValueProvider steps succeeded earlier — a wrong-type builder earlier in the flow surfaces here."],"exampleFix":"// before\n<PackageReference Include=\"Aspire.Hosting\" Version=\"9.*\" />\n\n// after\n<PackageReference Include=\"Aspire.Hosting\" Version=\"13.*\" /> <!-- matches RemoteHost expectations -->","handlingStrategy":"type-guard","validationCode":"var m = builder.GetType().GetMethod(\"Build\", BindingFlags.Instance | BindingFlags.Public);\nif (m is null)\n    throw new NotSupportedException($\"{builder.GetType().FullName} lacks a public Build(); it is not a ReferenceExpression.Builder.\");","typeGuard":"static bool SupportsBuild(object builder) =>\n    builder.GetType().GetMethod(\"Build\", BindingFlags.Instance | BindingFlags.Public) is not null;","tryCatchPattern":"try\n{\n    var expr = BuildReferenceExpression(builder);\n}\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"missing Build()\"))\n{\n    logger.LogError(ex, \"Cannot finalize reference expression: {Message}\", ex.Message);\n}","preventionTips":["Confirm all prior Append steps ran on the same builder instance before Build.","Align Aspire.Hosting package versions across the solution.","Smoke-test Build() after SDK/package upgrades.","Root the ReferenceExpression.Builder API in trimmer settings for AOT publishes."],"tags":["reflection","reference-expression","missing-method"],"backgroundTag":"method-not-implemented","analyzedSha":"25830f84bd145686607ad00c057b3f84e2e51d43","analyzedAt":"2026-09-16T11:10:06.193Z","contentChangedAt":"2026-09-16T11:10:06.193Z","schemaVersion":2},"datasetVersion":"2026-09-21T04:17:39.646Z"}