Possible 64-bit operating system issues in C# deve

2020-01-29 08:36发布

问题:

I'm updating my operating system to Windows 7 x64, I only have experience with running 32-bit operating systems. Does anyone have any bad/good experiences with a 64 bit environment?

For reference, the tools I use are:

  • Visual Studio 2008
  • Tortoise SVN
  • TestDriven.Net
  • Oracle 10g XE
  • PL/SQL Developer
  • Dundas Chart
  • Analysis Services from MS SQL Server 2008

回答1:

Running on a 64-bit operating system has a number of side effects that will be noticeable to some extent. The most common issues:

  • Edit and Continue in Visual Studio won't work. You can fix this by forcing your .NET app to run in 32-bit mode. Project + Properties, Build tab, Platform Target = x86. Resolved in VS2013.

  • If you use any ActiveX controls or COM components in your .NET app you may find your program no longer works since your machine doesn't have a corresponding 64-bit version of the COM server. You'll get error 0x80040154, REGDB_E_CLASSNOTREG, "Class not registered". Same fix as above.

  • The 64-bit debugger doesn't support mixed-mode debugging, you'll have to commit to either Managed only or Native only debugging. Same fix as above, as long as you don't have 64-bit specific issues. Resolved in VS2010.

  • Poorly written P/Invoke declarations that declare an uint or int where an IntPtr is required will stop working in 64-bit mode. You'll generally get an AccessViolation exception or a failure return code. Or a PInvokeStackImbalance MDA warning. You should not have any trouble locating the mistake, just fix the declaration.

  • Several legacy end-of-life Microsoft libraries are not available in a 64-bit version. That's most commonly a problem with Microsoft Access databases. Same fix as above.

  • You must use the correct version of Regasm.exe to register [ComVisible] assemblies. Select the one from either Framework or Framework64, depending on whether the client program is going to run in 64-bit or 32-bit mode. Or both if you want the server to be available in either.

  • A few COM type libraries contain bit-ness dependent arguments in their method declarations. ADO 2.8 is a notable one. Be sure to use the correct bitness of Tlbimp.exe to generate the correct COM interop assembly, Visual Studio won't do this right. Same approach as Regasm.exe

  • A 32-bit program has a different view of the registry from a 64-bit program. Specifically the HKCR and HKLM\Software hives are virtualized. In Regedit.exe, the 32-bit visible keys are seen under the HKLM\Software\Wow6432Node key. This can cause many subtle problems with programs that use the registry. The .NET 4 RegistryKey.OpenBaseKey() allows specifying the view you want.

  • Again for COM, you'll have the use the correct bitness of Regsvr32.exe to register an unmanaged COM server (not .NET servers, they use Regasm.exe). Use the one in c:\windows\system32 for 64-bit servers, c:\windows\syswow64 for 32-bit servers.

  • Folders in the file system are virtualized, specifically c:\windows\system32 and c:\program files. A 32-bit program will see c:\windows\syswow64 and c:\program files (x86).

  • Installers need to take all the above issues in consideration.



回答2:

I wouldn't worry too much, if each program has an x64 download link, then use that. If not then your code will run through WOW64 emulation. And it will seem to you like it is running like normal.

Please see this related question I answered about 5 minutes ago.

WOW64 refers to windows32 on windows64 and it is a transparent emulation laywer that allows x86 programs to run on x64 operating systems. WOW64 will automatically be used if you run an x86 Windows program on an x64 Windows operating system.



回答3:

I am running Windows 7 Ultimate x64.

  1. Visual Studio 2008 works fine.
  2. I am using Subversion, but not Tortoise. AnkhSVN works fine.

The others I have no experience with.



回答4:

Majority of software I use has no issues with x64, it's been a few years since the XP x64 troubles, and people have caught up with x64 it seems.

The primary issue with development in x64 however, is when running in x64 mode in Visual Studio, you can not edit code while debugging.

You must use x86 as the target platform in order to do so.

This is one of the reasons one of the beta's for Visual Studio 2010 defaulted target platform to x32 instead of Any Platform...