잘못된 라인에서 시스템이 오류를보고했기 때문입니다. 문제 해결됨.모든 것이 null이 아니지만 시스템이 여전히 null 오류를 표시하도록했습니다.
ObjectReferenceException : 개체 참조가 개체의 인스턴스로 설정되지 않았습니다. D에 CheckRfqStatus.Program.StartCheckingRFQStatus (INT32 startDateVariable)에서 : PRIVACY \ Program.cs \ : 라인 121
선 121 :
MAPIFolder mapiFolderArchive = (MAPIFolder)outlook.Session.Folders[archiveFolderName].Folders["Inbox"].Parent;
if (null == (MAPIFolder)outlook.Session.Folders[archiveFolderName]) { logger.Debug("33"); }
if (null == (MAPIFolder)outlook.Session.Folders[archiveFolderName].Folders["Inbox"]) { logger.Debug("35"); }
if (null == (MAPIFolder)outlook.Session.Folders[archiveFolderName].Folders["Inbox"].Parent) { logger.Debug("4"); }
MAPIFolder archiveSentEmailToVendorFolder = mapiFolderArchive.Folders["Sent Email to Vendor"];
if (null == mapiFolderArchive) { logger.Debug("7"); }
if (null == mapiFolderArchive.Folders) { logger.Debug("8"); }
//Below is line 121
if (null == mapiFolderArchive.Folders["Sent Email to Vendor"]) { logger.Debug("9"); }
: 여기
if (null == mapiFolderArchive.Folders["Sent Email to Vendor"]) { logger.Debug("9"); }
는 관련있는 코드
로거에서 아무 것도 로깅하지 않았는데도 왜 줄 121에 여전히 Null 오류가 있습니까?
모든 조언에 따라 코드를 다시 작성합니다. 이미 if (mapiFolderArchive.Folders["Sent Email to Vendor"] != null)
을 선택한 경우
MAPIFolder mapiFolderArchive = (MAPIFolder)outlook.Session.Folders[archiveFolderName].Folders["Inbox"].Parent;
MAPIFolder defaultSentToVendorFolder = mapiFolderPurchase.Folders["Sent Email to Vendor"];
if (mapiFolderArchive.Folders != null)
{
if (mapiFolderArchive.Folders["Sent Email to Vendor"] != null)
{
MAPIFolder archiveSentEmailToVendorFolder = mapiFolderArchive.Folders["Sent Email to Vendor"];
//Now system said this line below got null reference exception error.
if (archiveSentEmailToVendorFolder != null)
왜 if (archiveSentEmailToVendorFolder != null)
는 null 참조 예외가있어?
'logger'가 null이 아닌가요? – wdosanjos
@ wdosanjos 아니요, 로거는 확실히 테스트하지 않았기 때문에 null이 아니며 프로그램 시작시에 기록 할 수 있습니다. – Pop
표준 복제가 사례를 설명하지 않는다고 생각하는 경우 실제로 null을 확인하는 곳에서 명확한 [MCVE]를 제공하십시오. 더 중요한 것은 일부 정보를 로깅하는 대신 null 객체의 속성에 대한 액세스를 차단하는 것입니다. "logger"가 실제로 아무것도 로그하지 않는다는 표시도 있습니다. (코드는 우리가 게시물에 제공하지 않았기 때문에) –