Error on LoadApplication in Xamarin Forms PCL












4















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.










share|improve this question

























  • I assume you are using Xamarin Forms? Please post the line of code that is throwing the error. I think your issue is that you need to change it to LoadApplication(new PCLNameHere.App())

    – Tristan
    Mar 3 '18 at 8:36











  • I tried that , but it falls into error on line LoadApplication(new App()); The important point is , when i changed Linking option to none and unchecked ProGuard option , my applicatrion run successfully. I need those options to decrease my final .apk file

    – Amir Hossein Khajegan
    Mar 3 '18 at 8:49













  • What does the rest of the stacktrace say?

    – hvaughan3
    Mar 3 '18 at 16:27











  • Linking against SDK assemblies only isn't enough?

    – hichame.yessou
    Mar 4 '18 at 1:23











  • @hvaughan3 The value of my Environment.StackTrace is : at System.Environment.get_StackTrace () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Diagnostics.Debugger.Mono_UnhandledException_internal (System.Exception ) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Diagnostics.Debugger.Mono_UnhandledException (System.Exception ex) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Object.d09f62bf-1e4f-438b-810e-1b2febfe5330 (System.IntPtr , System.IntPtr , System.IntPtr ) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0

    – Amir Hossein Khajegan
    Mar 4 '18 at 12:46
















4















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.










share|improve this question

























  • I assume you are using Xamarin Forms? Please post the line of code that is throwing the error. I think your issue is that you need to change it to LoadApplication(new PCLNameHere.App())

    – Tristan
    Mar 3 '18 at 8:36











  • I tried that , but it falls into error on line LoadApplication(new App()); The important point is , when i changed Linking option to none and unchecked ProGuard option , my applicatrion run successfully. I need those options to decrease my final .apk file

    – Amir Hossein Khajegan
    Mar 3 '18 at 8:49













  • What does the rest of the stacktrace say?

    – hvaughan3
    Mar 3 '18 at 16:27











  • Linking against SDK assemblies only isn't enough?

    – hichame.yessou
    Mar 4 '18 at 1:23











  • @hvaughan3 The value of my Environment.StackTrace is : at System.Environment.get_StackTrace () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Diagnostics.Debugger.Mono_UnhandledException_internal (System.Exception ) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Diagnostics.Debugger.Mono_UnhandledException (System.Exception ex) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Object.d09f62bf-1e4f-438b-810e-1b2febfe5330 (System.IntPtr , System.IntPtr , System.IntPtr ) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0

    – Amir Hossein Khajegan
    Mar 4 '18 at 12:46














4












4








4


0






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.










share|improve this question
















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.







c# android xamarin portable-class-library






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 24 '18 at 19:01









Federico Grandi

3,16621229




3,16621229










asked Mar 3 '18 at 7:58









Amir Hossein KhajeganAmir Hossein Khajegan

3111




3111













  • I assume you are using Xamarin Forms? Please post the line of code that is throwing the error. I think your issue is that you need to change it to LoadApplication(new PCLNameHere.App())

    – Tristan
    Mar 3 '18 at 8:36











  • I tried that , but it falls into error on line LoadApplication(new App()); The important point is , when i changed Linking option to none and unchecked ProGuard option , my applicatrion run successfully. I need those options to decrease my final .apk file

    – Amir Hossein Khajegan
    Mar 3 '18 at 8:49













  • What does the rest of the stacktrace say?

    – hvaughan3
    Mar 3 '18 at 16:27











  • Linking against SDK assemblies only isn't enough?

    – hichame.yessou
    Mar 4 '18 at 1:23











  • @hvaughan3 The value of my Environment.StackTrace is : at System.Environment.get_StackTrace () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Diagnostics.Debugger.Mono_UnhandledException_internal (System.Exception ) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Diagnostics.Debugger.Mono_UnhandledException (System.Exception ex) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Object.d09f62bf-1e4f-438b-810e-1b2febfe5330 (System.IntPtr , System.IntPtr , System.IntPtr ) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0

    – Amir Hossein Khajegan
    Mar 4 '18 at 12:46



















  • I assume you are using Xamarin Forms? Please post the line of code that is throwing the error. I think your issue is that you need to change it to LoadApplication(new PCLNameHere.App())

    – Tristan
    Mar 3 '18 at 8:36











  • I tried that , but it falls into error on line LoadApplication(new App()); The important point is , when i changed Linking option to none and unchecked ProGuard option , my applicatrion run successfully. I need those options to decrease my final .apk file

    – Amir Hossein Khajegan
    Mar 3 '18 at 8:49













  • What does the rest of the stacktrace say?

    – hvaughan3
    Mar 3 '18 at 16:27











  • Linking against SDK assemblies only isn't enough?

    – hichame.yessou
    Mar 4 '18 at 1:23











  • @hvaughan3 The value of my Environment.StackTrace is : at System.Environment.get_StackTrace () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Diagnostics.Debugger.Mono_UnhandledException_internal (System.Exception ) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Diagnostics.Debugger.Mono_UnhandledException (System.Exception ex) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Object.d09f62bf-1e4f-438b-810e-1b2febfe5330 (System.IntPtr , System.IntPtr , System.IntPtr ) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0

    – Amir Hossein Khajegan
    Mar 4 '18 at 12:46

















I assume you are using Xamarin Forms? Please post the line of code that is throwing the error. I think your issue is that you need to change it to LoadApplication(new PCLNameHere.App())

– Tristan
Mar 3 '18 at 8:36





I assume you are using Xamarin Forms? Please post the line of code that is throwing the error. I think your issue is that you need to change it to LoadApplication(new PCLNameHere.App())

– Tristan
Mar 3 '18 at 8:36













I tried that , but it falls into error on line LoadApplication(new App()); The important point is , when i changed Linking option to none and unchecked ProGuard option , my applicatrion run successfully. I need those options to decrease my final .apk file

– Amir Hossein Khajegan
Mar 3 '18 at 8:49







I tried that , but it falls into error on line LoadApplication(new App()); The important point is , when i changed Linking option to none and unchecked ProGuard option , my applicatrion run successfully. I need those options to decrease my final .apk file

– Amir Hossein Khajegan
Mar 3 '18 at 8:49















What does the rest of the stacktrace say?

– hvaughan3
Mar 3 '18 at 16:27





What does the rest of the stacktrace say?

– hvaughan3
Mar 3 '18 at 16:27













Linking against SDK assemblies only isn't enough?

– hichame.yessou
Mar 4 '18 at 1:23





Linking against SDK assemblies only isn't enough?

– hichame.yessou
Mar 4 '18 at 1:23













@hvaughan3 The value of my Environment.StackTrace is : at System.Environment.get_StackTrace () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Diagnostics.Debugger.Mono_UnhandledException_internal (System.Exception ) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Diagnostics.Debugger.Mono_UnhandledException (System.Exception ex) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Object.d09f62bf-1e4f-438b-810e-1b2febfe5330 (System.IntPtr , System.IntPtr , System.IntPtr ) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0

– Amir Hossein Khajegan
Mar 4 '18 at 12:46





@hvaughan3 The value of my Environment.StackTrace is : at System.Environment.get_StackTrace () [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Diagnostics.Debugger.Mono_UnhandledException_internal (System.Exception ) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Diagnostics.Debugger.Mono_UnhandledException (System.Exception ex) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0 at System.Object.d09f62bf-1e4f-438b-810e-1b2febfe5330 (System.IntPtr , System.IntPtr , System.IntPtr ) [0x00000] in <657aa8fea4454dc898a9e5f379c58734>:0

– Amir Hossein Khajegan
Mar 4 '18 at 12:46












2 Answers
2






active

oldest

votes


















2














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.






share|improve this answer































    0














    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.






    share|improve this answer
























    • I did it before but that error is persist exists

      – Amir Hossein Khajegan
      Jul 14 '18 at 17:24











    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49082024%2ferror-on-loadapplication-in-xamarin-forms-pcl%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    2














    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.






    share|improve this answer




























      2














      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.






      share|improve this answer


























        2












        2








        2







        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.






        share|improve this answer













        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.







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 26 '18 at 1:57









        DiomedesDiomedes

        344618




        344618

























            0














            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.






            share|improve this answer
























            • I did it before but that error is persist exists

              – Amir Hossein Khajegan
              Jul 14 '18 at 17:24
















            0














            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.






            share|improve this answer
























            • I did it before but that error is persist exists

              – Amir Hossein Khajegan
              Jul 14 '18 at 17:24














            0












            0








            0







            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.






            share|improve this answer













            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.







            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jul 13 '18 at 13:33









            WilhelmWilhelm

            676




            676













            • I did it before but that error is persist exists

              – Amir Hossein Khajegan
              Jul 14 '18 at 17:24



















            • I did it before but that error is persist exists

              – Amir Hossein Khajegan
              Jul 14 '18 at 17:24

















            I did it before but that error is persist exists

            – Amir Hossein Khajegan
            Jul 14 '18 at 17:24





            I did it before but that error is persist exists

            – Amir Hossein Khajegan
            Jul 14 '18 at 17:24


















            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f49082024%2ferror-on-loadapplication-in-xamarin-forms-pcl%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Costa Masnaga

            Fotorealismo

            Sidney Franklin