简体   繁体   中英

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 . Now I run my application on android, after that it shows me an error in MainActivity.cs class and on line

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

I tried this solution and it works.

Take a look at your App.xaml.cs file. If you have a "InitializeComponent does not exist in the current context error", this is likely caused by a known VS bug.

Solution:

  • Right click on App.xaml.cs and select Properties.
  • Change the Build Action to "Content".
  • Apply.
  • Change Build Action back to C# Compiler.
  • Clean Solution.
  • Build and Deploy.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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