Question

I'm building a PowerShell host in VS 2012, currently in a C# (.NET 4.5) Console Project. The project is configured for Any CPU and 'Prefer 32-bit' is not checked. I've added a reference to System.Management.Automation manually by adding

    <Reference Include="System.Management.Automation" />

to the ItemGroup with the other References in the .csproj file. I was getting odd behaviour reading from the registry (missing keys, etc.) and I realised it was looking at the x86 part. So I ran this script in the host:

if ([System.IntPtr]::Size -eq 4) 
{ 
    "32-bit"
}
else
{
    "64-bit"
}

and got back

"32-bit"

which wasn't a surprise given the behaviour, but was a surprise given the configuration. Anyone got any ideas? Is there something about hosted PowerShell that has to be x86?

Was it helpful?

Solution

On the off-chance, I tried checking the 'Prefer 32-bit' box, saving the project, then un-checking it and saving the project again. After this, it built as 64-bit. For info, this is Visual Studio 2012 Update 2 (11.0.60315.01).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top