ASN.1 encoding or decoding is always performed on the entire PDU or message, which often consists of a large number of elements organized in a complex structure. When encoding or decoding fails, finding which element caused the error might be difficult. To make encoding or decoding easier to troubleshoot, you can use the ValueNotationFormatter runtime trace or print class: every C# representation type can be printed or converted into an ASN.1 value string using ToString() or the ValueNotationFormatter class, which offers more formatting options.
Example:
using VNF = Oss.Asn1.ValueNotationFormatter; . . . // two lines below are equivalent Console.WriteLine(pdu.ToString()); Console.WriteLine(pdu); // print with options VNF.Options.IndentSize = 10; VNF.Options.NewLine = "\n"; VNF.Print(pdu); // log to file StreamWriter log = new StreamWriter("log.txt"); VNF.Print(pdu, log);
This documentation applies to the OSS® ASN.1 Tools for C# release 5.3 and later.
Copyright © 2024 OSS Nokalva, Inc. All rights reserved.
No part of this publication may be reproduced, stored in a retrieval system, or transmitted in any form or by any means electronic, mechanical, photocopying, recording or otherwise, without the prior permission of OSS Nokalva, Inc.
Every distributed copy of the OSS® ASN.1 Tools for C# is associated with a specific license and related unique license number. That license determines, among other things, what functions of the OSS ASN.1 Tools for C# are available to you.