-
I'm trying figure out how to properly use sidecar to run tauri with a console app building by c#. async function greet() {
// Learn more about Tauri commands at https://tauri.app/v1/guides/features/command
setGreetMsg(await invoke("greet", { name }));
const command = Command.sidecar("console/MyConsoleApp", ["-l"])
const output = await command.execute();
console.log(output); // Get `Uncaught (in promise) invalid utf-8 sequence of 1 bytes from index 2`
} Then i try execute sidecar in rust, and it will be four times let (mut rx, _) = Command::new_sidecar("MyConsoleApp")
.expect("failed to create `MyConsoleApp` binary command")
.args(["-l"])
.spawn()
.expect("Failed to spawn sidecar");
tauri::async_runtime::spawn(async move {
while let Some(event) = rx.recv().await {
if let CommandEvent::Stdout(message) = event {
println!("{}", message);
} else {
println!("Failed to execute sidecar");
}
}
}); So am i did anything wrong? How to properly using sidecar with a console app? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 1 reply
-
I guess you should use some like new_sidecar(...).encoding(..).spawn(..), but I am still quite not sure the correct answer |
Beta Was this translation helpful? Give feedback.
-
I have asked an issue [bug] Always get Uncaught (in promise) invalid utf-8 sequence of 1 bytes from index 2 with sidecar and figured out why. |
Beta Was this translation helpful? Give feedback.
I have asked an issue [bug] Always get Uncaught (in promise) invalid utf-8 sequence of 1 bytes from index 2 with sidecar and figured out why.
The problem is the console app cannot correctly load the dll specific in tauri->bundle->resources.
So the solution is quite simply, bundle all your assemblies like dll to your console app will fix it.
If you are using c# .net framework to build your console app and have the same issue, strongly recommend to use Costura.Fody. For more detail, check this Embedding DLLs in a compiled executable