我正在尝试使用: 我的Xamarin.Forms应用程序上的表单的ZXing.Net.Mobile https://components.xamarin.com/gettingstarted/zxing.net.mobile.forms
namespace MnakabAlshabaViewBook.Droid
{
[Activity ( Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
[assembly: UsesPermission(Manifest.Permission.Flashlight)]
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);
ZXing.Net.Mobile.Forms.Android.Platform.Init();
LoadApplication(new App());
}
我收到以下错误:
'组装'不是有效的属性位置 声明。此声明的有效属性位置是 '类型&#39 ;.此块中的所有属性都将被忽略。
我应该放在哪里:
[assembly: UsesPermission (Android.Manifest.Permission.Flashlight)]
???
答案 0 :(得分:4)
您必须将程序集属性放在命名空间之上,因此重新排列它:
[assembly: UsesPermission(Manifest.Permission.Flashlight)]
namespace MnakabAlshabaViewBook.Droid
{
[Activity ( Icon = "@drawable/icon", MainLauncher = true, ConfigurationChanges = ConfigChanges.ScreenSize | ConfigChanges.Orientation)]
public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsApplicationActivity
{
//... Rest of code is here ...