System.InvalidCastException: Unable to cast object of type 'System.IntPtr' to type 'Gio.File[]'.
Closed this issue · 1 comments
nlogozzo commented
I have the following code, meant to implement Gio.ApplicationFlags.HandlesOpen
:
/// <summary>
/// Occurs when the application is opened via dbus
/// </summary>
/// <param name="sender">Gio.Application</param>
/// <param name="e">Gio.Application.OpenSignalArgs</param>
private void OnOpen(Gio.Application sender, Gio.Application.OpenSignalArgs e)
{
_mainWindowController.UrlToLaunch = e.Files[0].GetUri();
_application.Activate();
}
We are trying to open the app via dbus, passing a URL to the app:
#!/usr/bin/env python3
import dbus
if __name__ == "__main__":
bus = dbus.SessionBus()
proxy = bus.get_object(
"org.nickvision.tubeconverter", "/org/nickvision/tubeconverter"
)
open = proxy.get_dbus_method("Open", "org.freedesktop.Application")
open(["https://youtu.be/8eXj97stbG8"], {})
When this method hits, we get the error:
UnhandledException - unhandled exception: System.InvalidCastException: Unable to cast object of type 'System.IntPtr' to type 'Gio.File[]'.
at GObject.Value.Extract[T]()
at Gio.Application.OpenSignalArgs.get_Files()
at NickvisionTubeConverter.GNOME.Program.OnOpen(Application sender, OpenSignalArgs e) in /run/build/org.nickvision.tubeconverter/NickvisionTubeConverter.GNOME/Program.cs:line 122
at GObject.Signal`2.<>c__DisplayClass11_0.<Connect>b__0(Value returnValue, Value[] parameters)
at GObject.Closure.InternalCallback(IntPtr closure, IntPtr returnValuePtr, UInt32 nParamValues, ValueData[] paramValuesData, IntPtr invocationHint, IntPtr userData)
How should we be handling this correctly?