Switch to a different documentation area.
TroubleshootingTable of contents
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. 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 NotSupportedExceptionYou'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:
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 ModelNotImplementedExceptionIf 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 XXXXIf 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 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 fileThis 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 foundIf 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 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. 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:
The problem is that Mono is picking up the OS X 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 3892346901This 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 MonoDevelopEnsure 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:
Be careful that you type this command correctly or you could accidentally remove important files. MonoDevelop crashes when you copy textThe 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 requiredIf 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 metIf 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 slowSometimes 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.
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 largeIn 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 HangsBoth 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 0If you get this message while running device, You can create more type 0 trampolines (type SPECIFIC) by modifying your project options "iPhone Build" section. You want to add extra arguments for the Device build targets:
The default number of trampolines is 1024. Try increasing this number until you have enough for your application. Ran out of trampolines of type 1If you make heavy use of recursive generics, you may get this message on device. You can create more type 1 trampolines (type RGCTX) by modifying your project options "iPhone Build" section. You want to add extra arguments for the Device build targets:
The default number of trampolines is 1024. Try increasing this number until you have enough for your usage of generics. Ran out of trampolines of type 2If you make heavy use interfaces, you may get this message on device. You can create more type 2 trampolines (type IMT Thunks) by modifying your project options "iPhone Build" section. You want to add extra arguments for the Device build targets:
The default number of IMT Thunk trampolines is 128. Try increasing this number until you have enough for your usage of interfaces. Debugger is unable to connect with the deviceWhen 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, 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 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 Debug Settings page on the device (open the Settings app 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 optionsMonoDevelop 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 uploadWhile 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:
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:
Unhandled Exception: System.Exception: Failed to find selector someSelector: on {type}This exception is caused by one of three things:
MainWindow.xib.designer.cs file is not updatedThere 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 createdIf 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 SimulatorThe 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 ibtool returns error 133This means that you have XCode 4 installed. In XCode 4, the tool ibtool was removed, it is no longer possible to edit your XIB files with a standalone tool. If you want to use Interface Builder, install XCode series 3, available from Apple's web site. "Can't create display binding for mime type: application/vnd.apple-<wbr/>interface-builder"This error happens if you try to create an iPhone UI from a non-iPhone project. Make sure that you start with an iPhone/iPad solution, it is not possible to just add iPhone UI elements to a non-iPhone/iPad project. Startup crash when executing inside the iOS simulatorIf you get a runtime crash (SIGSEGV) inside the simulator along with a stack trace that looks like this: at (wrapper managed-to-native) System.Reflection.Assembly.GetTypes (System.Reflection.Assembly,bool) at MonoTouch.ObjCRuntime.Runtime.RegisterAssembly (System.Reflection.Assembly) at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object (object,intptr,intptr,intptr) then you probably have one (or more) stale assembly in your simulator application directory. Such assemblies may exists since Apple iOS simulator adds and updates files but never deletes them. If this happens then the easiest solution is to select "Reset and Content and Settings..." from the simulator menu.
Warning: this will remove all files, applications and data from the simulator.
Next time you execute your application, MonoDevelop will deploy it into the simulator and there will be no old, stale assembly to cause the crash.
Simulator hangs during application installationThis can happen when application names include a '.' (dot) in their name. This is forbidden as the executable name in CFBundleExecutable - even if it can works in many other cases (like devices). "The value should not include any extension on the name." http://developer.apple.com/library/mac/documentation/General/Reference/InfoPlistKeyReference/InfoPlistKeyReference.pdf |