Hello,

Good news. I am working on a patch for this, so you will be able to remove
this workaround when the new release is out.

Regards, Laurent Etiemble.

2008/8/18 Ben Martin <[EMAIL PROTECTED]>

>  Laurent,
>
> The work-around is working fine.  Here is my working code.
>
> [ObjectiveCMessage("openUntitledDocumentAndDisplay:error:")]
> public Id OpenUntitledDocumentAndDisplayErrorNew(bool displayDocument,
> IntPtr outError)
> {
>     // The outError parameter points to a native memory zone that waits for
> a NSError pointer
>     // Error will be initialized by the MakeUntitledDocumentOfTypeError
> call
>     NSError error = null;
>     Id oDocId = this.MakeUntitledDocumentOfTypeError("DocumentType", out
> error);
>     if (oDocId != null)
>     {
>         this.AddDocument(oDocId.CastTo<NSDocument>());
>
>         if (displayDocument)
>         {
>      oDocId.CastTo<NSDocument>().MakeWindowControllers();
>      oDocId.CastTo<NSDocument>().ShowWindows();
>     }
>     }
>     // Marshal back the pointer to Objective-C
>     Marshal.WriteIntPtr(outError, error.NativePointer);
>     return oDocId;
> }
>
>
>
> Regards,
>
>
>
> Ben Martin
>
>
>
> TruStorm Software
>
> http://www.trustorm.com.au
>
> 0407 256 072
>   ------------------------------
> *From:* [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf
> Of Laurent Etiemble [EMAIL PROTECTED]
> *Sent:* Saturday, 16 August 2008 11:38 PM
>
> *To:* users@lists.monobjc.net
> *Subject:* Re: [EMAIL PROTECTED] NSDocumentController
>
>   Hello,
>
> I have not forgotten your problem, but after some analysis, the problem
> seems serious enough to need a big patch in the proxy generator. Meanwhile,
> you can try the following untested work-around (I have put bold to
> emphasis):
>
> [ObjectiveCMessage("openUntitledDocumentAndDisplay:error:")]
> public override Id OpenUntitledDocumentAndDisplayError(bool
> displayDocument, *IntPtr* outError)
> {
>     *// The outError parameter points to a native memory zone that waits
> for a NSError pointer*
> *    // Error will be initialized by the MakeUntitledDocumentOfTypeError
> call*
> *    NSError error = null;*
>     Id oDocId = this.MakeUntitledDocumentOfTypeError("hpf", out outError);
>     this.NewDocument (oDocId);
>
>     if (displayDocument)
>     {
>         oDocId.CastTo<NSDocument>().MakeWindowControllers();
>         oDocId.CastTo<NSDocument>().ShowWindows();
>     }
>
> *    // Marshal back the pointer to Objective-C*
> *    Marshal.WriteIntPtr(outError, error.NativePointer);*
>
>     return oDocId;
> }
>
> Tell me if it solves your problem, while I am trying to get things fixed in
> the bridge.
>
> Regards, Laurent Etiemble
>
>
> 2008/8/8 Laurent Etiemble <[EMAIL PROTECTED]>
>
>> Hello,
>>
>> The unmarshalling of the NSError seems to be problematic (it has a
>> 'out' keyword). I will take a look at this.
>>
>> Regards, Laurent Etiemble.
>>
>>  2008/8/8 Ben Martin <[EMAIL PROTECTED]>:
>>  > I trying to override OpenUntitledDocumentAndDisplayError but I am get
>> the a exception when the method is called i.e it does not enter my method.
>> >
>> > Unhandled Exception: System.Reflection.TargetInvocationException:
>> Exception has been thrown by the target of an invocation. --->
>> System.InvalidProgramException: Invalid IL code in
>> Monobjc.Dynamic.Proxies.Mac.BaseDocumentController:OpenUntitledDocumentAndDisplayError_System_Boolean_Monobjc_Cocoa_NSError&
>> (intptr,intptr,bool,intptr): IL_000f: call      0x0a0001ec  at (wrapper
>> native-to-managed)
>> Monobjc.Dynamic.Proxies.Mac.BaseDocumentController:OpenUntitledDocumentAndDisplayError_System_Boolean_Monobjc_Cocoa_NSError&
>> (intptr,intptr,bool,intptr)
>> >  at (wrapper managed-to-native) Monobjc.Dynamic.Messaging.OBJC_MSGSEND
>> [System_Void]():objc_msgSend (intptr,intptr)
>> >  at (wrapper managed-to-native)
>> System.Reflection.MonoMethod:InternalInvoke (object,object[])
>> >  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
>> invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
>> System.Globalization.CultureInfo culture) [0x00000] --- End of inner
>> exception stack trace ---
>> >
>> >
>> > The code:
>> >
>> > [ObjectiveCMessage("openUntitledDocumentAndDisplay:error:")]
>> >        public override Id OpenUntitledDocumentAndDisplayError(bool
>> displayDocument, out NSError outError)
>> >        {
>> >            Id oDocId = this.MakeUntitledDocumentOfTypeError("hpf", out
>> outError);
>> >            this.NewDocument (oDocId);
>> >
>> >            if (displayDocument)
>> >            {
>> >                oDocId.CastTo<NSDocument>().MakeWindowControllers();
>> >                oDocId.CastTo<NSDocument>().ShowWindows();
>> >            }
>> >            return oDocId;
>> >        }
>> >
>> > Regards,
>> >
>> > Ben Martin
>> >
>> > TruStorm Software
>> > http://www.trustorm.com.au
>> > 0407 256 072
>> > ________________________________________
>> > From: Ben Martin [EMAIL PROTECTED]
>> > Sent: Monday, 4 August 2008 10:45 AM
>> > To: users@lists.monobjc.net
>> > Subject: RE: [EMAIL PROTECTED] NSDocumentController
>> >
>> > Hi Laurent,
>> >
>> > Thank you, the information helped.
>> >
>> > Regards,
>> >
>> > Ben Martin
>> >
>> > TruStorm Software
>> > http://www.trustorm.com.au
>> > 0407 256 072
>> > ________________________________________
>> > From: [EMAIL PROTECTED] [EMAIL PROTECTED] On Behalf
>> Of Laurent Etiemble [EMAIL PROTECTED]
>> > Sent: Wednesday, 30 July 2008 5:38 PM
>> > To: users@lists.monobjc.net
>> > Subject: Re: [EMAIL PROTECTED] NSDocumentController
>> >
>> > Hello,
>> >
>> > There is no such example in the Monobjc sample, but I am sure that you
>> > can find an example in Objective-C and port it to .NET. Be careful
>> > when overriding methods and calling super implementation (use Monobjc
>> > documentation to learn about it)
>> >
>> > Here are some useful links:
>> > -
>> http://developer.apple.com/documentation/Cocoa/Conceptual/Documents/Tasks/SubclassController.html
>> > - http://www.monobjc.net/index.php?page=exposing-net-class
>> > - http://www.monobjc.net/index.php?page=messaging
>> >
>> > Regards, Laurent Etiemble.
>> >
>> > 2008/7/30 Ben Martin <[EMAIL PROTECTED]>:
>> >> Hi,
>> >>
>> >> Is there any examples using a subclassed NSDocumentController with
>> Monobjc?
>> >>
>> >>
>> >>
>> >> Regards,
>> >>
>> >>
>> >>
>> >> Ben Martin
>> >>
>> >>
>> >>
>> >> TruStorm Software
>> >>
>> >> http://www.trustorm.com.au
>> >>
>> >> 0407 256 072
>> >
>>
>
>

Reply via email to