tags:

views:

4250

answers:

7

How do I force my app to run 32 bit on the 64 bit machine? The code is written in C#.

+1  A: 

Assuming this is a Winforms, console app, or Windows service you have to build the exe for x86 instead of Any CPU. It's in the Configuration Manager.

JD Conley
+4  A: 

If you go to Configuration Manager in Visual Studio you can set the platform to x86 or x64.

+14  A: 

Right click your project, and select properties.

In properties, select the build tab. Under platform target, select x86.

Hit Ctrl+Shift+S to save all files, right click the solution and select "Clean" to get rid of old binaries. Any builds after that should be 32 bit

Matt Briggs
A: 

Can anyone tell me why my 32-bit app fails on 64-bit computers? How does the 64-bit computer run certain 32-bit machines with no issue, but it crashes running my program? He said it also happens with programs from smaller publishers. What do major publishers do to get this to work?

You could start by posting a question as a question, and not an answer.
Peter LaComb Jr.
A: 

When I said "he", I meant my friend. I sent my friend my 32-bit app and he has 64-bit Vista.

A: 

He's how I did it when we couldn't change the existing code from AnyCPU to x86 due to a Click-once limitation:

Create a 32bit 'Launcher' (x86 must be checked under project properties) application (Windows Application but not form):

    static void Main(string[] args)
    {
        // load the assembly    
        string directory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
        string assemblyName = Path.Combine(directory, "YourAnyCPUApplication.exe");
        Assembly assembly = Assembly.LoadFile(assemblyName);
        assembly.EntryPoint.Invoke(null, null);
    }

Add the following code to the Main method in the 'AnyCPU' project:

        if (IntPtr.Size == 4)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            // etc...
        }
        else
        {
            // Launch application in 32bit mode
            System.Diagnostics.Process.Start(Path.GetDirectoryName(Application.ExecutablePath) + @"\Your32BitApplicationLauncher.exe");
        }

Hope this helps :-)

Campbell

Campbell
+1  A: 

Command-line form:

corflags application.exe /32BIT+ 
alexdej