locked
Disable Android Debugging on Release Mode: AssemblyInfo.cs vs .csproj file? RRS feed

  • Question

  • User390623 posted

    I need to disable debugging on my Xamarin.Android project before I release it. The official docs recommend doing this in the AssemblyInfo.cs file. However, I also notice that the .csproj file for my Android project, under android options, I can uncheck "Enable developer instrumentation (debugging and profiling)."

    My question is, what is the difference between these two approaches? Do they both disable debugging for a release configuration? I'd prefer to disable debugging in the .csproj file, as I'm running into an exception when I try to set it in AssemblyInfo.cs ("Application cannot have both a type with an [Application] attribute and an [assembly:Application] attribute.")

    Thanks!

    Wednesday, February 12, 2020 4:07 PM

Answers

  • User371688 posted

    Application cannot have both a type with an [Application] attribute and an [assembly:Application] attribute.

    What this means is that you have both the Application attribute defined in your AssemblyInfo.cs and have that attribute defined in one of your classes. Did you create a class that derived from Application?

    [Application(Debuggable=false)]
    MyApplication : Application
    { 
      // You code
    }
    

    So you can either define it in your AssemblyInfo.cs, or as an attribute in one of your classes, but not both.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, February 13, 2020 9:21 AM

All replies

  • User371688 posted

    Application cannot have both a type with an [Application] attribute and an [assembly:Application] attribute.

    What this means is that you have both the Application attribute defined in your AssemblyInfo.cs and have that attribute defined in one of your classes. Did you create a class that derived from Application?

    [Application(Debuggable=false)]
    MyApplication : Application
    { 
      // You code
    }
    

    So you can either define it in your AssemblyInfo.cs, or as an attribute in one of your classes, but not both.

    • Marked as answer by Anonymous Thursday, June 3, 2021 12:00 AM
    Thursday, February 13, 2020 9:21 AM
  • User390623 posted

    Thanks! Yeah, it turns out I have a MainApplication class that inherits Application, and I set the Debuggable attribute there. :)

    Thursday, February 13, 2020 2:23 PM