I am trying to set the DecoderFallback property of an arbitrary (but supported) encoding in my C # application. Essentially, I'm trying to do this:
ASCIIEncoding ascii = new ASCIIEncoding();
ascii.DecoderFallback = new DecoderExceptionFallback();
I get an exception that I have never seen before:
Exception System.InvalidOperationException unhandled Message = "Read-only instance." Source = "mscorlib"
Stack Traces : in System.Text.Encoding.set_DecoderFallback (DecoderFallback value) at <... in my application ...> InnerException:
I could not find the MSDN documentation with examples of using this property. If someone can point me to someone, perhaps suggest what is wrong, I will be grateful. I need to throw an exception due to the impossibility of decoding a byte or bytes and cannot afford to leave it unnoticed.
Thanks Brian
source
share