Tôi gặp sự cố với ứng dụng Xamarin.Forms mới được tạo trong Visual Studio 2015. Tôi đã thêm dự án Droid/iOS vào giải pháp và cung cấp cho tôi một lỗi build nói ...Loại hoặc không gian tên 'Ứng dụng' không tồn tại trong không gian tên hiện tại
The type or namespace 'App' does not exist in the current namespace
Dưới đây là một ví dụ về nơi hai lỗi này.
dự án Droid:
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()
}
}
}
dự án 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);
}
}
}
Giải pháp này đã được chỉ cần thực hiện và không mã hóa được thực hiện chưa, điều này có thể là một vấn đề với VS2015?
hai dự án nền tảng của bạn có tham chiếu đến dự án Biểu mẫu PCL được chia sẻ không? Đó là nơi lớp App tồn tại theo mặc định. – Jason