24/7 서버에서 실행되도록 설계된 응용 프로그램이 있습니다. Localy는 모든 것이 원활하고 예상대로 작동하는지 테스트했습니다. Windows Server 2012 R2에 배포 - 주 작업 (스레드)이 시작될 때마다 예외가 발생합니다.C# "주 스레드"에 예외 캐치
서버에는 분명히 Visual Studio가 없으므로 ig를 디버그 할 수 없습니다. 나는 "{ApplicationName}이 (가) 작동을 멈췄다."라고 말하는 추악한 Windows 대화 상자를 보았습니다.
EventViewer에서 오류의 위치를 나타내는 항목을 발견했습니다.
이벤트 로그는 말한다 :
Application: MyApplicationBackend.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: System.IO.FileNotFoundException
Stack:
at Application.Name.SomeClass..ctor()
at Application.Name.SomeThread()
at System.Threading.ThreadHelper.ThreadStart_Context(System.Object)
at System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object, Boolean)
at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, System.Threading.ContextCallback, System.Object)
at System.Threading.ThreadHelper.ThreadStart()
음, SomeClass의 생성자 내부에가는 중요한 아무것도 없다 -이 같은 단지 MySQL 데이터베이스 연결을, (어디 CFG 싱글 들고 구성이다. 값) :
//Connecto to server.
String connectionString = "server=" + cfg.DatabaseServer + ";user=" + cfg.DatabaseUser + ";database=" + cfg.DatabaseName + ";port=" + cfg.DatabasePort + ";password=" + cfg.DatabasePassword + ";";
mysqlConnection = new MySqlConnection(connectionString);
- MySQL의 커넥터 닷넷 6.8.3이 설치되어
- 코드가 원격 데이터베이스 (로컬 네트워크)에 연결될 것입니다.
- 코드는 로컬 컴퓨터에서 완벽하게 작동합니다.
1) 나는 (그리고 경우, 방법) 주 스레드에서 중첩 된 스레드의 모든 수준에서 표시 예외를 처리 할 수 있습니다? (동일 네트워크)
이이 개 질문을 제기?
2.) 어떤 종류의 파일이 발견 될 수 있습니까? (이 2 줄의 코드와 관련하여)? 및 localY의 작업 미세 (soure는 네트워크 공유에있는),하지만 내 서버에서 실행할 때 나는
그냥 물건을 디버깅 일부으로 메시지를 사용 (동일한 네트워크 공유에서 같은 exectuable 사용)이 예외를 얻을 그것은 나타나서처럼 ... 그리고 예외가 발생합니다 -
public class class1{
private void SomeThread(){
MessageBox.Show("before con");
DbCon dc = new DbCon();
MessageBox.Show("after con");
}
}
내가 "사기 전에"메시지를받을
public class DbCon{
public DbCon(){
MessageBox.Show("inside");
String connectionString = "server=" + cfg.DatabaseServer + ";user=" + cfg.DatabaseUser + ";database=" + cfg.DatabaseName + ";port=" + cfg.DatabasePort + ";password=" + cfg.DatabasePassword + ";";
mysqlConnection = new MySqlConnection(connectionString);
}
}
을 ... 궁극적으로는 다음과 같습니다 t는
DbCon
-Class를 찾지 못하지만 실행 파일의 일부이므로
File-Not-Found-Exception
을 실행할 수 없습니다. ?? !! (그리고 로컬 컴퓨터에서 작동합니다 :-() ...
아마도'cfg'가 파일에서 구성을 읽으려고 시도하고 그 파일이 서버에 없습니까? – Medo42
@ Medo42, 작동이 확인되었습니다. (예, 싱글 톤은 파일에서 읽는 중입니다. 그러나 앱 시작시 읽었을 때만 앱 닫기로 다시 쓰기 만합니다.) – dognose
다음으로 'MySqlConnection' 클래스를 찾을 수 없습니까? 실행은 실제 생성자 코드에 도달하는 것처럼 보이지 않지만 생성자에 대한 호출까지 모든 것이므로 참조 된 클래스를로드하지 못할 수도 있습니다. 그런 다음 mysqlconnection이 유형이 'MySqlConnection' 인 경우 다시 Cctor에서 이미 실패했을 것입니다. – Medo42