Sytem.InvalidCastException on Windows Phone

One of my code throws this exception:

An exception of type 'System.InvalidCastException' occurred in mscorlib.ni.dll but was not handled in user code

Additional information: At least one element in the source array could not be cast down to the destination array type.

I get this exception on visual studio 2013 when I run this project on Windows Phone. OS version is 8.1 developer preview.
the Code snippet is:

private var BootlePattern : int[];
var BootleHits : boolean[];
var maxBottle : int;

function Start() {	
    ...
    BootlePattern=new Array(maxBottle);
    BootleHits=new Array(maxBottle);
    ...
}

Can anyone please suggest anything about how to solve this?

Explicitly initializing the arrays like:

BootlePattern = [0, 0, 0, 0, 0, 0];

instead of :

BootlePattern = new Array(maxBottle);

solved my problem. I guess Windows phone could not handle the datatype during the declaration without value. Though I don’t know the real reason.