Call mono-2.0-sgen.dll with syscall got “not a valid Win32 application”What does int argc, char *argv[] mean?Creating OSX App bundle while embedding Mono in a Windows Forms projectNullReferenceExceptions while using latest mod_mono and xsp4Setup and Debugging of applications run under mod-mono-server4Use Mono for Windows in MonoDevelop for UnityTargeting the MONO Runtime causes Xamarin Build to failMono Application Compiled Under Linux Does Not Run in WindowsMono profiling: Perf syscall deniedXamarin iOS Linker fails on System.Net.Http.Primitives.dllWhat is the proper way to install Mono 4.4.2 on Android x86_64?C# Mono NLog Could not load file or assembly When Deployed to Raspberry PI
I caught several of my students plagiarizing. Could it be my fault as a teacher?
How can I close a gap between my fence and my neighbor's that's on his side of the property line?
If Melisandre foresaw another character closing blue eyes, why did she follow Stannis?
Why is Arya visibly scared in the library in S8E3?
What happens if I start too many background jobs?
Short story about people living in a different time streams
How to get SEEK accessing converted ID via view
How did Arya manage to disguise herself?
I’ve officially counted to infinity!
Floor tile layout process?
How can I fairly adjudicate the effects of height differences on ranged attacks?
Junior developer struggles: how to communicate with management?
How could a planet have most of its water in the atmosphere?
Selecting a secure PIN for building access
Can commander tax be proliferated?
Can a cyclic Amine form an Amide?
What was the state of the German rail system in 1944?
If Earth is tilted, why is Polaris always above the same spot?
How long can a 35mm film be used/stored before it starts to lose its quality after expiry?
Unidentified items in bicycle tube repair kit
Airbnb - host wants to reduce rooms, can we get refund?
What happened to Rhaegal?
Has any spacecraft ever had the ability to directly communicate with civilian air traffic control?
How to back up a running Linode server?
Call mono-2.0-sgen.dll with syscall got “not a valid Win32 application”
What does int argc, char *argv[] mean?Creating OSX App bundle while embedding Mono in a Windows Forms projectNullReferenceExceptions while using latest mod_mono and xsp4Setup and Debugging of applications run under mod-mono-server4Use Mono for Windows in MonoDevelop for UnityTargeting the MONO Runtime causes Xamarin Build to failMono Application Compiled Under Linux Does Not Run in WindowsMono profiling: Perf syscall deniedXamarin iOS Linker fails on System.Net.Http.Primitives.dllWhat is the proper way to install Mono 4.4.2 on Android x86_64?C# Mono NLog Could not load file or assembly When Deployed to Raspberry PI
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
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", `monolibmono4.5;C:DEVHelloWorldConsoleHelloWorldConsolebinDebug`)
_ = os.Setenv("MONO_CFG_DIR", `"C:Program Files (x86)Monoetc"`)
_ = os.Setenv("MONO_CONFIG", `"C:Program Files (x86)Monoetcmonoconfig"`)
mono := `C:Program Files (x86)Monobinmono-2.0-sgen.dll`
app := `C:DEVHelloWorldConsoleHelloWorldConsolebinDebugHelloWorldConsole.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
Full Error:
panic: Failed to load C:Program Files (x86)Monobinmono-2.0-sgen.dll: %1 is **not a valid Win32 application**.
go mono
add a comment |
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", `monolibmono4.5;C:DEVHelloWorldConsoleHelloWorldConsolebinDebug`)
_ = os.Setenv("MONO_CFG_DIR", `"C:Program Files (x86)Monoetc"`)
_ = os.Setenv("MONO_CONFIG", `"C:Program Files (x86)Monoetcmonoconfig"`)
mono := `C:Program Files (x86)Monobinmono-2.0-sgen.dll`
app := `C:DEVHelloWorldConsoleHelloWorldConsolebinDebugHelloWorldConsole.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
Full Error:
panic: Failed to load C:Program Files (x86)Monobinmono-2.0-sgen.dll: %1 is **not a valid Win32 application**.
go mono
Why not call mono.exe?
– muszeo
Mar 24 at 6:40
add a comment |
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", `monolibmono4.5;C:DEVHelloWorldConsoleHelloWorldConsolebinDebug`)
_ = os.Setenv("MONO_CFG_DIR", `"C:Program Files (x86)Monoetc"`)
_ = os.Setenv("MONO_CONFIG", `"C:Program Files (x86)Monoetcmonoconfig"`)
mono := `C:Program Files (x86)Monobinmono-2.0-sgen.dll`
app := `C:DEVHelloWorldConsoleHelloWorldConsolebinDebugHelloWorldConsole.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
Full Error:
panic: Failed to load C:Program Files (x86)Monobinmono-2.0-sgen.dll: %1 is **not a valid Win32 application**.
go mono
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", `monolibmono4.5;C:DEVHelloWorldConsoleHelloWorldConsolebinDebug`)
_ = os.Setenv("MONO_CFG_DIR", `"C:Program Files (x86)Monoetc"`)
_ = os.Setenv("MONO_CONFIG", `"C:Program Files (x86)Monoetcmonoconfig"`)
mono := `C:Program Files (x86)Monobinmono-2.0-sgen.dll`
app := `C:DEVHelloWorldConsoleHelloWorldConsolebinDebugHelloWorldConsole.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
Full Error:
panic: Failed to load C:Program Files (x86)Monobinmono-2.0-sgen.dll: %1 is **not a valid Win32 application**.
go mono
go mono
edited Mar 23 at 18:59
dhcgn
asked Mar 22 at 20:04
dhcgndhcgn
3,4492646
3,4492646
Why not call mono.exe?
– muszeo
Mar 24 at 6:40
add a comment |
Why not call mono.exe?
– muszeo
Mar 24 at 6:40
Why not call mono.exe?
– muszeo
Mar 24 at 6:40
Why not call mono.exe?
– muszeo
Mar 24 at 6:40
add a comment |
1 Answer
1
active
oldest
votes
%1 is not a valid Win32 application
The error %1 is not a valid Win32 application
is a discription of Win32 error code from windows itself.
The Win32 error code itself is 0x000000C1 ERROR_BAD_EXE_FORMAT
, see docs.microsoft.com.
BAD_EXE_FORMAT
means you call a x86 dll within a x64 process. You must use the x86 variant of Go, e.g. go1.12.1.windows-386.zip from https://golang.org/dl/.
Now must change the GOROOT and PATH to the extracted bin folder and then you are ready to go.
Type of Arguments
When you call mono_main
you need to consume the this function in the right way.
If you take an look at the implementation you see that the signature is int mono_main (int argc, char* argv[]);
. argc and argv is a widly used pattern, see here.
Working Sample
func main()
_ = os.Setenv("MONO_PATH", `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonolibmono4.5;C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debug`)
_ = os.Setenv("MONO_CFG_DIR", `C:DEVHelloWorhpm.goldConsoleHelloWorldConsolebinx86Debugmonoetc`)
_ = os.Setenv("MONO_CONFIG", `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonoetcmonoconfig`)
_ = os.Chdir(`C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debug`)
mono := `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonobinmono-2.0-sgen.dll`
// https://github.com/mono/mono/blob/c5b88ec4f323f2bdb7c7d0a595ece28dae66579c/mcs/tools/mkbundle/template_main.c#L1
dll := windows.NewLazySystemDLL(mono)
lazyProc := dll.NewProc("mono_main")
dotNetAssembly := []byte(`HelloWorldConsole.exe`)
var argummentData [260]byte
ptr := unsafe.Pointer(&argummentData)
copy(argummentData[:], dotNetAssembly)
args := [2]uintptr0, uintptr(ptr)
_, _, _ = lazyProc.Call(2, uintptr(unsafe.Pointer(&args)))
add a comment |
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307074%2fcall-mono-2-0-sgen-dll-with-syscall-got-not-a-valid-win32-application%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
%1 is not a valid Win32 application
The error %1 is not a valid Win32 application
is a discription of Win32 error code from windows itself.
The Win32 error code itself is 0x000000C1 ERROR_BAD_EXE_FORMAT
, see docs.microsoft.com.
BAD_EXE_FORMAT
means you call a x86 dll within a x64 process. You must use the x86 variant of Go, e.g. go1.12.1.windows-386.zip from https://golang.org/dl/.
Now must change the GOROOT and PATH to the extracted bin folder and then you are ready to go.
Type of Arguments
When you call mono_main
you need to consume the this function in the right way.
If you take an look at the implementation you see that the signature is int mono_main (int argc, char* argv[]);
. argc and argv is a widly used pattern, see here.
Working Sample
func main()
_ = os.Setenv("MONO_PATH", `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonolibmono4.5;C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debug`)
_ = os.Setenv("MONO_CFG_DIR", `C:DEVHelloWorhpm.goldConsoleHelloWorldConsolebinx86Debugmonoetc`)
_ = os.Setenv("MONO_CONFIG", `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonoetcmonoconfig`)
_ = os.Chdir(`C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debug`)
mono := `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonobinmono-2.0-sgen.dll`
// https://github.com/mono/mono/blob/c5b88ec4f323f2bdb7c7d0a595ece28dae66579c/mcs/tools/mkbundle/template_main.c#L1
dll := windows.NewLazySystemDLL(mono)
lazyProc := dll.NewProc("mono_main")
dotNetAssembly := []byte(`HelloWorldConsole.exe`)
var argummentData [260]byte
ptr := unsafe.Pointer(&argummentData)
copy(argummentData[:], dotNetAssembly)
args := [2]uintptr0, uintptr(ptr)
_, _, _ = lazyProc.Call(2, uintptr(unsafe.Pointer(&args)))
add a comment |
%1 is not a valid Win32 application
The error %1 is not a valid Win32 application
is a discription of Win32 error code from windows itself.
The Win32 error code itself is 0x000000C1 ERROR_BAD_EXE_FORMAT
, see docs.microsoft.com.
BAD_EXE_FORMAT
means you call a x86 dll within a x64 process. You must use the x86 variant of Go, e.g. go1.12.1.windows-386.zip from https://golang.org/dl/.
Now must change the GOROOT and PATH to the extracted bin folder and then you are ready to go.
Type of Arguments
When you call mono_main
you need to consume the this function in the right way.
If you take an look at the implementation you see that the signature is int mono_main (int argc, char* argv[]);
. argc and argv is a widly used pattern, see here.
Working Sample
func main()
_ = os.Setenv("MONO_PATH", `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonolibmono4.5;C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debug`)
_ = os.Setenv("MONO_CFG_DIR", `C:DEVHelloWorhpm.goldConsoleHelloWorldConsolebinx86Debugmonoetc`)
_ = os.Setenv("MONO_CONFIG", `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonoetcmonoconfig`)
_ = os.Chdir(`C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debug`)
mono := `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonobinmono-2.0-sgen.dll`
// https://github.com/mono/mono/blob/c5b88ec4f323f2bdb7c7d0a595ece28dae66579c/mcs/tools/mkbundle/template_main.c#L1
dll := windows.NewLazySystemDLL(mono)
lazyProc := dll.NewProc("mono_main")
dotNetAssembly := []byte(`HelloWorldConsole.exe`)
var argummentData [260]byte
ptr := unsafe.Pointer(&argummentData)
copy(argummentData[:], dotNetAssembly)
args := [2]uintptr0, uintptr(ptr)
_, _, _ = lazyProc.Call(2, uintptr(unsafe.Pointer(&args)))
add a comment |
%1 is not a valid Win32 application
The error %1 is not a valid Win32 application
is a discription of Win32 error code from windows itself.
The Win32 error code itself is 0x000000C1 ERROR_BAD_EXE_FORMAT
, see docs.microsoft.com.
BAD_EXE_FORMAT
means you call a x86 dll within a x64 process. You must use the x86 variant of Go, e.g. go1.12.1.windows-386.zip from https://golang.org/dl/.
Now must change the GOROOT and PATH to the extracted bin folder and then you are ready to go.
Type of Arguments
When you call mono_main
you need to consume the this function in the right way.
If you take an look at the implementation you see that the signature is int mono_main (int argc, char* argv[]);
. argc and argv is a widly used pattern, see here.
Working Sample
func main()
_ = os.Setenv("MONO_PATH", `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonolibmono4.5;C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debug`)
_ = os.Setenv("MONO_CFG_DIR", `C:DEVHelloWorhpm.goldConsoleHelloWorldConsolebinx86Debugmonoetc`)
_ = os.Setenv("MONO_CONFIG", `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonoetcmonoconfig`)
_ = os.Chdir(`C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debug`)
mono := `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonobinmono-2.0-sgen.dll`
// https://github.com/mono/mono/blob/c5b88ec4f323f2bdb7c7d0a595ece28dae66579c/mcs/tools/mkbundle/template_main.c#L1
dll := windows.NewLazySystemDLL(mono)
lazyProc := dll.NewProc("mono_main")
dotNetAssembly := []byte(`HelloWorldConsole.exe`)
var argummentData [260]byte
ptr := unsafe.Pointer(&argummentData)
copy(argummentData[:], dotNetAssembly)
args := [2]uintptr0, uintptr(ptr)
_, _, _ = lazyProc.Call(2, uintptr(unsafe.Pointer(&args)))
%1 is not a valid Win32 application
The error %1 is not a valid Win32 application
is a discription of Win32 error code from windows itself.
The Win32 error code itself is 0x000000C1 ERROR_BAD_EXE_FORMAT
, see docs.microsoft.com.
BAD_EXE_FORMAT
means you call a x86 dll within a x64 process. You must use the x86 variant of Go, e.g. go1.12.1.windows-386.zip from https://golang.org/dl/.
Now must change the GOROOT and PATH to the extracted bin folder and then you are ready to go.
Type of Arguments
When you call mono_main
you need to consume the this function in the right way.
If you take an look at the implementation you see that the signature is int mono_main (int argc, char* argv[]);
. argc and argv is a widly used pattern, see here.
Working Sample
func main()
_ = os.Setenv("MONO_PATH", `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonolibmono4.5;C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debug`)
_ = os.Setenv("MONO_CFG_DIR", `C:DEVHelloWorhpm.goldConsoleHelloWorldConsolebinx86Debugmonoetc`)
_ = os.Setenv("MONO_CONFIG", `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonoetcmonoconfig`)
_ = os.Chdir(`C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debug`)
mono := `C:DEVHelloWorldConsoleHelloWorldConsolebinx86Debugmonobinmono-2.0-sgen.dll`
// https://github.com/mono/mono/blob/c5b88ec4f323f2bdb7c7d0a595ece28dae66579c/mcs/tools/mkbundle/template_main.c#L1
dll := windows.NewLazySystemDLL(mono)
lazyProc := dll.NewProc("mono_main")
dotNetAssembly := []byte(`HelloWorldConsole.exe`)
var argummentData [260]byte
ptr := unsafe.Pointer(&argummentData)
copy(argummentData[:], dotNetAssembly)
args := [2]uintptr0, uintptr(ptr)
_, _, _ = lazyProc.Call(2, uintptr(unsafe.Pointer(&args)))
answered Mar 24 at 18:39
dhcgndhcgn
3,4492646
3,4492646
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55307074%2fcall-mono-2-0-sgen-dll-with-syscall-got-not-a-valid-win32-application%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Why not call mono.exe?
– muszeo
Mar 24 at 6:40