![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/userdefault.png)
11/11/2015
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
Hello,
I'm trying to find a way to parse the binary structured data from an ExtensionObject.
I know, how to get the correct DataTypeNode of the received data. But didn't find any way on how to use it to decode the binary data.
Hopefully, anyone can give me a hint how to do this with the .NET SDK.
Thanks!
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/admindefault.png)
05/30/2017
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
https://github.com/OPCFoundati.....Encoder.cs
public ExtensionObject ReadExtensionObject(string fieldName)
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/userdefault.png)
11/11/2015
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
Thanks for your reply!
But how do I use the Binary decoder? And whats the fieldName?
Is there a possibility to the the DataTypeNode for the decoder?
The following code does not work...
DataValue Data = GetDataFromServer(...);
var ExtData = GenericData.Value as ExtensionObject;using var Decoder = new BinaryDecoder(ExtData .Body as byte[], ServiceMessageContext.GlobalContext);
var Result = Decoder.ReadExtensionObject(null);
![Avatar](https://opcfoundation.org/wp-content/uploads/sp-resources/forum-avatars/defaults/admindefault.png)
05/30/2017
![sp_UserOfflineSmall](https://opcfoundation.org/wp-content/sp-resources/forum-themes/reboot/images/darkpack/sp_UserOfflineSmall.png)
The binary decoder needs to exact the fields of the custom structure.
i.e.
field1 = Decoder.ReadInt32();
field2 = Decoder.ReadString();
The process is the same as you would expect if you were extracting information from an XML or JSON document.
Some stacks that have helper classes that can parse ExtensionObjects from a schema definition but I am not sure NETStandard has that yet.
1 Guest(s)