Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7911981
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T13:27:11+00:00 2026-06-03T13:27:11+00:00

I am trying to implement a method based on Cocoa’s – (void) alertDidEnd:(NSAlert *)alert

  • 0

I am trying to implement a method based on Cocoa’s

- (void) alertDidEnd:(NSAlert *)alert returnCode:(NSInteger)returnCode contextInfo:(void *)contextInfo;

The problem is the parameter of the type void*. I don’t know what the C# equivalent is for pointer to void.

I tried unsafe execution with “void*” but apparently that’s not the same. I also tried simply “void” but the C# compiler claims that void cannot be used as a parameter type.

Any ideas?

Error CS0123: A method or delegate `MyProgram.MainWindow.alertDidEnd(MonoMac.AppKit.NSAlert, int, MonoMac.Foundation.NSObject)' parameters do not match delegate `MonoMac.Foundation.NSAction()' parameters (CS0123)

Update (after problem was resolved):

These are the call and the method that made this work:

alert.BeginSheet ((NSWindow)sender, this, new Selector ("alertDidEnd:returnCode:contextInfo:"), IntPtr.Zero);


[Export("alertDidEnd:returnCode:contextInfo:")]
public void alertDidEnd (NSAlert alert, int result, IntPtr ci)
{}

The first is displaying the alert attached to the window, the second is the method declaration of the function called when the alert is dismissed. The result is stored in int result.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T13:27:13+00:00Added an answer on June 3, 2026 at 1:27 pm

    void* maps to IntPtr in .net:

    [Export("alertDidEnd:returnCode:contextInfo:")] 
    public void alertDidEnd (NSAlert alert, int returnCode, IntPtr contextInfo) 
    { 
        Console.WriteLine (returnCode); 
    }
    

    You can take a look here for a working example:

    https://github.com/picoe/Eto/blob/master/Source/Eto.Platform.Mac/Forms/MacModal.cs

    Also, it looks like from your error message that you should just use a plain parameterless method for whatever you’re using it with. NSAction is a delegate with no parameters.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to implement a delegate method for my Cocoa document-based application which
So I'm trying to learn how to implement method collection for a plugin based
I'm trying to implement method Find that searches the database. I forgot to mention
So I'm trying to implement the alterTime method from the EaseActionsTest example from the
I am trying to implement my own authentication method for AuthKit and am trying
I'm trying to implement a class in C# with a method that intercepts the
I'm trying to implement a filecopy method that can match the performance a copy
I'm trying to implement a DFT-based 8-band equalizer for the sole purpose of learning.
I'm trying to implement a method which returns a boost::filter_iterator pair (begin, end). I
I am trying to implement MVVM in a new project (based on WPF &

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.