简体   繁体   中英

ASP.NET MVC; compiling to x64 versus anyCPU for 64bit, difference?

I am running Visual Studio 2017, ASP.NET 4.7 and MVC 5, for developing against IIS Express and Azure App Services.

It is currently 32bit. I want to convert it to 64bit

I see 2 options:

  1. Explicitly setting x64 in the Solution's configuration via the "Active" tab.

  2. Explicitly setting AnyCPU in the Solution's configuration via the "Active tab.

I have set IIS Express to 64bit and will have set the Azure App Service instance to 64bit.

I have a feeling that 2) is best practice since the web server target bitness will be picked up.

There may be a few third party 32bit dlls in use if this makes a difference.

Thanks.

  1. If your project is only using Managed DLL or Nuget package then Any CPU would be fine. AnyCPU means at runtime it will decide 64bit or 32bit based on your CPU bitness.

  2. Now if you explicitly want to tell that your program should run in 32bit mode or 64bit mode then you have to choose that specific profile.

    For example : I am using unmanaged DLL and that is specially written for 64bit then AnyCPU will create problem as it is not decided at compile time. Same goes for 32bit as well. Here we explicitly try to tell that it must run in specific bit ness profile.

  3. At IIS Level too this configuration available like you can set 32bit dll to run at App Pool Level.

Update after comment.

  1. If you look for 32bit instance for App Service then there are only few. Free and Shared. Most of all are 64bit.

Note: 1. In real life too I have faced such issue in which azure app depends on 32bit and our tier was 64bit. 2. If you go bit ahead and choose VM then you will get all option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM