MessagingToolkit.QRCode: “Index was outside the bounds of the array” error..

Ok, this one was really annoying: I’m using the MessagingToolkit to create dynamic QR-codes. Sometimes my application threw an exception, because an “Index was outside the bounds of the array”. Because of the complex scenario, it was pretty hard to track down this error. Adding the following lines to my code solved the problem:

//create encoder object
MessagingToolkit.QRCode.Codec.QRCodeEncoder qe = new MessagingToolkit.QRCode.Codec.QRCodeEncoder();

//set error correction level to Q = 25%
qe.QRCodeErrorCorrect = MessagingToolkit.QRCode.Codec.QRCodeEncoder.ERROR_CORRECTION.Q;
                    
//here comes work-around #1
qe.QRCodeVersion = 0;

//here comes work-around #2, using utf8 
Bitmap bmp = qe.Encode(encodedText, System.Text.Encoding.UTF8);

I really like this library, it’s very easy to work with and does exactly what i was looking for. But it would be great if they could fix this bug.

Advertisements
MessagingToolkit.QRCode: “Index was outside the bounds of the array” error..

One thought on “MessagingToolkit.QRCode: “Index was outside the bounds of the array” error..

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s