두 개의 서로 다른 프로젝트에 두 개의 거의 동일한 코드 블록이 있습니다. 두 번째 프로젝트는 첫 번째 프로젝트와 동일한 ConnectClass를 사용하도록 만들어졌습니다."다음 방법 또는 속성 사이에서 호출이 모호합니다"동일한 코드
가호 모호 :
그러나 새로운 프로젝트 (아래 번째 코드 블록)에서, 컴파일러는 오류 처리기 정적 무효 client_ErrorEvents 관한 다음 오류 메시지 (오브젝트 송신자 abcErrorEventArgs E)를 제공한다 'ProjectName.ConnectClass.client_ErrorEvents (객체 abcErrorEventArgs)'및 'ProjectName.ConnectClass.client_ErrorEvents (객체 abcErrorEventArgs)'HERE
는 (관련 부분에서) 제 CODE 블록 다음 방법 또는 속성 간의public partial class ConnectClass
{
public static a.b.c.Client client = new a.b.c.Client();
public static string DriveLetter;
public static string CurrentDate;
//_____________________
public static void StoreVars(Form1 frm)
{
DriveLetter = frm.textBox4.Text;
CurrentDate = frm.textBox5.Text;
}
public static string Connect(Form1 frm, int Call)
{
string host = "127.0.0.1";
int port = 7496;
int clientId = 0;
string Result = "Connected";
try
{
client.Connect(host, port, clientId);
}
catch (SocketException e)
{
Result = e.ToString();
}
//if (Call == 0)
client.Error += new EventHandler<a.b.c.ErrorEventArgs>(client_ErrorEvents);
return Result;
}
static void client_ErrorEvents(object sender, a.b.c.ErrorEventArgs e)
{
int ErrorCode;
string path = DriveLetter + "/ThisPath/File.txt";
FileStream ThisFile = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(ThisFile);
DateTime dtNow = DateTime.Now;
ErrorCode = (int)e.ErrorCode;
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.Write(dtNow);
sw.Write(" ");
sw.Write(e.ErrorCode);
sw.Write(" ");
sw.Write(e.ErrorMsg);
sw.Write(sw.NewLine);
sw.Close();
ThisFile.Close();
}
HERE
10 (관련 부분에서) 두 번째 코드 블록
public partial class ConnectClass
{
public static a.b.c.Client client = new a.b.c.Client();
public static string DriveLetter;
public static string CurrentDate;
//_____________________
public static void StoreVars(Form1 frm)
{
DriveLetter = frm.TBx_Drive.Text;
CurrentDate = frm.TBx_Date.Text;
}
public static string Connect(Form1 frm)
{
string host = "127.0.0.1";
int port = 7496;
int clientId = 10;
string Result = "Connected";
try
{
client.Connect(host, port, clientId);
}
catch (SocketException e)
{
Result = e.ToString();
}
client.Error += new EventHandler<a.b.c.ErrorEventArgs>(client_ErrorEvents);
return Result;
}
// 컴파일러 에러 신호 WHERE이된다
static void client_ErrorEvents(object sender, a.b.c.ErrorEventArgs e)
{
string path = DriveLetter + "/ThisPath/File.txt";
FileStream ThisFile = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
StreamWriter sw = new StreamWriter(ThisFile);
DateTime dtNow = DateTime.Now;
ErrorCode = (int)e.ErrorCode;
sw.BaseStream.Seek(0, SeekOrigin.End);
sw.Write(dtNow);
sw.Write(" ");
sw.Write(e.ErrorCode);
sw.Write(" ");
sw.Write(e.ErrorMsg);
sw.Write(sw.NewLine);
sw.Close();
ThisFile.Close();
}
어떤 아이디어?
대단히 감사합니다.
서로 다른 프로젝트 인 경우 이름 충돌이 발생하지 않을 것입니다. – BartoszKP
@BartoszKP 어떻게 든 두 부분이 "새 프로젝트"에서 볼 수 있으므로 하나 또는 둘 모두에서 부분적으로 제거하면 두 클래스가 계속 표시됩니다 ... 이름 충돌이 예상됩니다. –
알렉세이가 맞습니다. 두 번째 프로젝트에는 동일한 이름의 이벤트 핸들러가 이벤트 처리기가 포함 된 동일한 부분 클래스의 별도 파일에 이미 있습니다. 두 번째 파일에는 다른 프로그래머가 작성한 많은 수의 이벤트 처리기가 포함되어 있으며 처리기가 있다는 것을 모릅니다. 알았어, 고마워. 알렉세이. – CSMasm