{"record":{"id":"faf492b0fae3cf68","repo":"MaterialDesignInXAML/MaterialDesignInXamlToolkit","slug":"no-loaded-dialoghost-have-an-nameof-identifier","errorCode":null,"errorMessage":"No loaded DialogHost have an {nameof(Identifier)} property matching {nameof(dialogIdentifier)} ('{dialogIdentifier}') argument.","messagePattern":"No loaded DialogHost have an (.+?) property matching (.+?) \\('(.+?)'\\) argument\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"src/MaterialDesignThemes.Wpf/DialogHost.cs","lineNumber":251,"sourceCode":"                }\n                else\n                {\n                    // Retrieve the identifier using the Dispatcher on the owning thread (effectively replaces the VerifyAccess() call previously used)\n                    identifier = dialogInstance.Dispatcher.Invoke(() => dialogInstance.Identifier);\n                }\n                if (Equals(dialogIdentifier, identifier))\n                {\n                    targets.Add(dialogInstance);\n                }\n            }\n            else\n            {\n                LoadedInstances.Remove(instance);\n            }\n        }\n\n        if (targets.Count == 0)\n            throw new InvalidOperationException($\"No loaded DialogHost have an {nameof(Identifier)} property matching {nameof(dialogIdentifier)} ('{dialogIdentifier}') argument.\");\n        if (targets.Count > 1)\n            throw new InvalidOperationException(\"Multiple viable DialogHosts. Specify a unique Identifier on each DialogHost, especially where multiple Windows are a concern.\");\n\n        return targets[0];\n    }\n\n    internal async Task<object?> ShowInternal(object content, DialogOpenedEventHandler? openedEventHandler, DialogClosingEventHandler? closingEventHandler, DialogClosedEventHandler? closedEventHandler)\n    {\n        if (IsOpen)\n            throw new InvalidOperationException(\"DialogHost is already open.\");\n\n        _dialogTaskCompletionSource = new TaskCompletionSource<object?>();\n\n        AssertTargetableContent();\n\n        if (content != null)\n            DialogContent = content;\n","sourceCodeStart":233,"sourceCodeEnd":269,"githubUrl":"https://github.com/MaterialDesignInXAML/MaterialDesignInXamlToolkit/blob/98edec3a0b96ef272c587b14bcd67ef5f928a7ed/src/MaterialDesignThemes.Wpf/DialogHost.cs#L233-L269","documentation":"After confirming at least one `DialogHost` is loaded, `GetInstance` filters by matching `Equals(dialogIdentifier, instance.Identifier)`. If none match it throws `InvalidOperationException` reporting that no loaded host has an `Identifier` matching the supplied `dialogIdentifier`. Note a null identifier matches hosts whose `Identifier` is also null.","triggerScenarios":"Calling Show/Close with an identifier that does not equal any loaded host's `Identifier` (typo, different casing won't matter since it's `Equals`, but wrong value will), or with a non-null identifier when hosts are configured with null identifiers.","commonSituations":"Identifier mismatch between XAML (`Identifier=\"root\"`) and code (`Show(content, \"RootDialog\")`); renaming the identifier in one place only; using an enum/object identifier that doesn't `Equals` the configured one; passing an identifier when the host has none.","solutions":["Use the exact same `Identifier` value in XAML and in `Show`/`Close` calls (define it once as a const/shared key).","If you set no identifier in XAML, call Show/Close with `null`.","Ensure the identifier type's `Equals`/`GetHashCode` behave as you expect (strings, enums, records are fine; custom objects may not).","Double-check spelling/casing of string identifiers."],"exampleFix":"<!-- before -->\n<materialDesign:DialogHost Identifier=\"root\" />\nawait DialogHost.Show(vm, \"RootDialog\"); // mismatch -> throws\n\n<!-- after (single source of truth) -->\n<materialDesign:DialogHost Identifier=\"{x:Static local:DialogIds.Root}\" />\nawait DialogHost.Show(vm, DialogIds.Root);","handlingStrategy":"validation","validationCode":"object id = DialogIds.Root; // shared with XAML Identifier\nawait DialogHost.Show(content, id);","typeGuard":"static bool IdentifierIsMounted(object id)\n    => DialogHost.GetDialogSession(id) is not null || DialogHost.IsDialogOpen(id) || /* loaded */ true;","tryCatchPattern":"try { await DialogHost.Show(content, id); }\ncatch (InvalidOperationException ex) when (ex.Message.Contains(\"matching\"))\n{ /* identifier typo: log expected id */ }","preventionTips":["Define the identifier once and reference it from both XAML and code.","Use null consistently if no identifier is configured.","Ensure identifier types have correct Equals/GetHashCode semantics."],"tags":["wpf","dialog","identifier","configuration","material-design"],"backgroundTag":null,"analyzedSha":"98edec3a0b96ef272c587b14bcd67ef5f928a7ed","analyzedAt":"2026-08-13T14:31:19.111Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}