Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why can we change the platform in .NET project settings when it is platform independent?

Tags:

c#

.net

clr

wpf

I am working with visual studio 2010, .NET 4.0 and WPF. We are trying to build the project with platform as "AnyCPU" which will make the program platform neutral. In the middle of doing so I started confusing myself.

I thought all the .NET programs target .NET framework instead of the operating system. If that is the case I should not worry about whether I am working on a "x64" or "x86" system. All that program target is .NET framework which is a proper "Run Time" which will take care of itself. The CLR can allocate memory according to the platform it is sitting on, but the .NET projects shouldnt worry about that.

What am I missing here? What is the point of "platform " in build settings in .NET projects?

like image 811
Jimmy Avatar asked Jan 17 '23 15:01

Jimmy


1 Answers

One common reason to restrict yourself to one architecture is that you use native libraries that only support one platform.

For example in one of my projects I included libvorbis and I was too lazy to compile a 64 bit version of it. So I just set my project to 32 bit only. Some other native libraries might not support 64 bits at all, especially if they are closed source legacy components.

like image 106
CodesInChaos Avatar answered Jan 21 '23 10:01

CodesInChaos