OrchardCMS/OrchardCore · error · InvalidOperationException
Invalid dependency position of type
Error message
Invalid dependency position of type '{dependent.Type}' for resource '{dependent.Name}' positioned at '{dependent.Position}' depending on '{Name}' positioned at '{Position}' What it means
RequireSettings.UpdatePositionFromDependent throws this InvalidOperationException when dependency ordering is contradictory: a resource required 'First' is positioned 'Last' while a resource that depends on it is positioned 'First' (Last cannot be reordered to satisfy a First-dependent). The dependency graph cannot be laid out in document order.
Solutions
- Align the positions: require the dependency at First (or ByDependency) so a First-dependent can be satisfied.
- Remove the explicit Last/First positioning on one of the two conflicting resources and let default ByDependency ordering apply.
- Resolve which module/theme imposes the ordering and change it in that module's ResourceManifest or the RequireSettings call.
- If you own both calls, drop the dependency or the positional constraint so ordering is unambiguous.
Example fix
// before settings.BuildPosition(ResourcePosition.Last); // dependency required Last required.BuildPosition(ResourcePosition.First); // dependent required First -> conflict // after settings.BuildPosition(ResourcePosition.ByDependency); // allow ordering by dependency
Defensive patterns
Strategy: validation
Validate before calling
if (dependent.Position == ResourcePosition.First && dependency.Position == ResourcePosition.Last)
throw new InvalidOperationException("Cannot require a First-positioned resource that depends on a Last-positioned resource."); Try / catch
try
{
resourceManager.GetRequiredResources(resourceType);
}
catch (InvalidOperationException ex) when (ex.Message.Contains("Invalid dependency position"))
{
logger.LogWarning(ex, "Conflicting resource positioning; using default ordering.");
} Prevention
- Only use First/Last positioning on leaf resources, not shared dependencies.
- Let dependencies order themselves via ByDependency (the default).
- Audit themes and modules that both position the same shared resource (e.g. jQuery).
- Document positioning intent in one place (the manifest) rather than scattered Require calls.
When it happens
Trigger: Two resources where the dependent is required with ResourcePosition.First and the dependency is required with ResourcePosition.Last, via BuildPosition/CombinePosition during RequireSettings combination or dependency expansion.
Common situations: A theme requires a script 'at Foot/Last' while a module requires the same script 'at Head/First' and declares a dependency on it; conflicting positioning directives from two modules or a theme overriding module ordering for the same shared resource.
Understand the failure class
Background: Conflicting config options: "cannot be used together" — configuration validation errors across open-source libraries — this error's family across 162 libraries.
Related errors
- Could not find a resource of type
- The resource version should be in the form of…
- Unknown token type
- Deserializing a is not supported.
- Cannot perform this operation because the shell scope for…
AI-assisted analysis of OrchardCMS/OrchardCore@4306c0717f (2026-09-13).
Data as JSON: /api/errors/eb057e30dcf8c29b.
Report an issue: GitHub.
Appendix: source
Thrown at src/OrchardCore/OrchardCore.ResourceManagement.Abstractions/RequireSettings.cs:227
return other._attributes == null ? null : new Dictionary<string, string>(other._attributes);
}
if (other._attributes == null)
{
return new Dictionary<string, string>(_attributes);
}
var mergedAttributes = new Dictionary<string, string>(_attributes);
foreach (var pair in other._attributes)
{
mergedAttributes[pair.Key] = pair.Value;
}
return mergedAttributes;
}
public RequireSettings UpdatePositionFromDependent(RequireSettings dependent)
{
if (dependent.Position == ResourcePosition.First && Position == ResourcePosition.Last)
{
throw new InvalidOperationException($"Invalid dependency position of type '{dependent.Type}' for resource '{dependent.Name}' positioned at '{dependent.Position}' depending on '{Name}' positioned at '{Position}'");
}
// If a 'First' resource depends on a 'ByDependency' resource, position the dependency 'First'.
if (dependent.Position == ResourcePosition.First && Position == ResourcePosition.ByDependency)
{
Position = ResourcePosition.First;
}
return this;
}
public RequireSettings UpdatePositionFromDependency(RequireSettings dependency)
{
// If a 'ByDependency' resource depends on a 'Last' resource, position the dependent 'Last'.
if (Position == ResourcePosition.ByDependency && dependency.Position == ResourcePosition.Last)
{
Position = ResourcePosition.Last;
}View on GitHub (pinned to 4306c0717f)