<HTML><HEAD><STYLE media="all" type="text/css">         #sig {                 /* Typography */                 color: black;                 font-size: 9pt;                 font-family: Arial, Verdana, sans-serif;                 background-color: #FFFCF6;                 line-height: 15px;                 margin: 6px 0;                 padding: 6px;                 border-top: 1px #999999 dotted;                 border-bottom: 1px #999999 dotted;         }         #sig .row2 {                                 margin-top: 0px;                 margin-bottom: -8px;         }         #sig .row a:link, #sig .row a:visited {                 color: #511a06;                 text-decoration: underline;                 border-bottom: none;         }         #sig .row a:hover {                 color: #c20e0a;                 text-decoration: none;         } </STYLE></HEAD><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; ">Ok, I apologize for the recent flood of emails, but i've been trying to tie some complex Cocoa and C# together recently.<DIV><BR class="khtml-block-placeholder"></DIV><DIV>Singletons)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>There seems to be no reasonable means of implementing a singleton DBMonoObjectRepresentation as it stands now with Dumbarton. My C# singleton is relatively "traditional" in that it has a private constructor, and a static Iinstance property (i..e Object.Instance.ExecuteMethod()). Implementing a Cocoa singleton isn't hard, but initWithSignature and initWithMonoObject aren't exactly suitable. I attempted (in vain of course) to use getProperty to return a MonoObject to initWithMonoObject, which requires an instantiated DBMonoObjectRepresentation to function (d'oh). </DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>I had another property, and I found that if I used [[SingletonObject sharedObject] property]; it would call my default constructor, regardless of the private modifier (!).</DIV><DIV> Whereas the code would be:</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>- (NSString *)property</DIV><DIV>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>MonoString *monoString = (MonoString*)[self getProperty:"someproperty"];</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>return [NSString stringWithMonoString:monoString];</DIV><DIV>}</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>#pragma mark "Singelton Methods"</DIV><DIV>+ (SingletonObject *)sharedObject</DIV><DIV>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>@synchronized(self)</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>if (instance == nil)</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>instance = [[self alloc] init];</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>}</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>}</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>return instance;</DIV><DIV>}</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>And the C# code is somewhere along the lines of :</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>public static SingletonObject Instance</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>get </DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>lock(internalLock)</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>if (instance == null)</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>instance = new SingletonObject();</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>Console.WriteLine("Calling Instance Property");<SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>return instance;</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>}</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>}</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>}<SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>public string someproperty { get { return m_SomeProperty; } }</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>private SingletonObject()</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>m_SomeProperty = this.GeneratePath();</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>}</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Dumbarton would violate the access modifier for the constructor, and call it, and then when I would call the property method in my Cocoa code, it'd function as expected. This seems like a subtle bug, or is it something that is "allowed" within the constraints of the Mono embedded runtime?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Statics)</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>As far as I can tell there's not really a feasible way to call static methods through the Dumbarton bridge i.e. I cannot write:</DIV><DIV>Cocoa:</DIV><DIV>+ (NSString *)getStringFromCSharp</DIV><DIV>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>MonoString *monoString = (MonoString*)[DBClass invokeStaticMethod:"returnString" withNumArgs:0]];</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>return [NSString stringWithMonoString:monoString];</DIV><DIV>}</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>C#:</DIV><DIV>public static string returnString()</DIV><DIV>{</DIV><DIV><SPAN class="Apple-tab-span" style="white-space:pre">        </SPAN>return "OMFG!";</DIV><DIV>}</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>I've been looking through the embedding Mono examples to see if there's a good means of doing so with the embedded runtime but from the best that I can tell, almost all the calls require an instatiated MonoObject before invoking a method.</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>It seems like having statics would fix my problem with singletons immediately, is there a piece of the puzzle I'm not seeing?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>If not, any pointers on where I could look to add this functionality to the bridge?</DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV><BR class="khtml-block-placeholder"></DIV><DIV>Cheers</DIV><DIV><BR><DIV> <DIV id="sig">         <DIV class="row">                 <STRONG>R. Tyler Ballance</STRONG>: Custom Mac and Linux Development at <A href="http://www.bleepconsulting.com">bleep. consulting</A>                 <BR>                 contact: <A href="mailto:tyler@bleepconsulting.com">tyler@bleepconsulting.com</A> | jabber: <A href="jabber:tyler@jabber.geekisp.com">tyler@jabber.geekisp.com</A>         </DIV>         <DIV class="row2">                 <A href="http://www.bleepconsulting.com" title="visit bleepconsulting.com"><IMG src="http://bleepconsulting.com/images/bleep_consulting_small.png" border="0"></A>         </DIV> </DIV> </DIV><BR></DIV></BODY></HTML>