Generated Method Format and Calling Parameters

The signature for the MDER encode method comes in two forms, shown below:

public virtual void Encode(Asn1MderOutputStream buffer, bool useCachedLength ) 

public virtual void Encode(Asn1MderOutputStream buffer ) 

The buffer argument is an Asn1MderOutputStream object which receives the encoded message. This must be created and initialized before calling any encode method. See the description of this class in the C# Run-Time Classes section for details on how this class is used.

The useCachedLength argument indicates whether the encode method can rely on cached length information. In some cases, MDER requires pre-calculation of the length of nested structures and this piece of information is needed twice during encoding (once when encoding the containing structure and once when encoding the nested structure). The generated types cache this information during encoding. User code should normally pass false for this argument. The generated encoding methods will pass true to other encoding methods when appropriate.

As you can see, the encode methods return void; an exception is thrown if an error occurs. All ASN1C exceptions are derived from Asn1Exception. See the section on exceptions for a complete list and description of the various exceptions that can be thrown.