views:

2580

answers:

11

Howdy,

We are getting new dev machines and moving up to Vista 64 Ultimate to take advantage of our 8gb ram. Our manager wants us to do all dev in 32bit virtual machines to make sure there will be no problems with our code moving into production.

Is there any way to guarantee the resultant programs will work on 32bit os's? I don't mind using virtual machines, but I don't like how they force you back into a "Single" monitor type view. I like moving my VS toolbars off to my other monitor.

EDIT: We are using Visual Studio 2005 and 2008, VB.NET and/or C#

EDIT: Using Harpreet's answer, these are the steps I used to set my Visual Studio IDE to compile x86 / 32bit:

  1. Click Build and open Configuration Manager
  2. Select Active Solution Platform drop down list
  3. Select x86 if it is in the list and skip to step 5, if not Select <New...>
  4. In the New Solution Platform dialog, select x86 and press OK
  5. Verify the selected platform for all of your projects is x86
  6. Click Close.

Enjoy.

Thank you, Keith

+1  A: 

Compiling for a 64bit OS is an option in the compiler. You can absolutely compile to a 32bit exe from within Vista 64 bit. When you run the app, you can then see in the TaskManager that there is a "*32" next to the process...this means it's 32bit ;)

I believe your managers need some more education on what 64bit OS really means :)

Adam Haile
+4  A: 

As long as you compile your executables as 32 bit, they will run on both 32 bit and 64 Windows machines (guaranteed). Using 64 dev machines has the advantage that you can start testing your code with 64 bit compilation (to check for things like pointers casted to 32 bit integers), this way making the transition to 64 bit easier in the future (should you your company choose to do a 64 bit version).

Cd-MaN
+1  A: 

Not an answer to your question, but possibly a solution to your problem: VirtualBox (and probably others) supports "seamless integration" mode, which just gives you a second start bar and lets you drag windows around freely.

Also, and this is an answer to your question, it depends on your compile settings. You can compile for different environments, and you can perfectly compile 32-bit programs on a 64-bit system with Visual Studio. Can't tell you how, but I'm sure some Visual Studio guru could help you out.

wvdschel
A: 

yeah, like adam was saying. There's 3 options: MSIL (default), x64, and x86. You can target x64 and it will generate dll's specifically for 64-bit systems, or you can do x86 which will run on 32-bit and 64-bit, but will have the same restrictions as 32-bit on a 64-bit system.

MSIL will basically let the JITer issue the platform specific instruction (at a slight performance penalty compared to a native image)

EDIT: no language, so i'm talking about .net framework languages like vb.net and c#, c++ is a completely different animal.

Darren Kopp
A: 

I agree with most of the answers given, and I don't see any major issues either.

Does anyone know if Microsoft has any documentation towards this question?

Keith

Keith Sirmons
+9  A: 

I do development on 64 bit machines for 32 bit Windows. It's not a problem. You should make sure that your projects are set to compile in x86 mode in order to be conservative. You'll want to go through each project in the solution and double check this. You could also use the AnyCPU setting but that's a little riskier since it will run differently on your dev machine than a 32 bit machine. You want to avoid the 64bit mode, of course.

The problems I've run into are drivers that don't work when the app is compiled for 64 bit (explicitly 64 bit or AnyCPU compiled and running on 64 bit Windows). Those problems are completely avoidable by sticking with x86 compilation. That should reveal all flaws on your dev machines.

Ideally, you could set up a build and test environment that could be executed against frequently on a 32 bit machine. That should reassure your management and let you avoid the VM as your desktop.

Harpreet
+1 for setting up a build and test environment in your target platform. If you're developing any software targeting a specific OS or version of an OS, you'd better have a copy of that OS installed somewhere so you can ensure it will work! If possible, it's good to use this box as a continuous integration server, so that your official builds and your official unit tests run in that environment.
Daniel Pryden
A: 

@Adam,

His managers happen to be correct for a few edge cases like virtual address space.

Don't knock it just because it sounds incredibly inconvenient.

Anyways, nothing prevents you from compiling on a 64-bit OS; the resulting .exe should be the same.

MSN

Mat Noguchi
+1  A: 

We develop a 32-bit application using VS 2005 (2008 soon) and have just purchased some new machines with XP Pro x64 or Vista Business 64-bit on them so that we can take advantage of the extra RAM whilst holding a watching brief on the possibility of doing a 64-bit port if it becomes commercially necessary to do so. We haven't had any problems with doing this other than tweaking some scripts in our development environment etc.

Those developers who weren't included in this upgrade cycle still use 32-bit machines, so these should pick up problems when the unit tests and the application test suite are run as a matter of course before a check-in.

What we also do is to make sure that we have a set of "test build" machines made up of "typical" configurations (XP/Vista, 2/4/8 cores, etc.) that build and test sets of check-ins - we have various different test suites for stability, performance, etc. - before they are added to the integration area proper. Again, these haven't picked up any problems with running a 32-bit application built on a 64-bit OS.

Anyway, as others have already said, I wouldn't expect it to be a problem because it's the compiler that generates the appropriate code for the target OS regardless of the OS that the compiler is actually running on.

Nick
A: 

@Mat Naguchi

His managers happen to be correct for a few edge cases like virtual address space.

Don't knock it just because it sounds incredibly inconvenient.

Understood and agreed, but what I meant was that they need to understand that a 64bit OS will also run 32bit apps. Also, he talked about the managers wanting them to do dev work on 32bit systems and didn't specify testing....I was making the assumption that even if they developed on a 64bit OS they would at least test on a 32bit OS before shipping...I would hope so anyway!

Adam Haile
A: 

Found this today:

http://www.brianpeek.com/blog/archive/2007/11/13/x64-development-with-net.aspx

x64 Development with .NET

Earlier this year I made the switch to a 64-bit operating system - Vista Ultimate x64 to be exact. For the most part, this process has been relatively painless, but there have been a few hiccups along the way (x64 compatible drivers, mainly, but that's not the point of this discussion).

In the world of x64 development, there have been a few struggling points that I thought I'd outline here. This list will likely grow, so expect future posts on the matter.

In the wonderful world of .NET development, applications and assemblies can be compiled to target various platforms. By default, applications and assemblies are compiled as Any CPU in Visual Studio. In this scenario, the CLR will load the assembly as whatever the default target is for the machine it is being executed on. For example, when running an executable on an x64 machine, it will be run as a 64-bit process.

Visual Studio also provides for 3 specific platform targets: x86, x64 and Itanium (IA-64). When building an executable as a specific target, it will be loaded as a process of that type. For example, an x86-targeted executable run on an x64 machine will run as a 32-bit process using the 32-bit CLR and WOW64 layer. When assemblies are loaded at runtime, they can only be loaded by a process if their target matches that of the hosting process, or it is compiled as Any CPU. For example, if x64 were set as the target for an assembly, it can only be loaded by an x64 process.

This has come into play in a few scenarios for me:

  • XNA - XNA is available as a set of 32-bit assemblies only. Therefore, when referencing the XNA assemblies, the executable/assembly using them must be targeted to the x86 platform. If it is targeted as x64 (or as Any CPU and run on a 64-bit machine), an error will be thrown when trying to load the XNA assemblies.

  • Microsoft Robotics Studio - The XInputGamepadService uses XNA internally to talk to the Xbox 360 controller. See above.

  • Managed DirectX - While this is already deprecated and being replaced with XNA, it still has its uses. The assemblies are not marked for a specific target, however I had difficulty with memory exceptions, especially with the Microsoft.DirectX.AudioVideoPlayback assembly.

  • Phidgets - Depending on what library you download and when, it may or may not be marked as 32-bit only. The current version (11/8/07) is marked as such, and so requires a 32-bit process to host it. The easiest way to determine if an executable or assembly is targeted to a specific platform is to use the corflags application. To use this, open a Visual Studio Command Prompt from your Start menu and run it against the assembly you wish to check.

The easiest way to determine if an executable or assembly is targeted to a specific platform is to use the corflags application. To use this, open a Visual Studio Command Prompt from your Start menu and run it against the assembly you wish to check.

Keith Sirmons
A: 

i'm encountering a compatibility problem using my vb.net application (32bit) on a 64 bit machine.

and if i change the debug from "any cpu" to x64 i can't debug , an error message appear " cannot start debugging, the assembly to be debugged was built with a platform incompatible with the current system".

coder
Turn this into it's own question.
Keith Sirmons