HighTechTalks DotNet Forums  

Forcing x86 runtime on x64 system

Dotnet Framework (CLR) microsoft.public.dotnet.framework.clr


Discuss Forcing x86 runtime on x64 system in the Dotnet Framework (CLR) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Thomas Krause
 
Posts: n/a

Default Forcing x86 runtime on x64 system - 06-21-2006 , 09:02 AM






Hello,

I have the following problem:

I have a .net 2.0 application, which dynamically loads a Managed C++
assembly. The managed c++ assembly has the ProcessorArchitecture correctly
set to x86 (32 Bit). The application however does not have the 32Bit-Corflag
set and is therefore loaded by the x64 version of the .net framework runtime
(64 Bit). So when the application tries to load the Managed C++ assembly I
get an exception, because it cannot use the 32 Bit managed C++ assembly in
the 64 Bit application.

So I need a way to force the os to load an assembly with the 32 Bit runtime
and not the 64 Bit runtime. I know that I can use the "corflags" application
in the SDK to set the 32Bit-Flag, but since the application is a strong
signed 3rd party application it does not allow me to do this (and since I
don't have the source code I cannot recompile it either).

Thanks,
Thomas Krause


Reply With Quote
  #2  
Old   
David Browne
 
Posts: n/a

Default Re: Forcing x86 runtime on x64 system - 06-21-2006 , 12:03 PM







"Thomas Krause" <Forum.Thomas.Krause-NoSpam- (AT) gmx (DOT) de> wrote

Quote:
Hello,

I have the following problem:

I have a .net 2.0 application, which dynamically loads a Managed C++
assembly. The managed c++ assembly has the ProcessorArchitecture correctly
set to x86 (32 Bit). The application however does not have the
32Bit-Corflag set and is therefore loaded by the x64 version of the .net
framework runtime (64 Bit). So when the application tries to load the
Managed C++ assembly I get an exception, because it cannot use the 32 Bit
managed C++ assembly in the 64 Bit application.

So I need a way to force the os to load an assembly with the 32 Bit
runtime and not the 64 Bit runtime. I know that I can use the "corflags"
application in the SDK to set the 32Bit-Flag, but since the application is
a strong signed 3rd party application it does not allow me to do this (and
since I don't have the source code I cannot recompile it either).

The only way I know to do this is to build your own launcher application,
load the 3rd party application assembly and run its main method.

EG
Compile the following with x86 target:


using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Reflection;

namespace Run32bit
{
class Program
{
static void Main(string[] args)
{
try
{
string target = @"c:\program files\Whatever\whatever.exe";
Assembly target = Assembly.LoadFile(target);
target.EntryPoint.Invoke(null, new object[] { args });
}
catch (Exception ex)
{
Console.WriteLine(ex);
}


}
}
}



David



Reply With Quote
  #3  
Old   
Thomas Krause
 
Posts: n/a

Default Re: Forcing x86 runtime on x64 system - 06-22-2006 , 11:28 AM



Interesting idea! I will try that.

Thanks for your help,
Thomas Krause

"David Browne" <davidbaxterbrowne no potted meat (AT) hotmail (DOT) com> wrote:
Quote:
"Thomas Krause" <Forum.Thomas.Krause-NoSpam- (AT) gmx (DOT) de> wrote:
Hello,

I have the following problem:

I have a .net 2.0 application, which dynamically loads a Managed C++
assembly. The managed c++ assembly has the ProcessorArchitecture
correctly set to x86 (32 Bit). The application however does not have the
32Bit-Corflag set and is therefore loaded by the x64 version of the .net
framework runtime (64 Bit). So when the application tries to load the
Managed C++ assembly I get an exception, because it cannot use the 32 Bit
managed C++ assembly in the 64 Bit application.

So I need a way to force the os to load an assembly with the 32 Bit
runtime and not the 64 Bit runtime. I know that I can use the "corflags"
application in the SDK to set the 32Bit-Flag, but since the application
is a strong signed 3rd party application it does not allow me to do this
(and since I don't have the source code I cannot recompile it either).


The only way I know to do this is to build your own launcher application,
load the 3rd party application assembly and run its main method.

EG
Compile the following with x86 target:


using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Reflection;

namespace Run32bit
{
class Program
{
static void Main(string[] args)
{
try
{
string target = @"c:\program files\Whatever\whatever.exe";
Assembly target = Assembly.LoadFile(target);
target.EntryPoint.Invoke(null, new object[] { args });
}
catch (Exception ex)
{
Console.WriteLine(ex);
}


}
}
}



David



Reply With Quote
  #4  
Old   
Willy Denoyette [MVP]
 
Posts: n/a

Default Re: Forcing x86 runtime on x64 system - 06-24-2006 , 08:00 AM



Your application need to target X86 (/platform:x86 option in C#, linker
option /Machine:x86 for C++)

Willy.

"Thomas Krause" <Forum.Thomas.Krause-NoSpam- (AT) gmx (DOT) de> wrote

Quote:
Hello,

I have the following problem:

I have a .net 2.0 application, which dynamically loads a Managed C++
assembly. The managed c++ assembly has the ProcessorArchitecture correctly
set to x86 (32 Bit). The application however does not have the
32Bit-Corflag
set and is therefore loaded by the x64 version of the .net framework
runtime
(64 Bit). So when the application tries to load the Managed C++ assembly I
get an exception, because it cannot use the 32 Bit managed C++ assembly in
the 64 Bit application.

So I need a way to force the os to load an assembly with the 32 Bit
runtime
and not the 64 Bit runtime. I know that I can use the "corflags"
application
in the SDK to set the 32Bit-Flag, but since the application is a strong
signed 3rd party application it does not allow me to do this (and since I
don't have the source code I cannot recompile it either).

Thanks,
Thomas Krause




Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.