mkbundle System.ComponentModel.Win32Exception 错误

mkbundle System.ComponentModel.Win32Exception error

我正在尝试捆绑我在 archlinux 上用 monodevelop 制作的应用程序。

在 monodevelop 中构建应用程序后,我将使用以下命令打包:

mkbundle --deps file.exe --static

但是输出是:

OS is: Linux
Note that statically linking the LGPL Mono runtime has more licensing restrictions than dynamically linking.
See http://www.mono-project.com/Licensing for details on licensing.
Sources: 1 Auto-dependencies: True
   embedding: /home/test/Test/Test/bin/Release/file.exe
   embedding: /usr/lib/mono/gac/gtk-sharp/2.12.0.0__35e10195dab3c99f/gtk-sharp.dll
 config from: /usr/lib/mono/gac/gtk-sharp/2.12.0.0__35e10195dab3c99f/gtk-sharp.dll.config
   embedding: /usr/lib/mono/4.5/mscorlib.dll
   embedding: /usr/lib/mono/gac/gdk-sharp/2.12.0.0__35e10195dab3c99f/gdk-sharp.dll
 config from: /usr/lib/mono/gac/gdk-sharp/2.12.0.0__35e10195dab3c99f/gdk-sharp.dll.config
   embedding: /usr/lib/mono/gac/glib-sharp/2.12.0.0__35e10195dab3c99f/glib-sharp.dll
 config from: /usr/lib/mono/gac/glib-sharp/2.12.0.0__35e10195dab3c99f/glib-sharp.dll.config
   embedding: /usr/lib/mono/gac/System/4.0.0.0__b77a5c561934e089/System.dll
   embedding: /usr/lib/mono/gac/Mono.Security/4.0.0.0__0738eb9f132ed756/Mono.Security.dll
   embedding: /usr/lib/mono/gac/System.Configuration/4.0.0.0__b03f5f7f11d50a3a/System.Configuration.dll
   embedding: /usr/lib/mono/gac/System.Xml/4.0.0.0__b77a5c561934e089/System.Xml.dll
   embedding: /usr/lib/mono/gac/System.Security/4.0.0.0__b03f5f7f11d50a3a/System.Security.dll
   embedding: /usr/lib/mono/gac/Mono.Cairo/4.0.0.0__0738eb9f132ed756/Mono.Cairo.dll
   embedding: /usr/lib/mono/gac/pango-sharp/2.12.0.0__35e10195dab3c99f/pango-sharp.dll
 config from: /usr/lib/mono/gac/pango-sharp/2.12.0.0__35e10195dab3c99f/pango-sharp.dll.config
   embedding: /usr/lib/mono/gac/atk-sharp/2.12.0.0__35e10195dab3c99f/atk-sharp.dll
 config from: /usr/lib/mono/gac/atk-sharp/2.12.0.0__35e10195dab3c99f/atk-sharp.dll.config
   embedding: /usr/lib/mono/gac/Mono.Posix/4.0.0.0__0738eb9f132ed756/Mono.Posix.dll
Compiling:
AS = as (default)
as -o temp.o temp.s 
as -o temp.o temp.s 

Unhandled Exception:
System.ComponentModel.Win32Exception: ApplicationName='cmd', CommandLine='/c "as -o temp.o temp.s "', CurrentDirectory='', Native error= Cannot find the specified file
  at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) <0x40c2f420 + 0x00637> in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.ComponentModel.Win32Exception: ApplicationName='cmd', CommandLine='/c "as -o temp.o temp.s "', CurrentDirectory='', Native error= Cannot find the specified file
  at System.Diagnostics.Process.Start_noshell (System.Diagnostics.ProcessStartInfo startInfo, System.Diagnostics.Process process) <0x40c2f420 + 0x00637> in <filename unknown>:0

因为我是静态链接单声道的,所以我必须从 AUR 安装单声道-git 以确保我拥有静态库。

我也不确定为什么它列出了两个 as -o temp.o temp.s

如有任何帮助,我们将不胜感激。

11 月 23 日编辑: 我刚刚再次确认 ascc 已经安装。版本输出位于:http://pastebin.com/ka25tjWZ

11 月 24 日编辑: 如已接受的答案中所述;我的单声道没有正确编译。 我使用带有以下 PKGBUILD 的 abs 进行重建,它现在按预期工作。

# $Id: PKGBUILD 246414 2015-09-16 21:25:15Z daniel $
# Maintainer: Daniel Isenmann <daniel@archlinux.org>
# Contributor: Brice Carpentier <brice@dlfp.org>

pkgname=mono
pkgver=4.0.4.1
_pkgver=4.0.4
pkgrel=1
pkgdesc="Free implementation of the .NET platform including runtime and compiler"
arch=(i686 x86_64)
license=('GPL' 'LGPL2.1' 'MPL' 'custom:MITX11')
url="http://www.mono-project.com/"
depends=('zlib' 'libgdiplus>=3.8' 'sh' 'python' 'ca-certificates')
options=('!makeflags' 'staticlibs')
provides=('monodoc')
conflicts=('monodoc')
source=(http://download.mono-project.com/sources/mono/${pkgname}-${pkgver}.tar.bz2
        mono.binfmt.d
        sgen_fix.patch
    build_fix.patch
    Microsoft.Portable.Common.targets
    fix-zlib-helper.patch)
md5sums=('f598b60a664dfebb1a5eef3e66a9a178'
         'b9ef8a65fea497acf176cca16c1e2402'
         '8a700b94bff7a913f920e95890d2fb4c'
         '30a5af1a4ff50b98f9e73cc2ae554115'
         'acbffadb0ac233c494b40dd5e79209a5'
         '62912ad289535bf841c140727e5c1165')
install="${pkgname}.install"

build() {
  cd "${srcdir}"/${pkgname}-${_pkgver}

  # build mono
  ./configure --prefix=/usr \
    --sysconfdir=/etc \
    --bindir=/usr/bin \
    --sbindir=/usr/bin \
    --disable-quiet-build \
    --disable-system-aot \
    --enable-static \
    --with-static_mono=yes \
    --with-mcs-docs=no 
  make

  # build jay
  cd "${srcdir}"/${pkgname}-${_pkgver}/mcs/jay
  make
}

package() {
  cd "${srcdir}"/${pkgname}-${_pkgver}
  make DESTDIR="${pkgdir}" install

  # install jay
  pushd "${srcdir}"/${pkgname}-${_pkgver}/mcs/jay
  make DESTDIR="${pkgdir}" prefix=/usr INSTALL=../../install-sh install
  popd

  # install binfmt conf file and pathes
  install -D -m644 "${srcdir}"/mono.binfmt.d "${pkgdir}"/usr/lib/binfmt.d/mono.conf

  #install license
  mkdir -p "${pkgdir}"/usr/share/licenses/${pkgname}
  install -m644 mcs/MIT.X11 "${pkgdir}"/usr/share/licenses/${pkgname}/

  #fix .pc file to be able to request mono on what it depends, fixes #go-oo build
  sed -i -e "s:#Requires:Requires:" "${pkgdir}"/usr/lib/pkgconfig/mono.pc
}

更新:

所以我 SSH 了一个朋友的 ArchLinux 并且 mkbundle 在那里工作正常,所以我回到了你的错误:

System.ComponentModel.Win32Exception: ApplicationName='cmd', CommandLine='/c "as -o temp.o temp.s "', CurrentDirectory='', Native error= Cannot find the specified file at System.Diagnostics.Process.Start_noshell

本来我以为你是在Windows因为这个错误,但你说Linux所以我无视了。我去了 mkbundle 的来源,我可以看到你的 ArchLinux 框 and/or Mono 安装没有正确地将 'IsUnix' 报告为 false,因此它不是通过 system 调用执行 AS cmd,而是试图使用 Windows' cmd 来执行它,因此失败了....

static bool IsUnix {
        get {
            int p = (int) Environment.OSVersion.Platform;
            return ((p == 4) || (p == 128) || (p == 6));
        }
    }

    static void Execute (string cmdLine)
    {
        if (IsUnix) {
            Console.WriteLine (cmdLine);
            int ret = system (cmdLine);
            if (ret != 0)
            {

同样,我可以访问的 ArchLinux 4.2.5-1 具有 Mono 4.0.4.1 并且按预期工作......

您的系统为每一行返回了什么?:

int p = (int) Environment.OSVersion.Platform;
var islinux = ((p == 4) || (p == 128) || (p == 6));

原文:

ENVIRONMENT VARIABLES

   AS     Assembler command. The default is "as".

   CC     C compiler command. The default is "cc" under Linux and "gcc" under
          Windows.

参考:man mkbundle

如果您自己构建单声道,这与您需要的要求相同,除了 temp.s 汇编代码外,它还会创建 temp.c 需要 c 编译器的文件。这是 load/execute 基于 CIL 的代码的 bootstrap 代码。

如果您的系统缺少汇编程序,有许多软件包可以满足要求,例如 binutils