Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / CLR / June 2006

Tip: Looking for answers? Try searching our database.

Forcing x86 runtime on x64 system

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Thomas Krause - 21 Jun 2006 14:02 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.