Moving to 64 Bits: GUI for .NET and .NET Assemblies

Posted by Matt Gilarde on 10-Apr-2013 14:45

In my last post (Moving to 64 bits: DLLs and OCXs) I talked about issues that you may have to deal with due to the fact that the 64-bit client can't load 32-bit DLLs. Now I will discuss what you need to know about .NET assemblies if your application uses the GUI for .NET. Though .NET assemblies are also DLLs, for the purposes of this discussion when I say "DLL" I mean a library which was written in an unmanaged language such as C or C++. When I say ".NET assembly" I'm referring to .NET code written in a managed language such as C#.

A DLL can be built in two basic configurations: 32-bit (often referred to as x86) and 64-bit (x64). .NET assemblies can be built in three configurations: 32-bit (x86), 64-bit (x64), and Any CPU. If a .NET assembly is built as x86 it can only be used by a 32-bit process. Similarly, an x64 assembly can only be used by a 64-bit process. So far this is exactly how DLLs work.

The third configuration, Any CPU, is different. If an assembly is built for Any CPU it can be used by both 32-bit and 64-bit processes. This is possible because .NET assemblies don't contain native executable code. Instead, they (even the x86 and x64 ones) are compiled to an intermediate language which is known as CIL (Common Intermediate Language). At runtime the CIL is compiled to native machine code as it runs.

Since Any CPU can be used by both 32-bit and 64-bit processes, why would anyone choose the x86 or x64 configurations? One reason would be if the assembly relies on unmanaged code that is specific to one configuration. For example, if an assembly uses a 32-bit DLL to do some of its work, building the assembly as x86 may be required.

Don't worry if none of that made sense. What's important is whether the .NET assemblies you're using in your application will work with the 64-bit client. If you're only using classes from Microsoft (System.whatever) and Infragistics NetAdvantage, the answer is "Yes" because the Microsoft and Infragistics assemblies are Any CPU assemblies.

If you are using other third-party assemblies, odds are that they are also Any CPU, too. The easiest way to confirm that is to test them with the 64-bit client. If they work you are all set. If they don't, talk to the component vendor.

I could have just said "Your GUI for .NET application will probably just work with the 64-bit client" but where's the fun in that?

All Replies

This thread is closed