Xamarin.ios 错误CS1061:AppDelegate不包含GetNativeField的定义
我正在用mono touch编写我的第一个iPhone应用程序。我只写了一点点代码,突然,它不再编译了,我得到了以下错误: /MyRoute/MainWindow.xib.designer.cs(85,85):错误CS1061:TypeXamarin.ios 错误CS1061:AppDelegate不包含GetNativeField的定义,xamarin.ios,Xamarin.ios,我正在用mono touch编写我的第一个iPhone应用程序。我只写了一点点代码,突然,它不再编译了,我得到了以下错误: /MyRoute/MainWindow.xib.designer.cs(85,85):错误CS1061:Typexxxx.AppDelegate'不包含GetNativeField'的定义,并且找不到类型为xxx.AppDelegate'的扩展方法(是否缺少using指令或程序集引用?)(CS1061)(xxx) 你知道这个错误是从哪里来的,怎么解决吗 谢谢-D 编辑:添加
xxxx.AppDelegate'不包含
GetNativeField'的定义,并且找不到类型为xxx.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);
}
}
}
}
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;
}
}
}
这是主要内容。CS:
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);
}
}
}
}
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;
}
}
}
namespace GuiaTeleIphone
{
公共类应用程序
{
静态void Main(字符串[]参数)
{
UIApplication.Main(args);
}
}
//名称AppDelegate在MainWindow.xib文件中引用。
公共部分类AppDelegate:UIApplicationDelegate
{
列出远程通道数据;
//当应用程序加载其UI并准备运行时,将调用此方法
公共覆盖bool FinishedLaunching(UIApplication应用程序、NSDictionary选项)
{
//如果已定义视图,请将其添加到此处:
//window.AddSubview(navigationController.View);
window.MakeKeyAndVisible();
//在这里做事
返回true;
}
}
}
xxxx.AppDelegate的另一部分类缺失或位于不同的命名空间中。它指定基类。抱歉,mhutch。其他哪个分部类?如果使用默认模板,它可能在Main.cs.Hi中,我认为两者都在同一名称空间中。。。请看一下我在最初的假设中添加的代码ApplicationLegate有一个GetNativeField方法。您应该验证这两个类部分都包含在构建中,并且没有其他名为AppDelegate的类。我不知道发生了什么。。。我刚刚创建了一个新的解决方案,复制并粘贴了所有内容,而且它工作正常。。。我想这是因为某些名称空间的疯狂。。。谢谢胡奇