The following code sample works fine unprotected, but the protected version throws an exception because the array is not being populated.
struct ValueHolder
{
public byte value;
}
static void Main(string[] args)
{
ValueHolder[] pairs = GeneratePairs();
for (int i = 0; i < pairs.Length; i++)
{
if (pairs.value != i)
throw new Exception("value " + i); // this throws on i >= 1
}
Console.WriteLine("Success!");
}
private static ValueHolder[] GenerateValues()
{
ValueHolder[] ret = new ValueHolder[15];
for (int i = 0; i < ret.Length; i++)
{
ret.value = (byte)i;
}
return ret;
}
We are running code protector version 3.0.1908.464.