dongxie559554 2019-03-22 20:04
浏览 209
已采纳

用syscall调用mono-2.0-sgen.dll收到“不是有效的Win32应用程序”

I want to execute HelloWorldConsole.exe with an shipped Mono Framework through Go.

So I want to call mono-2.0-sgen.dll funtion "mono_main" to execute the exe. mono-2.0-sgen.dll is a PE32 executable for MS Windows, see.

But I get the error "not a valid Win32 application"

_ = os.Setenv("MONO_PATH", `\mono\lib\mono\4.5;C:\DEV\HelloWorldConsole\HelloWorldConsole\bin\Debug`)
_ = os.Setenv("MONO_CFG_DIR", `"C:\Program Files (x86)\Mono\etc"`)
_ = os.Setenv("MONO_CONFIG", `"C:\Program Files (x86)\Mono\etc\mono\config"`)

mono := `C:\Program Files (x86)\Mono\bin\mono-2.0-sgen.dll`
app := `C:\DEV\HelloWorldConsole\HelloWorldConsole\bin\Debug\HelloWorldConsole.exe`

fmt.Println("Execute")

var mod = syscall.NewLazyDLL(mono)
var proc = mod.NewProc("mono_main")

ret, _, _ := proc.Call(0,
    uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr("mono.exe"))),
    uintptr(unsafe.Pointer(syscall.StringToUTF16Ptr(app)))  )

Same behavior with windows.NewLazySystemDLL

dll := windows.NewLazySystemDLL(mono)
lazyProc := dll.NewProc("mono_main")
lazyProc.Call()

Function Name

mono-2.0-sgen.dll

Full Error:

panic: Failed to load C:\Program Files (x86)\Mono\bin\mono-2.0-sgen.dll: %1 is **not a valid Win32 application**.
  • 写回答

1条回答

      报告相同问题?

      相关推荐 更多相似问题

      悬赏问题

      • ¥15 Python Xpath对<em>标签的爬取结果变成了- -(关键词-Xpath)
      • ¥15 el-cascader懒加载模式选中单选框加载下层无数据问题
      • ¥15 promql 参数怎么忽视大小写查询
      • ¥50 swift使用textkit读取大文本文件速度慢的问题
      • ¥20 统信linux360企业浏览器 如何配置扩展程序?(图形界面我知道)
      • ¥100 c/c++实现DoubleArrayTrie
      • ¥30 关于#网络安全#的问题:非对称加密验证
      • ¥20 关于线性代数里施密特正交化和QR分解的疑问
      • ¥15 matlab超类包含解析错误
      • ¥15 python拖拽文件问题