After Assigning new project to 64 bit in Configuration Manager, configuration was unsuccessful

Simon 346 Reputation points
2022-05-24T22:03:36.78+00:00

I built a new project and imported all the forms and codes from the previous project. In the menu Build, I assigned 64 bit in the Configuration Manager, and it's showing in the ribbon that the project is 64-bit.
However, when the codes run

If IntPtr.Size = 4 Then 'access

    ElseIf IntPtr.Size = 8 Then 'or sql

    End If

It is automatically selecting the IntPtr.Size=4, which proves that the project is still 32 bit.
How can I correct this problem?

Visual Studio
Visual Studio
A family of Microsoft suites of integrated development tools for building applications for Windows, the web and mobile devices.
5,359 questions
{count} votes

Accepted answer
  1. Anna Xiu-MSFT 30,791 Reputation points Microsoft Vendor
    2022-05-25T03:12:09.59+00:00

    Hi @Simon ,

    Welcome to Microsoft Q&A!

    Please uncheck the “Prefer 32-bit” by right-click on project properties > Build. Then, try again.

    Sincerely,
    Anna
    *
    If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.