簡體   English   中英

“內部類”不在一個庫中編譯,而是在新的類庫中工作

[英]“internal class” not compiling in one library, but working in a new class library

我有一個內部屬性,在其定義的程序集中不可見。

屬性

namespace Stuff {

  [AttributeUsage(AttributeTargets.Class, Inherited = false, AllowMultiple = false)]
    internal sealed class LogActionsAttribute : Attribute {

        internal LogActionsAttribute() { }
    }
}

此類在同一程序集中定義,並產生編譯錯誤。

namespace OtherStuff {

  [Stuff.LogActionsAttribute]
    class MyClass {

        void D() {


        }
    }

}

錯誤1命名空間“Stuff”中不存在類型或命名空間名稱“LogActionsAttributeAttribute”(您是否缺少程序集引用?)

有任何想法嗎?

如果該類型在項目內,那么它可能是名稱空間沖突; 嘗試:

[global::Stuff.LogActions]
class MyClass { ... }

這避免了與其他命名空間中的Stuff沖突。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM