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

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-28 11:47:57

问题


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:


  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.



来源:https://stackoverflow.com/questions/52959418/asp-net-mvc-compiling-to-x64-versus-anycpu-for-64bit-difference

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!