简体   繁体   English

Xamarin Forms PCL中的LoadApplication错误

[英]Error on LoadApplication in Xamarin Forms PCL

I created a new Xamarin Forms PCL solution, and in debug mode I checked the Enable ProGuard option and I selected Linking comboxbox to Sdk and User Assemblies . 我创建了一个新的Xamarin Forms PCL解决方案,并在调试模式下选中了Enable ProGuard选项,然后选择了Linking comboxbox LinkingSdk and User Assemblies Now I run my application on android, after that it shows me an error in MainActivity.cs class and on line 现在我在android上运行我的应用程序,此后它向我显示MainActivity.cs类中的错误并在线

LoadApplication(new App());

Error: 错误:

Unhandled Exception:
System.NullReferenceException: Object reference not set to an instance of an object.

I do that because of to decrease the size of my release app, and I have to change the release mode to debug in order to check what happened. 我这样做是因为减小了发布应用程序的大小,并且我必须更改发布模式以进行调试才能检查发生了什么。

As per: The type or namespace 'App' does not exist in the current namespace 按照: 类型或名称空间“应用程序”在当前名称空间中不存在

Clean the solution Build the PCL Remove the PCL reference from the affected project(s) Re-add the PCL reference Build 清洁解决方案生成PCL从受影响的项目中删除PCL参考重新添加PCL参考Build

I tried this solution and it works. 我尝试了这种解决方案,它可以工作。

Take a look at your App.xaml.cs file. 查看您的App.xaml.cs文件。 If you have a "InitializeComponent does not exist in the current context error", this is likely caused by a known VS bug. 如果您有一个“ InitializeComponent在当前上下文错误中不存在”,则可能是由已知的VS错误引起的。

Solution: 解:

  • Right click on App.xaml.cs and select Properties. 右键单击App.xaml.cs,然后选择“属性”。
  • Change the Build Action to "Content". 将生成操作更改为“内容”。
  • Apply. 应用。
  • Change Build Action back to C# Compiler. 将“生成操作”更改回C#编译器。
  • Clean Solution. 清洁溶液。
  • Build and Deploy. 构建和部署。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM