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
David Browne - 21 Jun 2006 17:03 GMT
> Hello,
>
[quoted text clipped - 13 lines]
> 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
Thomas Krause - 22 Jun 2006 16:28 GMT
Interesting idea! I will try that.
Thanks for your help,
Thomas Krause
>> Hello,
>>
[quoted text clipped - 48 lines]
>
> David
Willy Denoyette [MVP] - 24 Jun 2006 13:00 GMT
Your application need to target X86 (/platform:x86 option in C#, linker
option /Machine:x86 for C++)
Willy.
| Hello,
|
[quoted text clipped - 16 lines]
| Thanks,
| Thomas Krause