You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

ServiceEndpoint注册中.NetBinary消息格式的具体作用咨询

.NetBinary Message Format for ServiceEndpoint in Dynamics 365 Plugin Registration

Great question—this is one of those niche but critical details when routing PluginExecutionContext to Azure services via Dynamics 365 service endpoints. Let me break down exactly what this format is, how it compares to JSON, and when you’d want to use it.

What is .NetBinary Format?

At its core, .NetBinary is Microsoft’s native binary serialization format for .NET objects. For Dynamics 365 scenarios, it uses the System.Runtime.Serialization.DataContractSerializer to convert the full PluginExecutionContext object (and all its nested properties like Entity records, OptionSetValue instances, etc.) into a compact binary byte stream.

Unlike JSON (the text-based format you’re using now), this format preserves every detail of the original .NET type—including inheritance hierarchies, private field metadata, and strong type markers that JSON often drops or converts to generic values.

How It Works with ServiceEndpoints

When you select .NetBinary as the message format in the Plugin Registration Tool:

  • Dynamics 365 serializes the PluginExecutionContext directly to a binary blob instead of converting it to JSON text.
  • This blob is sent to your Azure Queue (or Service Bus) as the message body.
  • If your receiving service is a .NET application (like an Azure Function or Worker Service), you can deserialize the blob straight back into a fully functional PluginExecutionContext object without manual mapping.

Here’s a quick example of deserializing in an Azure Function:

using System.IO;
using System.Runtime.Serialization;
using Microsoft.Xrm.Sdk;

public static void Run(byte[] myQueueItem, ILogger log)
{
    // Initialize the serializer for PluginExecutionContext
    var serializer = new DataContractSerializer(typeof(PluginExecutionContext));
    
    // Convert the binary message back to the context object
    using var memoryStream = new MemoryStream(myQueueItem);
    var executionContext = (PluginExecutionContext)serializer.ReadObject(memoryStream);
    
    // Use the context directly—no JSON parsing needed!
    log.LogInformation($"Received context for {executionContext.PrimaryEntityName} record: {executionContext.PrimaryEntityId}");
}

.NetBinary vs. JSON: Key Tradeoffs

Aspect.NetBinaryJSON
PerformanceFaster serialization/deserialization, smaller payload sizeSlower for large contexts, larger text payload
Type FidelityPreserves all .NET type details (no data loss)Loses strong type info (e.g., OptionSetValue becomes a raw number)
Cross-Platform.NET-only—hard to parse in non-.NET stacks (Java, Python, etc.)Universal, easy to parse in any language
Ease of DebuggingNot human-readable—you can’t inspect the binary payload directlyHuman-readable, easy to debug with tools like Postman

When to Use .NetBinary

Opt for .NetBinary if:

  • Your receiving service is built with .NET (so you can leverage direct object deserialization).
  • You need maximum performance and minimal payload size for high-volume scenarios.
  • You rely on the full, unmodified PluginExecutionContext type (including nested complex objects).

If you’re working with non-.NET services or need easy debuggability, sticking with JSON is the better call.

内容的提问来源于stack exchange,提问作者Paul Richardson

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.07 08:22:34