I just upgraded my Monotouch to 6 and now my app won't start. It was working formerly without any issues. Now it throws an exception (listed below) in the Main.cs file. I've looked through the troubleshooting tips on Xamarin, but it didn't resolve the issue. I've re-layed out the nib file, removed and re-configured my outlets, and have create an entirely new nib to see if that would remedy the problem. Does anybody else have any thoughts?
MonoTouch.Foundation.MonoTouchException: Objective-C exception thrown. Name: NSUnknownKeyException Reason: [<UIApplication 0xc84bb10> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key btnNewAccount.
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0004c] in /Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:38
at Pokr.Application.Main (System.String[] args) [0x00000] in /Users/James/Projects/App/Main.cs:17
Code from the LoginView.designer.cs:
[Register ("LoginView")]
partial class LoginView
{
[Outlet]
MonoTouch.UIKit.UIImageView imgLogo { get; set; }
[Outlet]
MonoTouch.UIKit.UITextField txtEmail { get; set; }
[Outlet]
MonoTouch.UIKit.UITextField txtPassword { get; set; }
[Outlet]
MonoTouch.UIKit.UIButton btnLogin { get; set; }
[Outlet]
MonoTouch.UIKit.UIButton btnNewAccount { get; set; }
[Outlet]
MonoTouch.UIKit.UILabel lblSecurityNotice { get; set; }
[Outlet]
MonoTouch.UIKit.UIImageView imgKeyboardBorder { get; set; }
void ReleaseDesignerOutlets ()
{
if (imgLogo != null) {
imgLogo.Dispose ();
imgLogo = null;
}
if (txtEmail != null) {
txtEmail.Dispose ();
txtEmail = null;
}
if (txtPassword != null) {
txtPassword.Dispose ();
txtPassword = null;
}
if (btnLogin != null) {
btnLogin.Dispose ();
btnLogin = null;
}
if (btnNewAccount != null) {
btnNewAccount.Dispose ();
btnNewAccount = null;
}
if (lblSecurityNotice != null) {
lblSecurityNotice.Dispose ();
lblSecurityNotice = null;
}
if (imgKeyboardBorder != null) {
imgKeyboardBorder.Dispose ();
imgKeyboardBorder = null;
}
}
Code from Main.cs (where the code breaks):
static void Main (string[] args)
{
UIApplication.Main (args, null, "AppDelegate");
}
Here is the snippet from my AppDelegate where I call the ViewController:
var rootNavigationController = new UINavigationController();
LoginView loginScreen = new LoginView();
rootNavigationController.PushViewController(loginScreen, false);
this.window.RootViewController = rootNavigationController;
//blank function fires so the getter will init the singleton.
Singleton.Instance.Initialize();
// make the window visible
window.MakeKeyAndVisible ();
return true;
This error occurs when you have initialized a ViewController
in code but also have the ViewController
initialized from a XIB file.
This could happen if you have the "Main Interface" value set to a ViewController
you're creating in code. To resolve this issue, make this value empty, then no ViewController
will be initialized automatically.
Also check your pInfo file to see if there is a Main Interface set.
Thanks to @Bart for providing this tip for Xamarin users:
Right-click project in Xamarin Studio (v.4) select 'Options'
and then under 'iOS Project'
(section 'iPad Deployment info'
). Clear out the drop-down 'Main Interface'
and that should solve the issue.
It's telling you the reason: [<UIApplication 0xc84bb10> setValue:forUndefinedKey:]
. Notice it's not saying: [<LoginView 0xc84bb10> setValue:forUndefinedKey:]
. Now you need to figure out what is trying to send the message -setBtnNewAccount:
to an instance of UIApplication.
It looks like a delegate is set wrong somewhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With