[Mono-osx] MonoMac: ClassHandle issue

Miguel de Icaza miguel at novell.com
Sat Jul 10 11:56:56 EDT 2010


Hello Duane,

    Are you referencing monomac.dll, or are you compiling all its source
code directly into your app?

    This problem happens if you try to put the MonoMac source code into your
project, instead of keeping it as a separate assembly.

Miguel

On Sat, Jul 10, 2010 at 10:04 AM, Duane Wandless <duane at wandless.net> wrote:

> 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()
>         {
>                 NSApplication.Init();
>                 MyViewController sv = new MyViewController();
>                 Console.WriteLine("class handle {0}",
> sv.ClassHandle.ToString("x"));
>                 Console.WriteLine("class name {0}", new
> Class(sv.ClassHandle).Name);
>                 Class kls = new Class("MyViewController");
>                 Console.WriteLine("kls handle {0}",
> kls.Handle.ToString("x"));
>                 Console.WriteLine("kls name {0}", kls.Name);
>         }
>     }
>
>     [Register("MyViewController")]
>     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.
>
> Thanks,
> Duane
>
>
> _______________________________________________
> Mono-osx mailing list
> Mono-osx at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-osx
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-osx/attachments/20100710/beab5b72/attachment.html 


More information about the Mono-osx mailing list