Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Configure WPF client to run 64bit

We have some code that uses Entity Framework against a DB2 database.

When we try to use transaction scope, we get a message "The Under lying provider failed on Open".

  • We only get this error when to run from the WPF client.
  • We do not get this error when we run from a unit test.
  • The DB2 provider is 64bit

The difference that we have been able to find is that the unit test is configured as Any CPU, but the WPF project is configured as x86.

The problem is that the Visual Studion UI does not allow us to select anything other than x86 for the WPF project.

Is this a limitation of WPF projects? If not how do we configure a WPF project as Any CPU?

like image 924
Shiraz Bhaiji Avatar asked Feb 20 '12 09:02

Shiraz Bhaiji


4 Answers

Perhaps you are confusing the Visual Studio C# Platform with the Platform target?

Each Visual Studio C# project can be built to one of several platforms. This allows you to use the same project to build to several hardware platforms like 32 and 64 bit Intel/AMD CPU or even a different CPU like Itanium.

However, when you create a new project it will by default only contain a single platform, and in your case you also want to build to only a single platform, i.e. x64. For new projects the platforms used by Visual Studio are these:

  • A library project (including a test project) will have the Any CPU platform.
  • An executable project (including a WPF project) will have the x86 platform.

What is slightly confusing is that these platforms are just names hinting at what is actually built. You control what is emitted by the compiler in the Build tab of the project settings. Here you can set the Platform target to values like Any CPU, x86 or x64.

You will have to set the Platform target to x64 in your WPF project.

Visual Studio C# project settings

To fully configure your platforms you will have to use the Configuration Manager which is on the menu Build -> Configuration Manager.

like image 101
Martin Liversage Avatar answered Nov 05 '22 10:11

Martin Liversage


There is no such limitation. You can select target in Platform Target combobox on Build page of project properties

like image 25
Pavel Krymets Avatar answered Nov 05 '22 12:11

Pavel Krymets


The only x86 I wasn't able to change was the Platform, which to be honest I have no Idea what it is. but as you can see I can select x64 as the Platform target, are you sure you don't have such option?

enter image description here

like image 1
Slime recipe Avatar answered Nov 05 '22 10:11

Slime recipe


In the latest version of Visual Studio (at least 2019) in the project properties, in the build settings, there is an option for the platform target to prefer 32-bit.

enter image description here

You might want to uncheck it otherwise your app will run as x32 even on a x64 machine.

like image 1
Pic Mickael Avatar answered Nov 05 '22 12:11

Pic Mickael