{"record":{"id":"82ba9d75bfeace3e","repo":"microsoft/semantic-kernel","slug":"impossible-to-create-type-for-datacontractmetada","errorCode":null,"errorMessage":"Impossible to create type for '{dataContractMetadata.Name}' data contract.","messagePattern":"Impossible to create type for '(.+?)' data contract\\.","errorType":"exception","errorClass":"KernelException","httpStatus":null,"severity":"error","filePath":"dotnet/src/Functions/Functions.Grpc/GrpcOperationRunner.cs","lineNumber":325,"sourceCode":"            setterIl.Emit(OpCodes.Ldarg_1);\n            setterIl.Emit(OpCodes.Stfld, fieldBuilder);\n            setterIl.Emit(OpCodes.Ret);\n\n            //Registering the property get and set methods.\n            propertyBuilder.SetGetMethod(getterBuilder);\n            propertyBuilder.SetSetMethod(setterBuilder);\n\n            //Add ProtoMember attribute to the data contract with tag/number\n            var dataMemberAttributeBuilder = new CustomAttributeBuilder(typeof(ProtoMemberAttribute).GetConstructor([typeof(int)])!, [field.Number]);\n            propertyBuilder.SetCustomAttribute(dataMemberAttributeBuilder);\n        }\n\n        //Add ProtoContract attribute to the data contract\n        var dataContractAttributeBuilder = new CustomAttributeBuilder(typeof(ProtoContractAttribute).GetConstructor(Type.EmptyTypes)!, []);\n        typeBuilder.SetCustomAttribute(dataContractAttributeBuilder);\n\n        return typeBuilder.CreateTypeInfo() ??\n            throw new KernelException($\"Impossible to create type for '{dataContractMetadata.Name}' data contract.\");\n    }\n\n    /// <summary>\n    /// Returns .net type that corresponds to protobuf data type name.\n    /// </summary>\n    /// <param name=\"type\">The protobuf data type name.</param>\n    /// <returns>The .net type.</returns>\n    private static Type GetNetType(string type) =>\n        type switch\n        {\n            \"TYPE_DOUBLE\" => typeof(double),\n            \"TYPE_FLOAT\" => typeof(float),\n            \"TYPE_INT64\" => typeof(long),\n            \"TYPE_UINT64\" => typeof(ulong),\n            \"TYPE_INT32\" => typeof(int),\n            \"TYPE_FIXED64\" => typeof(ulong),\n            \"TYPE_FIXED32\" => typeof(uint),\n            \"TYPE_BOOL\" => typeof(bool),","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/dotnet/src/Functions/Functions.Grpc/GrpcOperationRunner.cs#L307-L343","documentation":"Thrown at the end of BuildGrpcOperationDataContractType when `typeBuilder.CreateTypeInfo()` returns null after emitting a dynamic assembly with ProtoContract/ProtoMember attributes. CreateTypeInfo returning null is rare and indicates the CLR refused to materialize the emitted type (e.g. invalid IL, conflicting members).","triggerScenarios":"A .proto data contract whose field set or types produce an unbuildable dynamic type — duplicate member names, unsupported field types in the emit path, or a reflection-emit constraint violation.","commonSituations":"Edge-case .proto schemas the dynamic type builder wasn't designed for; protobuf field types that map to incompatible CLR types during emit.","solutions":["Inspect the .proto data contract named in the message for unusual or duplicate field definitions.","Simplify the message (rename duplicate fields, remove unsupported types) and retry.","Report the schema if it is valid protobuf but still fails — this is effectively an internal emit failure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { /* register gRPC plugin */ }\ncatch (KernelException ex) when (ex.Message.Contains(\"Impossible to create type\")) {\n    logger.LogError(ex, \"Dynamic data-contract emit failed for {name}\"); throw;\n}","preventionTips":["Keep .proto message schemas simple and primitive.","Test each new .proto against the runner before relying on it."],"tags":["grpc","reflection-emit","protobuf","internal"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}