2016-02-16 35 views
2

我在我的应用程序类中有编译错误。这里是我的代码有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 

这是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(); 
    } 

我收到此错误信息:

应用程序不能同时拥有键入[应用程序]属性 和[程序集:应用程序]属性

谢谢你有关如何解决这个问题的任何建议。

回答

5

SOLUTION: 只是删除行中的AssemblyInfo.cs

(#if DEBUG ... #endif) 

并更换线

[Application] 

(在你的类)具有下列之一:

#if DEBUG 
    [Application(Debuggable = true)] 
#else 
    [Application(Debuggable=false)] 
#endif 
1

我也遇到过一次,当时我把这段删掉就编译过了...

#if DEBUG 
[assembly: Application(Debuggable = true)] 
#else 
[assembly: Application(Debuggable=false)] 
#endif 

其他的方式,你可以尝试一下 https://forums.xamarin.com/discussion/7670/error-while-preparing-an-application-for-release

+0

(因此)是一个仅限英语的网站。请用英文发表。 [见这里](https://meta.stackexchange.com/q/13676/204869),[这里](https://meta.stackoverflow.com/a/262054/1402846)和[here](https: //blog.stackoverflow.com/2009/07/non-english-question-policy)了解详情。谢谢。 – Pang