【发布时间】:2015-07-28 02:09:05
【问题描述】:
我在使用 Visual Studio 2015 中新制作的 Xamarin.Forms 应用时遇到问题。我将 Droid/iOS 项目添加到解决方案中,但它给了我一个构建错误提示...
The type or namespace 'App' does not exist in the current namespace
这是两个错误所在的示例。
机器人项目:
namespace MyApp.Droid
{
[Activity (Label = "MyApp", Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
protected override void OnCreate (Bundle bundle)
{
base.OnCreate (bundle);
global::Xamarin.Forms.Forms.Init (this, bundle);
LoadApplication (new MyApp.App ());
//Error on the above line at MyApp.App ()
}
}
}
iOS 项目:
namespace MyApp.iOS
{
[Register("AppDelegate")]
public partial class AppDelegate : global::Xamarin.Forms.Platform.iOS.FormsApplicationDelegate
{
public override bool FinishedLaunching(UIApplication app, NSDictionary options)
{
global::Xamarin.Forms.Forms.Init ();
LoadApplication (new MyApp.App ());
//Error on above line in MyApp.App ()
return base.FinishedLaunching (app, options);
}
}
}
这个解决方案刚刚完成,还没有完成编码,这可能是VS2015的问题吗?
【问题讨论】:
-
您的两个平台项目是否引用了共享的 Forms PCL 项目?这就是 App 类默认存在的地方。
标签: xamarin xamarin.ios xamarin.android xamarin.forms