I have a compile error in my application class. Here is the code I have in AssemblyInfo.cs
:
[assembly: AssemblyTitle("myApp")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("")]
[assembly: AssemblyCopyright("CCS")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
[assembly: AssemblyVersion ("0.1.0")]
// The following attributes are used to specify the signing key for the assembly,
// if desired. See the Mono documentation for more information about signing.
//[assembly: AssemblyDelaySign(false)]
//[assembly: AssemblyKeyFile("")]
#if DEBUG
[assembly: Application(Debuggable = true)]
#else
[assembly: Application(Debuggable=false)]
#endif
And this is my application class in MainActivity.cs
:
[Application]
public class MyApplication : Android.App.Application
{
//public static string globaly = "CSS!";
public static int AppNr;
public MyApplication(IntPtr handle, JniHandleOwnership ownerShip) : base(handle, ownerShip)
{
}
public override void OnCreate()
{
// If OnCreate is overridden, the overridden c'tor will also be called.
base.OnCreate();
}
I am getting this error message:
Application cannot have both a type with an [Application] attribute and an [assembly:Application] attribute
Thanks for any advice on how to solve this.
SOLUTION: just remove the lines in the AssemblyInfo.cs
(#if DEBUG ... #endif)
and replace the line
[Application]
(in your class) with the following one :
#if DEBUG
[Application(Debuggable = true)]
#else
[Application(Debuggable=false)]
#endif
I have also encountered it once, when I deleted below lines and compiled it.
#if DEBUG
[assembly: Application(Debuggable = true)]
#else
[assembly: Application(Debuggable=false)]
#endif
Other Way,You can try it
https://forums.xamarin.com/discussion/7670/error-while-preparing-an-application-for-release
Remove below code from your AssemblyInfo.cs
#if DEBUG
[assembly: Application(Debuggable = true)]
#else
[assembly: Application(Debuggable=false)]
#endif
And move them to MyApplication class instead
#if DEBUG
[Application(Debuggable = true, UsesCleartextTraffic = true)]
#else
[Application(Debuggable = false, UsesCleartextTraffic = false)]
#endif
public class MyApplication : Android.App.Application
{
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With