[Kde-bindings] Qyoto DBUS

Arno Rehn arno at arnorehn.de
Wed Jan 10 14:15:49 UTC 2007


I have added most of the marshallers by now, I think, and the ones we need for 
getting dbus to work are also complete. I've again tried to get the listnames 
example to work, but as before it fails when we try to call get the session 
bus via SessionBus() - it doesn't return a real object.

I tried it with the code from Richard:
using Qyoto;
using System;

class ListNames {

	public static void method2()
		QDBusConnection bus = QDBusConnection.SessionBus();
		QDBusInterface dbus_iface = new 
QDBusInterface("org.freedesktop.DBus", "/org/freedesktop/DBus",
								"org.freedesktop.DBus", bus);
		QDBusMessage result = dbus_iface.Call("ListNames");
		QDBusMessage.MessageType mess = result.type();
	public static int Main(string[] args) {
        	new QCoreApplication(args);
		if (!QDBusConnection.SessionBus().IsConnected()) {
			Console.WriteLine("Cannot connect to the D-BUS session bus.\n" +
				"To start it, run:\n" +
				"\teval `dbus-launch --auto-syntax`\n");
			return 1;
		return 0;

The line 
if (!QDBusConnection.SessionBus().IsConnected()) {
gives the error
Unhandled Exception: System.NullReferenceException: Object reference not set 
to an instance of an object
  at ListNames.Main (System.String[] args) [0x00000]

I don't really know what goes wrong here, other static methods do work well.
Any ideas?

Arno Rehn
arno at arnorehn.de

More information about the Kde-bindings mailing list