XINCGer/Unity3DTraining · error · DescriptorValidationException
Dependencies passed to FileDescriptor.BuildFrom() don't…
Error message
Dependencies passed to FileDescriptor.BuildFrom() don't match those listed in the FileDescriptorProto.
What it means
FileDescriptor.BuildFrom verifies that the FileDescriptor array passed by the caller exactly matches the dependency list declared inside the FileDescriptorProto. If the counts differ, the descriptor and supplied dependencies are inconsistent and a DescriptorValidationException is thrown.
Solutions
- Regenerate the C# code so the dependencies array matches the descriptor's imports exactly.
- Compare proto.Dependency with the passed dependencies array; add/remove entries so counts and order match.
- Ensure all generated files are from the same protoc/plugin generation run.
- If a dependency was intentionally removed from the .proto, rebuild both descriptor and code together.
Example fix
// before
return new FileDescriptor[] { A.Descriptor }; // proto declares 2 dependencies
// after
return new FileDescriptor[] { A.Descriptor, B.Descriptor }; // matches proto.Dependency.Count Defensive patterns
Strategy: validation
Validate before calling
bool DepsMatch(FileDescriptorProto p, FileDescriptor[] deps) => deps.Length == p.Dependency.Count && deps.Zip(p.Dependency, (fd, name) => fd.Name == name).All(x => x);
Try / catch
try { BuildFrom(...); } catch (DescriptorValidationException e) when (e.Message.Contains("don't match")) { log.LogError("Dependency array out of sync with descriptor imports — regenerate"); } Prevention
- Generate dependencies arrays automatically via the code generator, not by hand.
- Regenerate all generated files together after .proto changes.
- Assert deps.Length == proto.Dependency.Count in tests.
When it happens
Trigger: FromGeneratedCode/BuildFrom called with a dependencies array whose length differs from proto.Dependency.Count — e.g. dropping a dependency descriptor or adding an extra one.
Common situations: Hand-updating generated code after schema changes; copying BuildFrom boilerplate between generated files with different imports; a code generator version mismatch where the embedded descriptor lists imports the caller array omits.
Related errors
- Field with message or enum type missing type_name.
- Property not found in
- Invalid public dependency
- Invalid embedded descriptor for
- No such field number
AI-assisted analysis of XINCGer/Unity3DTraining@016f98412e (2026-09-12).
Data as JSON: /api/errors/5ea1b990edd7e233.
Report an issue: GitHub.
Appendix: source
Thrown at NetWorkAndResources/Socket_Protobuff/Assets/Plugins/Google.Protobuf/Reflection/FileDescriptor.cs:273
// FileDescriptorProto's tree and put all of the descriptors into the
// DescriptorPool's lookup tables. In the linking step, we look up all
// type references in the DescriptorPool, so that, for example, a
// FieldDescriptor for an embedded message contains a pointer directly
// to the Descriptor for that message's type. We also detect undefined
// types in the linking step.
if (dependencies == null)
{
dependencies = new FileDescriptor[0];
}
DescriptorPool pool = new DescriptorPool(dependencies);
FileDescriptor result = new FileDescriptor(descriptorData, proto, dependencies, pool, allowUnknownDependencies, generatedCodeInfo);
// Validate that the dependencies we've been passed (as FileDescriptors) are actually the ones we
// need.
if (dependencies.Length != proto.Dependency.Count)
{
throw new DescriptorValidationException(
result,
"Dependencies passed to FileDescriptor.BuildFrom() don't match " +
"those listed in the FileDescriptorProto.");
}
result.CrossLink();
return result;
}
private void CrossLink()
{
foreach (MessageDescriptor message in MessageTypes)
{
message.CrossLink();
}
foreach (ServiceDescriptor service in Services)
{View on GitHub (pinned to 016f98412e)