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 5943705
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T16:26:01+00:00 2026-05-22T16:26:01+00:00

I totally do NOT understand why MonoTouch is crashing on this code. Let me

  • 0

I totally do NOT understand why MonoTouch is crashing on this code. Let me outline my steps to get to this point:

  1. New Project
  2. New > iPhone View with Controller (called TestScreen)
  3. In Main.cs, added: window.AddSubview(new TestScreen().View);
  4. Added button to the TestScreen UIView, and added an outlet called testButton on ‘File’s Owner’ (which should be my TestScreen controller), and linked up the button to that outlet.

Then, I added the following code:

public override void ViewDidLoad ()
        {
            base.ViewDidLoad ();

            this.testButton.SetTitle("Test", UIControlState.Normal); // this works!
            this.testButton.TouchUpInside += HandleTestButtonhandleTouchUpInside;
        }

        int i = 0;
        void HandleTestButtonhandleTouchUpInside (object sender, EventArgs e)
        {
            i += 1;
            this.testButton.SetTitle("Testing " + i.ToString(), UIControlState.Normal); // this crashes!
        }

Question is: Why does the this.testButton.SetTitle() method cause a crash?

Here’s the application output at time of crash:

Stacktrace:

at (wrapper managed-to-native)
MonoTouch.UIKit.UIApplication.UIApplicationMain
(int,string[],intptr,intptr) at
MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00038]
in /Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:26
at MonoTouch.UIKit.UIApplication.Main (string[]) [0x00000] in
/Users/plasma/Source/iphone/monotouch/UIKit/UIApplication.cs:31 at
MyApp.Application.Main (string[]) [0x00000] in
/Users/username/Projects/MyApp/MyApp/Main.cs:14 at (wrapper
runtime-invoke) .runtime_invoke_void_object
(object,intptr,intptr,intptr)

Native stacktrace:

0   MyApp               0x000d1965 mono_handle_native_sigsegv + 343
1   MyApp               0x0000ffb4 mono_sigsegv_signal_handler + 322
2   libSystem.B.dylib                   0x9476845b _sigtramp + 43
3   ???                                 0xffffffff 0x0 + 4294967295
4   UIKit                               0x01c981b5 -[UIControl sendAction:to:forEvent:] + 67
5   UIKit                               0x01c9a647 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
6   UIKit                               0x01c991f4 -[UIControl touchesEnded:withEvent:] + 458
7   UIKit                               0x01c2e0d1 -[UIWindow _sendTouchesForEvent:] + 567
8   UIKit                               0x01c0f37a -[UIApplication sendEvent:] + 447
9   UIKit                               0x01c14732 _UIApplicationHandleEvent + 7576
10  GraphicsServices                    0x03edfa36 PurpleEventCallback + 1550
11  CoreFoundation                      0x00e21064 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
12  CoreFoundation                      0x00d816f7 __CFRunLoopDoSource1 + 215
13  CoreFoundation                      0x00d7e983 __CFRunLoopRun + 979
14  CoreFoundation                      0x00d7e240 CFRunLoopRunSpecific + 208
15  CoreFoundation                      0x00d7e161 CFRunLoopRunInMode + 97
16  GraphicsServices                    0x03ede268 GSEventRunModal + 217
17  GraphicsServices                    0x03ede32d GSEventRun + 115
18  UIKit                               0x01c1842e UIApplicationMain + 1160
19  ???                                 0x09a7714b 0x0 + 161968459
20  ???                                 0x09a76f1c 0x0 + 161967900
21  ???                                 0x09a7651c 0x0 + 161965340
22  ???                                 0x09a76374 0x0 + 161964916
23  ???                                 0x09a764c6 0x0 + 161965254
24  MyApp               0x0000fd6f mono_jit_runtime_invoke + 1332
25  MyApp               0x001ee239 mono_runtime_invoke + 137
26  MyApp               0x001f0920 mono_runtime_exec_main + 669
27  MyApp               0x001efd0a mono_runtime_run_main + 843
28  MyApp               0x000a3c62 mono_jit_exec + 200
29  MyApp               0x002a25eb main + 3838
30  MyApp               0x000030c9 _start + 208
31  MyApp               0x00002ff8 start + 40

Debug info from gdb:

/tmp/mono-gdb-commands.DGcT7h:1: Error in sourced command file: unable
to debug self

================================================================= Got a SIGSEGV while executing native code. This usually indicates a fatal
error in the mono runtime or one of the native libraries used by your
application.

  • 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-05-22T16:26:02+00:00Added an answer on May 22, 2026 at 4:26 pm

    The error turned out to be in my Step 3.

    My new TestScreen() was going out of scope and getting disposed for some reason. Assigned it to a variable and then passed in variable to AddSubview() and that fixed it.

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

Sidebar

Related Questions

I'm still not sure I totally get how this particular case should work out.
This question may be redundant, but i could not totally understand how to do
ok desperation. This is killing me.. I totally do not understand MapKit at all..
Accept my early apologies as totally new to this so my terminology may not
Are there any good books for a relatively new but not totally new *nix
Okay, I feel totally stupid posting this. I am not sure if it is
I kind of understand what's retain counts for. But not totally. I looked on
I totally understand the purpose of arrays, yet I do not feel I have
I don't totally understand how all this works, but I'm getting this error: Fatal
I'm not totally convinced this is possible, but here goes. I have a method

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.