Troubleshoot

From $1
Table of contents

  1. 1. How do I create outlets or actions with Interface Builder?
  2. 2. System.Text.Encoding.GetEncoding throws NotSupportedException
  3. 3. System.MissingMethodException (anything else)
  4. 4. You are getting a ModelNotImplementedException
  5. 5. This class is not key value coding-compliant for the key XXXX
  6. 6. Unknown class XXXX in Interface Builder file
  7. 7. System.MissingMethodException: No constructor found for Foo.Bar::ctor(System.IntPtr)
  8. 8. Type {Foo} does not contain a definition for `GetNativeField' and no extension method `GetNativeField' of type {Foo} could be found
  9. 9. Object {Foo} of class NSConcreteData autoreleased with no pool in place - just leaking
  10. 10. Warning for actions: The private method 'Foo' is never used. (CS0169)
  11. 11. mtouch failed with the following message: Cannot open assembly '/path/to/yourproject.exe'
  12. 12. Your sqlite3 version is old - please upgrade to at least v3.5.0!
  13. 13. Deploy to device fails with System.Exception: AMDeviceInstallApplication returned 3892346901
  14. 14. Code Completion is not working in MonoDevelop
  15. 15. MonoDevelop crashes when you copy text
  16. 16. MonoDevelop complains about Mono 2.4 required
  17. 17. Assertion at ../../../../mono/metadata/generic-sharing.c:704, condition `oti' not met
  18. 18. System.ExecutionEngineException: Attempting to JIT compile method (wrapper managed-to-managed) Foo[]:System.Collections.Generic.ICollection`1.get_Count ()
  19. 19. MonoDevelop source editor is extremely slow
  20. 20. Compiled application is very large
  21. 21. Installation Hangs
  22. 22. Ran out of trampolines of type 1
  23. 23. Debugger is unable to connect with the device
  24. 24. Error 134: mtouch failed with the following message:
  25. 25. Distribution identity is not shown in MonoDevelop project signing options
  26. 26. Error "AFCFileRefWrite returned: 1" during upload
  27. 27. Error "mtouch failed with no output"
  28. 28. Error "The binary you uploaded was invalid.  A pre-release beta version of the SDK was used to build the application"
  29. 29. Error "A pre-release beta version of the SDK was used to build the app"
  30. 30. Unhandled Exception: System.Exception: Failed to find selector someSelector: on {type}
  31. 31. MainWindow.xib.designer.cs file is not updated
  32. 32. UIAlertView or UIActionSheet vanish after being created
  33. 33. Project Always Runs in the iPad Simulator

How do I create outlets or actions with Interface Builder?

Interface Builder changed between Xcode 3.1 (OS X 10.5) and Xcode 3.2 (OS X 10.6).  In Xcode 3.1, you would select your "App Delegate" in your Document window, then use the [+] button in the Class Outlet section of the Identity Inspector pane.  See the MonoDevelop_HelloWorld_with_Leopard sample.

In Xcode 3.2, this changed. You now would select Tools → Library, select the Classes section, and select your class, e.g. AppDelegate.  There would then be an Outlets tab at the bottom of the Library dialog. See the MonoDevelop_HelloWorld sample.

 

System.Text.Encoding.GetEncoding throws NotSupportedException

You're maybe using an encoding that is not added by default. Check the Internationalization page to learn how to add support for more encoding.

 

System.MissingMethodException (anything else)

The member was likely removed by the linker, and thus doesn't exist in the assembly at runtime.  There are several solutions to this:

  • Add the [Preserve] attribute to the member.  This will prevent the linker from removing it.
  • When invoking mtouch, use the -nolink or -linksdkonly options.
    • -nolink disables all linking.
    • -linksdkonly will only link MonoTouch-provided assemblies, such as monotouch.dll.

Note that assemblies are linked so that the resulting executable is smaller; thus, disabling linking may result in a larger executable than is desirable.

You are getting a ModelNotImplementedException

If you are getting this exception this means that you are calling base.Method () on a class that overrides a Model. You do not need to call the base method in a class for models (these are classes that are flagged with the [Model] attribute).

This class is not key value coding-compliant for the key XXXX

If you get this error when loading a NIB file it means that the value XXXX was not found on your managed class. This means that you are missing a declaration like this:

[Connect]
TypeName XXXX { 
   get {
       return (TypeName) GetNativeField ("XXXX");
   }
   set {
       SetNativeField ("XXXX", value);
   }
}

The above definition is automatically generated by MonoDevelop for any XIB files that you add to MonoDevelop in the NAME_OF_YOUR_XIB_FILE.designer.xib.cs file.

Additionally, the types containing the above code must be a subclass of NSObject.  If the containing type is within a namespace, it should also have a [Register] attribute which provides a type name without a namespace (as Interface Builder doesn't support namespaces in types):

namespace MonoTouch.Samples.GLPaint {

    // The [Register] attribute overrides the type name registered
    // with the Objective-C runtime, in this case removing the namespace.
    [Register ("AppDelegate")]
    public class AppDelegate {/* ... */}
}

Unknown class XXXX in Interface Builder file

This error is generated if you define a class in your interface builder files but you do not provide the actual implementation for it in your C# code.

You need to add some code like this: 

public partial class MyImageView : UIView {
   public MyImageView (IntPtr handle) : base (handle {}
}

System.MissingMethodException: No constructor found for Foo.Bar::ctor(System.IntPtr)

This error is produced at runtime when the code tries to instantiate an instance of the classes that you referenced from your Interface Builder file.   This means that you forgot to add a constructor that takes a single IntPtr as a parameter.

The constructor with an IntPtr handle is used to bind managed objects with their unmanaged representations.   To fix this, add the following line of code to the class Foo.Bar:

public Bar (IntPtr handle) : base (handle) { }

Type {Foo} does not contain a definition for `GetNativeField' and no extension method `GetNativeField' of type {Foo} could be found

If you get this error in the designer generated files (*.xib.designer.cs), it means one of two things:

1) Missing partial class or base class

The designer-generated partial classes must have corresponding partial classes in user code that inherit from some subclass of NSObject, often UIViewController. Ensure that you have such a class for the type that is giving the error.

2) Default namespaces changed

The designer files are generated using your project's default namespace settings. If you have changed these settings, or renamed the project, the generated partial classes may no longer be in the same namespace as their user-code counterparts.

Namespace settings can be found in the Project Options dialog. The default namespace is found in the General->Main Settings section. If it is blank, the name of your project is used as the default. More advanced namespace settings can be found in the Source Code->.NET Naming Policies section.

Object {Foo} of class NSConcreteData autoreleased with no pool in place - just leaking

You're creating an NSObject subclass on a thread that isn't the UI thread.

In the course of creating and releasing objects, the Objective-C runtime might choose to release objects when they are no longer needed.   These are released to the thread's current auto-release pool.   MonoTouch provides an autorelease pool for the main thread and any threads from the System.Threading.ThreadPool, but not for threads that you create manually using System.Threading.Thread.

When you create your own threads, if you are going to consume objects derives from NSObject, you should create an NSAutoReleasePool to prevent the leaking:

 You need to create an NSAutoreleasePool to prevent the leaking:

var MyThreadStart ()
{
    using (var pool = new NSAutoreleasePool()) {
         // create NSObject subclasses...
    }
}

If you want to track down where an object is being leaked by not having an auto release pool, you can drop down to GDB in XCode and set a breakpoint in the _NSAutoreleaseNoPool method and get a stack trace from it


Warning for actions: The private method 'Foo' is never used. (CS0169)

Actions for interface builder files are connected to the widgets by reflection at runtime, so this warning is expected.

You can use "#pragma warning disable 0169" "#pragma warning enable 0169" around your actions if you want to suppress this warning just for these methods, or add 0169 to the "Ignore warnings" field in compiler options if you want to disable it for your whole project (not recommended).

 

mtouch failed with the following message: Cannot open assembly '/path/to/yourproject.exe'

If you see this error message, generally the problem is the absolute path to your project contains a space.  This will be fixed in a future version of MonoTouch, but you can work around the issue by moving the project to a folder without spaces.

 

Your sqlite3 version is old - please upgrade to at least v3.5.0!

This happens when you do all of the following:

  1. Use Mono.Data.Sqlite
  2. Use Mac OS X Leopard (10.5)
  3. Run your app within the simulator.

The problem is that Mono is picking up the OS X libsqlite3.dylib, not the iPhoneSimulator's libsqlite3.dylib file.  Your app will work on the device, but just not your simulator.

The short term fix is to use Mac OS X Snow Leopard (10.6).  A fix for Leopard (10.5) will be released with a future MonoTouch version.

 

Deploy to device fails with System.Exception: AMDeviceInstallApplication returned 3892346901

This error means that the code-signing configuration for your certificate/bundle id does not match the provisioning profile installed on your device.  Confirm you have the appropriate certificate selected in Project Options->iPhone Bundle Signing, and the correct bundle id specified in Project Options->iPhone Application

Code Completion is not working in MonoDevelop

Ensure that you are using the latest MonoTouch version of MonoDevelop from http://monodevelop.com/Download/Mac_MonoTouch

If the issue is still present, please file a bug, attaching the "~/.config/MonoDevelop/log" log file.

If all else fails, you can try removing the code completion cache so that it is regenerated:

rm -r ~/.config/MonoDevelop/CodeCompletionData

Be careful that you type this command correctly or you could accidentally remove important files.

MonoDevelop crashes when you copy text

The popular Mac utilities QuickSilver, Google Toolbar and LaunchBar have clipboard features that corrupt MonoDevelop's memory. In their options, you can list MonoDevelop as a process they should not interfere with.

MonoDevelop complains about Mono 2.4 required

If you updated MonoDevelop due to a recent update, and when you try to start it again it complains about Mono 2.4 not being present, all you have to do is upgrade your Mono 2.4 installation.  

Mono 2.4.2.3_6 fixes some important problems that prevented MonoDevelop from running reliably, sometimes hung MonoDevelop at startup or prevented the code completion database from being generated.

Once you install the new Mono, MonoDevelop will start as expected.

 

Assertion at ../../../../mono/metadata/generic-sharing.c:704, condition `oti' not met

If you are receiving the following stack trace:

 * Assertion at ../../../../mono/metadata/generic-sharing.c:704, condition `oti' not met
Stacktrace:
    at System.Collections.Generic.List`1<object>..cctor () <0xffffffff>
    at System.Collections.Generic.List`1<object>..cctor () <0x0001c>
    at (wrapper runtime-invoke) object.runtime_invoke_dynamic (intptr,intptr,intptr,intptr) <0xffffffff>

It means that you are linking a static library compiled with thumb code into your project.  As of iPhone SDK release 3.1 (or higher at the time of this writing) Apple introduced a bug in their linker when linking non-Thumb code (MonoTouch) with Thumb code (your static library).  You will need to link with a non-Thumb version of your static library to mitigate this issue.

 

System.ExecutionEngineException: Attempting to JIT compile method (wrapper managed-to-managed) Foo[]:System.Collections.Generic.ICollection`1.get_Count ()

The [] suffix indicates that you or the class library are calling a method on an array through a generic collection, such as IEnumerable<>, ICollection<> or IList<>. As a workaround, you can explicitely force the AOT compiler to include such method by calling the method yourself, and by making sure that this code is executed before the call that triggered the exception. In this case, you could write:

Foo [] array = null;
int count = ((ICollection<Foo>) array).Count;

Which will force the AOT compiler to include the get_Count method.

 

MonoDevelop source editor is extremely slow

Sometimes the MonoDevelop source editor becomes extremely slow, appearing to hang for several seconds between typing characters.

This issue is very rare and extremely hard to reproduce - it usually cannot be reproduced on the same machine after restarting MonoDevelop. For this reason we would appreciate it if you could perform several debugging steps before restarting MonoDevelop, and send the results to us.

  1. Try closing the editor tab, and re-opening it. Does it take a little bit of editing or moving the caret around until the slowdown happens again?
  2. Disable "Beam Sync" using the "Quartz Debug" developer tool (which you can find using Spotlight), and check whether the source editor performance is restored to normal.
  3. Try repeating step (1) with Beam Sync still disabled.
  4. If the editor hangs for more than a few seconds, try to run "killall -QUIT monodevelop" in a terminal while it is hung. It may be difficult to time the kill command to happen while the editor is hung, but it's essential to do so, because the command forces Mono to write stack traces of all threads to the MD log, which we can use to discover what state the threads are in while the MD is hung.

Please attach the MD log, ~/.config/MonoDevelop/log (in future versions of MD it is ~/Library/Logs/MonoDevelop/MonoDevelop.log).

[NOTE: The above issue was fixed in MD 2.2 Final]

Compiled application is very large

In order to support debugging, debug builds contain additional code. Projects built in release mode are a fraction of the size.

As of MonoTouch 1.3 the debug builds included debugging support for every single component of Mono (every method in every class of the frameworks).  

With MonoTouch 1.4 we will introduce a finer grained method for debugging, the default will be to only provide debugging instrumentation for your code and your libraries, and not do this for all of the Mono assemblies (this will still be possible, but you will have to opt-in to debugging those assemblies).

Installation Hangs

Both Mono and MonoTouch installers hang if you have the iPhone Simulator running.   This problem is not limited to Mono or MonoTouch, this is a consistent problem across any software that tries to install software on MacOS Snow Leopard if the iPhone Simulator is running at installation time.

Make sure you quit the iPhone simulator and retry the installation.

Ran out of trampolines of type 1

If you make heavy use of recursive generics, you may get this message on device.  You can create more type 1 trampolines by modifying your project options "iPhone Build" section.  You want to add extra arguments for the Device build targets:
 
-aot "nrgctx-trampolines=2048"
 
The default number of trampolines is 1024.  Try increasing this number until you have enough for your usage of generics.

Debugger is unable to connect with the device

When you start debugging a device configuration, you will see the debugger show a dialog indicating that it is listening on a particular IP address. This IP address is also built into the application as a default setting. When you start the application in debug mode, it makes a connection to MonoDevelop, the debugger host. If it is unable to connect, the device will vibrate once.

There are several reasons the application may not be able to connect to the debugger:

If the device and the debugger host are on different networks, a firewall or private network may be preventing the application from connecting to the debugger host.

MonoDevelop may picked the wrong host IP address. MonoDevelop picks the first IP address on the machine, which, if you have multiple network interfaces, may not be the one you want. You can override the IP that MonoDevelop uses by quitting MonoDevelop and editing its settings file. This is in a hidden directory in in your home directory, ~/.config/MonoDevelop/MonoDevelopProperties.xml.

Look for the key "MonoTouch.Debugger.HostIP", and edit the value. If it is not present you will need to add it:

<Property key="MonoTouch.Debugger.HostIP" value="w.x.y.z"/>

where w.x.y.z is the IP you wish to use.

The debugger host's IP address may have changed. MonoDevelop has to embed the host's IP address in the application's default settings so that it knows what address to connect to. If the host's IP changes after you build the app, you need to rebuild and re-upload the app, or change the IP address entry in the app's settings on the device.

 

Error 134: mtouch failed with the following message:

This error could be raised if you are trying to build with -nolink on the MonoTouch 1.4 style of releases.  You can work around this error by specifying Extra Arguments in your monodevelop project configuration.  Add the argument

-nosymbolstrip

and the problem should be resolved.

Distribution identity is not shown in MonoDevelop project signing options

MonoDevelop 2.2 has a bug that causes it not to detect distribution certificates that contain a comma. Please update to MonoDevelop 2.2.1.

Error "AFCFileRefWrite returned: 1" during upload

While uploading an app to your device you may receive an Error "AFCFileRefWrite returned: 1". This can happen if you have a zero-length file.

Error "mtouch failed with no output"

The current release of MonoTouch and MonoDevelop fail when the project name or the directory where the solution or project are stored contain spaces.  To fix this:

  • Make sure that neither your project or the directory where it is stored contains a space.
  • In your project "Main Settings" make sure that the Project Name does not contain any spaces.

 

Error "The binary you uploaded was invalid.  A pre-release beta version of the SDK was used to build the application"

This error is usually caused with a project that was started in iPad development before MonoTouch 2.0.0 was released, you likely have some keys in your Info.plist like:

       <key>UIDeviceFamily</key>
       <array>
               <string>1</string>
       </array>

This keypair should be removed as MonoDevelop handles it for you automatically.

Error "A pre-release beta version of the SDK was used to build the app"

(Contributed by Ed Anuff)

Follow these steps:

  • Change the SDK version in iPhone Build to 3.2 or iTunes connect will reject it on upload because it is seeing an iPad compatible app built using an SDK version less than 3.2
  • Create a custom Info.plist for the project and explicitly set MinimumOSVersion to 3.0 in it.   This will override the MinimumOSVersion 3.2 value set by MonoTouch.   If you do not do this, the app will not be able to run on an iPhone.
  • Rebuild, zip and upload to iTunes connect.

 

 

Unhandled Exception: System.Exception: Failed to find selector someSelector: on {type}

This exception is caused by one of three things:

  1. You have provided a Selector to the Objective-C runtime without applying the corresponding [Export] attribute to a method
  2. You have enabled full linking and not applied the [Preverse] attribute to the [Export]ed method.
  3. You have applied the [Export] attribute to a private method in an inherited type.

MainWindow.xib.designer.cs file is not updated

There was a bug in MonoDevelop 2.4 that caused it not to group the MainWindow.xib file with the MainWindow.xib.designer file in new projects. This meant it would not update the designer code for that particular file.

This issue is fixed in the version of MonoDevelop that's available in its built-in updater, so please ensure you use the newer version.

You can fix existing projects by removing (not deleting) the xib and its designer file, then adding it back. This should re-group the files correctly.

UIAlertView or UIActionSheet vanish after being created

If you have some code like this:

var actionSheet = new UIActionSheet ("My ActionSheet", null, null, "OK", null){     
   Style = UIActionSheetStyle.Default 
}; 
actionSheet.Clicked += delegate (sender, args){ 
    Console.WriteLine ("Clicked on item {0}", args.ButtonIndex); 
};

the "actionSheet" object lives as a temporary variable in the function and as soon as the function terminates, the object is eligible for garbage collection, so it ends up being garbage collected.

To fix this problem, you need to keep a reference to "actionSheet" outside your method, somewhere that will live beyond your method.

Project Always Runs in the iPad Simulator

The iPhone SDK 4.0 installer installs 2 SDKs - the 3.2 SDK, for building iPad-only apps, and the 4.0 SDK, used for bulding iPhone and Universal apps. It also installs a 3.2 simulator, which simulates only an iPad, and a 4.0 simulator that simulates iPhone or iPhone 4. All older SDKs and simulators are removed.

MonoDevelop iPhone project build options include a setting for the SDK version that will be used in building your app. This setting can be found in Project Options->Build->iPhone Build.

New projects in MonoDevelop use the oldest installed SDK as their default SDK setting, and if the SDK specified does not exist, MonoDevelop will use the closest it can find to build your app. This was done so that  projects would not always requre the newest SDK. However, this currently results in the 3.2 SDK being used - which results in the iPad simulator being used.

To fix this by using the 4.0 SDK, go to Project Options->Build->iPhone Build and change the SDK value to "4.0" using the dropdown box. You must do this for each configuration and platform combination, accessed using the dropdowns at the top of the panel.

The SDK version should not be confused with the "Minimum OS version" setting. This value does not have to match the SDK version value - it affects the minimum version of the OS your app will install on, which can be older than the SDK, as long as you use only APIs that exist in the older OS, or guard use of newer features using runtime OS version checks. You should set it to the oldest OS version on which you test your app.

Note also that the Project->iPhone Simulator Target menu can be used to pick the simulator that is used by default when running/debugging a project. Additionally, the Run->Run With menu can be used to pick a specific simulator with which to run

Tag page

Files (0)

 
Page last modified 02:57, 28 Jul 2010 by MichaelHutchinson