[Mono-osx] MonoMac: ClassHandle issue

Duane Wandless duane at wandless.net
Sat Jul 10 10:04:07 EDT 2010

Here is a test case that shows the same issue I have with an Obj-C object.
 In my real app the MyViewController object is created in obj-c.  But this
test case shows the same issue.

using System;
using MonoMac.Foundation;
using MonoMac.AppKit;
using MonoMac.ObjCRuntime;

namespace monoMain
    public class myApp
        public static void Main()
                MyViewController sv = new MyViewController();
                Console.WriteLine("class handle {0}",
                Console.WriteLine("class name {0}", new
                Class kls = new Class("MyViewController");
                Console.WriteLine("kls handle {0}",
                Console.WriteLine("kls name {0}", kls.Name);

    public class MyViewController : NSViewController
        public MyViewController()  { }

In the output I get:
class handle a0625e70
class name NSViewController
kls handle d5dbc0
kls name MyViewController

The desired output is to have MyViewController returned in both cases.  If I
use NSView as the class it does work as expected.

I modified Class.cs to print out additional info:
Registering MyViewController : NSViewController / 0xa0625e70 0xd5dbc0
Console.WriteLine ("Registering {0} : {1} / 0x{2} 0x{3}", name, parent_name,
parent.ToString("x"), handle.ToString("x"));

So when the MyViewController is created it appears that its ClassHandle is
incorrectly set to its super class handle.  I did take it a step further and
created MyViewController2 : MyViewController.  And when sv.ClassHandle is
printed out it is NSViewController's handle.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20100710/e7e66be9/attachment.html 

More information about the Mono-osx mailing list