I have come across this odd behaviour: when my projects settings are set to Any CPU
and Prefer 32-bit
on a 64bit Windows 7 OS
the .Net 4.5
program below works as expected. If however I turn off Prefer 32-bit
then when stepping through the program, I can see that the code never steps into the interface implementation - but also does not throw any errors.
I have distilled it down to its simplest form in the following console application:
namespace BugCheck
{
interface IBroken
{
bool Broken<TValue> (TValue gen, Large large);
}
class Broke : IBroken
{
public bool Broken<TValue> (TValue gen, Large large )
{ return true; }
}
struct Large
{
int a, b, c;
}
class Program
{
static void Main (string[] args)
{
//32bit can step in. 64bit can't
((IBroken)new Broke()).Broken(1, new Large());
}
}
}
As expected, when toggling Prefer 32-bit
the program will alternate between the .net 32bit assemblies and the 64bit assemblies - where it works as expected with the 32bit assemblies and "breaks silently" with the 64bit assemblies.
As suggested by @Athari it appears to be related to the size of the Large struct.
What am I doing wrong that is causing this behaviour?