2014-10-30 77 views
0

我有一個非常簡單的程序:是否有可能在x86上強制啓動單聲道運行時?

using System; 

public class Program 
{ 
    public static void Main() 
    { 
     Console.WriteLine(IntPtr.Size); 
    } 
} 

讓我們從單聲道編譯器作爲應用程序的x86建立它,並在x64單運行:

$ uname -srvmpio ; lsb_release -d 
Linux 3.13.0-32-generiC#57-Ubuntu SMP Tue Jul 15 03:51:08 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux 
Description: Ubuntu 14.04.1 LTS 

$ mono --version 
Mono JIT compiler version 3.10.0 (tarball Mon Oct 27 14:33:41 IST 2014) 
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. www.mono-project.com 
     TLS:   __thread 
     SIGSEGV:  altstack 
     Notifications: epoll 
     Architecture: amd64 
     Disabled:  none 
     Misc:   softdebug 
     LLVM:   supported, not enabled. 
     GC:   sgen 

$ mcs -platform:x86 Program.cs 

$ mono Program.exe 
8 

單已成功推出該計劃。但它已經啓動了我的程序作爲一個x64應用程序。如果我使用Microsoft .NET Runtime在Windows上運行此二進制文件,則在控制檯輸出中會得到4(它將作爲x86應用程序運行)。那麼,是否有可能強制將單聲道運行時啓動爲x86?

回答

1

的-platform:86標誌是編譯器。它與單聲道運行時分配給程序的內存空間無關。如果你想運行64位的程序,你可以使用64位的單聲道運行時。如果你想運行32位的程序,你可以使用32位的單聲道運行時。

這個問題是這樣的Mono interop: Loading 32bit shared library does not work on my 64bit system

+0

重複順便說一句,我想指出的是,我花了大約一個小時看單源代碼,看看是否有可以幫助你。所以我不只是盲目地粘貼鏈接問題的答案並聲明重複。我其實看起來;) – Mystra007 2014-12-09 22:44:17

相關問題