Question about mixed managed/native code on x86-64

J

Jonathan Wilson

I have a dll (from a 3rd party) that is mixed native and managed code (32
bit x86 for the native part). I have an app written in C# and being
compiled with Visual C# Express 2008 (and targeting the .NET framework 2.0).
This app works fine on 32-bit windows (XP and Vista) but when run on
Windows x64, it will fail to run. Can someone tell me what project options
I need to set so that when the app is run on Windows Vista x64, it uses the
32 bit CLR and runs correctly.
 
J

Jeroen Mostert

Jonathan said:
I have a dll (from a 3rd party) that is mixed native and managed code
(32 bit x86 for the native part). I have an app written in C# and being
compiled with Visual C# Express 2008 (and targeting the .NET framework
2.0).
This app works fine on 32-bit windows (XP and Vista) but when run on
Windows x64, it will fail to run. Can someone tell me what project
options I need to set so that when the app is run on Windows Vista x64,
it uses the 32 bit CLR and runs correctly.

Your entry assembly (the .EXE) must be set to run as 32-bit to load 32-bit
DLLs successfully on a 64-bit Windows. From within Visual Studio, do this by
going to the project properties, picking the "Build" tab and changing
"Platform target" from "Any CPU" to "x86".

You can also do this without recompiling by using the corflags.exe utility
from the .NET 2.0 SDK.
 
J

Jeroen Mostert

Jonathan said:
I have a dll (from a 3rd party) that is mixed native and managed code
(32 bit x86 for the native part). I have an app written in C# and being
compiled with Visual C# Express 2008 (and targeting the .NET framework
2.0).
This app works fine on 32-bit windows (XP and Vista) but when run on
Windows x64, it will fail to run. Can someone tell me what project
options I need to set so that when the app is run on Windows Vista x64,
it uses the 32 bit CLR and runs correctly.

Your entry assembly (the .EXE) must be set to run as 32-bit to load 32-bit
DLLs successfully on a 64-bit Windows. From within Visual Studio, do this by
going to the project properties, picking the "Build" tab and changing
"Platform target" from "Any CPU" to "x86".

You can also do this without recompiling by using the corflags.exe utility
from the .NET 2.0 SDK.
 
A

Armin Zingler

Jonathan said:
I have a dll (from a 3rd party) that is mixed native and managed code
(32 bit x86 for the native part). I have an app written in C# and
being compiled with Visual C# Express 2008 (and targeting the .NET
framework 2.0). This app works fine on 32-bit windows (XP and Vista)
but when run on Windows x64, it will fail to run. Can someone tell me
what project options I need to set so that when the app is run on
Windows Vista x64, it uses the 32 bit CLR and runs correctly.

1. In the C# project, open the configuration manager (menu Build).
2. In the top right combo ("Active solution platform") select "new"
3. Select "x86" in the first combo.


Armin
 
A

Armin Zingler

Jonathan said:
I have a dll (from a 3rd party) that is mixed native and managed code
(32 bit x86 for the native part). I have an app written in C# and
being compiled with Visual C# Express 2008 (and targeting the .NET
framework 2.0). This app works fine on 32-bit windows (XP and Vista)
but when run on Windows x64, it will fail to run. Can someone tell me
what project options I need to set so that when the app is run on
Windows Vista x64, it uses the 32 bit CLR and runs correctly.

1. In the C# project, open the configuration manager (menu Build).
2. In the top right combo ("Active solution platform") select "new"
3. Select "x86" in the first combo.


Armin
 
F

Family Tree Mike

Jonathan Wilson said:
I have a dll (from a 3rd party) that is mixed native and managed code (32
bit x86 for the native part). I have an app written in C# and being
compiled with Visual C# Express 2008 (and targeting the .NET framework 2.0).
This app works fine on 32-bit windows (XP and Vista) but when run on
Windows x64, it will fail to run. Can someone tell me what project options
I need to set so that when the app is run on Windows Vista x64, it uses the
32 bit CLR and runs correctly.

1. Select "Build", then "Configuration Manager..."
2. At the top of the dialog is "Active solution platform:", which likely
says "Any CPU". On that dropdown, select "<New...>".
3. On the next dialog select "x86" for the new platform, copying settings
from "Any CPU".

Now you should be building your application to run in 32 bit mode regardless
of the OS (32/64 bit) that it is being run.
 
F

Family Tree Mike

Jonathan Wilson said:
I have a dll (from a 3rd party) that is mixed native and managed code (32
bit x86 for the native part). I have an app written in C# and being
compiled with Visual C# Express 2008 (and targeting the .NET framework 2.0).
This app works fine on 32-bit windows (XP and Vista) but when run on
Windows x64, it will fail to run. Can someone tell me what project options
I need to set so that when the app is run on Windows Vista x64, it uses the
32 bit CLR and runs correctly.

1. Select "Build", then "Configuration Manager..."
2. At the top of the dialog is "Active solution platform:", which likely
says "Any CPU". On that dropdown, select "<New...>".
3. On the next dialog select "x86" for the new platform, copying settings
from "Any CPU".

Now you should be building your application to run in 32 bit mode regardless
of the OS (32/64 bit) that it is being run.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top