Search code examples
c#wpfvisual-studioentity-framework-4

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?


Solution

  • 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.