共用方式為


編譯器錯誤 CS0438

更新:2007 年 11 月

錯誤訊息

'module_1' 中的 'type' 型別與 'module_2' 中的 'namespace' 命名空間相衝突。

當原始程式檔中的型別與其他原始程式檔中的命名空間相衝突時,便會發生這個錯誤。當兩者或其中之一是來自加入的模組時,通常會發生這個錯誤。若要解決這個錯誤,請重新命名造成衝突的型別或命名空間。

下列範例會產生 CS0438:

請先編譯這個檔案:

// CS0438_1.cs
// compile with: /target:module
public class Util
{
   public class A { }
}

然後編譯這個檔案:

// CS0438_2.cs
// compile with: /target:module
namespace Util 
{
   public class A { }
}

最後編譯這個檔案:

// CS0438_3.cs
// compile with: /addmodule:CS0438_1.netmodule /addmodule:CS0438_2.netmodule
using System;
public class Test
{
   public static void Main() {
      Console.WriteLine(typeof(Util.A));   // CS0438
   }
}