App crashes when objects are named: help?

I have recently encountered this problem, in my main storyboard (I only have 1) that whenever I name an object within the view controller label the object causes the app to not launch. When items are added with no name the program works fine however when an object is named it seems to cause a problem.
Below I have screenshots as well as the app delegate code and RegisterVC.designer code.
Error that is displayed:

"Foundation.MonoTouchException: Objective-C exception thrown. Name: NSUnknownKeyException Reason: [ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key TestForXamarin."

App Delegate code:

using Foundation;
using UIKit;
using System;
using RegApp;

namespace RegApp
{
    // The UIApplicationDelegate for the application. This class is responsible for launching the
    // User Interface of the application, as well as listening (and optionally responding) to application events from iOS.
    [Register("AppDelegate")]
    public class AppDelegate : UIApplicationDelegate
    {
        // class-level declarations

        public override UIWindow Window
        {
            get;
            set;
        }

        public override bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            Window = new UIWindow(UIScreen.MainScreen.Bounds);
            var storyboard = UIStoryboard.FromName("Register", NSBundle.MainBundle);

            UIViewController rootViewController;
            rootViewController = (UIViewController)storyboard.InstantiateViewController("RegisterVC");
            Window.RootViewController = rootViewController;
            Window.MakeKeyAndVisible();
            return true;
        }
    }
}

Designer Code:

using Foundation;
using System;
using System.CodeDom.Compiler;
using UIKit;

namespace RegApp
{
    [Register ("RegisterVC")]
    partial class RegisterVC
    {
        [Outlet]
        [GeneratedCode ("iOS Designer", "1.0")]
        UIKit.UIView TestForXamarin { get; set; }

        void ReleaseDesignerOutlets ()
        {
            if (TestForXamarin != null) {
                TestForXamarin.Dispose ();
                TestForXamarin = null;
            }
        }
    }
}

I am sure the problem is obvious to experienced users but I just cannot see it!
NOTE: It doesnt matter what object I name (this one is a view) the error occurs with everything I name.
Any help would be amazing!

Tagged:

Posts

  • LandLuLandLu Member, Xamarin Team Xamurai

    It seems your view controller in the storyboard may have the wrong class, so your control's connection to the outlet in the designer.cs will throw this exception. Try to recreate a new ViewController and test this.
    In the StoryBoard, you can choose a View Controller in the ToolBox tab. Then drag it on the storyboard, click the yellow button at the left bottom of this view controller which can show a property window on the right:

    Type a class name in the class tab(try to use a new class name you haven't used before), then press Enter Visual Studio will auto generate a class for this view controller. You can add some controls you want in this view controller and named them there.

  • @LandLu

    That seemed to work great thanks!

Sign In or Register to comment.