【问题标题】:Error CS1061: AppDelegate does not contain a definition for GetNativeField错误 CS1061:AppDelegate 不包含 GetNativeField 的定义
【发布时间】:2011-08-21 05:04:12
【问题描述】:

我正在使用单点触控编写我的第一个 iPhone 应用程序。我只写了一点代码,突然,它不再编译了,我得到这个错误:

/MyRoute/MainWindow.xib.designer.cs(85,85): Error CS1061: Type xxxx.AppDelegate' does not contain a definition forGetNativeField' and no extension method GetNativeField' of typexxx.AppDelegate' 找不到(你是否缺少 using 指令或程序集参考?)(CS1061)(xxx)

知道这个错误来自哪里以及如何解决它吗?

谢谢! :-D

已编辑:添加了附加信息:

这是主窗口设计师代码:

namespace GuiaTeleIphone {


    // Base type probably should be MonoTouch.Foundation.NSObject or subclass
    [MonoTouch.Foundation.Register("AppDelegate")]
    public partial class AppDelegate {

        private MonoTouch.UIKit.UIWindow __mt_window;

        #pragma warning disable 0169
        [MonoTouch.Foundation.Connect("window")]
        private MonoTouch.UIKit.UIWindow window {
            get {
                this.__mt_window = ((MonoTouch.UIKit.UIWindow)(this.GetNativeField("window")));
                return this.__mt_window;
            }
            set {
                this.__mt_window = value;
                this.SetNativeField("window", value);
            }
        }
    }
}

这是 MAIN.CS:

namespace GuiaTeleIphone
{
    public class Application
    {
        static void Main (string[] args)
        {
            UIApplication.Main (args);
        }
    }

    // The name AppDelegate is referenced in the MainWindow.xib file.
    public partial class AppDelegate : UIApplicationDelegate
    {
        List<RSSChannel> RemoteChannelsData;

        // This method is invoked when the application has loaded its UI and its ready to run
        public override bool FinishedLaunching (UIApplication app, NSDictionary options)
        {
            // If you have defined a view, add it here:
            // window.AddSubview (navigationController.View);

            window.MakeKeyAndVisible ();

                        // do things here

            return true;
        }

        }
}

【问题讨论】:

    标签: xamarin.ios


    【解决方案1】:

    xxxx.AppDelegate 的另一个部分类丢失或位于不同的命名空间中。它指定了基类。

    【讨论】:

    • 对不起mhutch。还有哪个部分类?
    • 如果你使用默认模板,它可能在 Main.cs 中。
    • 嗨,我认为两者都在同一个命名空间中......请看看我在原帖中添加的代码
    • UIApplicationDelegate 有一个 GetNativeField 方法。您应该验证这两个类部分都包含在构建中,并且没有其他名为 AppDelegate 的类。
    • 我不知道发生了什么...我刚刚创建了一个新的解决方案,复制并粘贴了所有内容,并且成功了...我想这是因为某些命名空间的疯狂...谢谢 mhutch
    猜你喜欢
    • 2023-03-20
    • 2018-04-11
    • 1970-01-01
    • 2020-12-31
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-08-31
    • 1970-01-01
    相关资源
    最近更新 更多