컴파일러 오류 CS0438
오류 메시지
'module_1'의 'type' 형식이 'module_2'의 'namespace' 네임스페이스와 충돌합니다.
The type 'type' in 'module_1' conflicts with the namespace 'namespace' in 'module_2'.
이 오류는 소스 파일에 있는 형식이 다른 소스 파일에 있는 네임스페이스와 충돌하는 경우 발생합니다. 대개 형식이나 네임스페이스 중 하나 또는 모두가 추가 모듈에 있는 경우 이러한 충돌이 생깁니다. 이 오류를 해결하려면 충돌을 일으키는 형식 또는 네임스페이스의 이름을 바꿉니다.
다음 예제에서는 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
}
}