2016-02-16 36 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