我循環組件的文件夾中,尋找其類型的一個字段的DateTime在於範圍當前日期未來7天的其公佈的地位的基礎上的組件。|評論方法拋出InvalidUriException當組件被檢出
但是,如果任一組件被檢出然後|評論方法拋出一個異常InvalidUriException
。如果我不想通過捕獲異常並繼續循環來跳過此檢出組件,我該如何處理這種情況?
編輯: 第三行爲檢出組件輸出InvalidUriException
。
componentUri = new TcmUri(node.Attributes[CommonConstants.Id].Value).GetVersionlessUri();
dummyComponent = engine.GetObject(componentUri) as Component;
bool isPublished = PublishEngine.IsPublished(dummyComponent , publicationTarget);
PublishEngine的'IsPublished'是否會拋出異常?請重新說明你的要求,我不太瞭解情況。 – 2012-08-04 09:20:35
componentUri = new TcmUri(node.Attributes [CommonConstants.Id] .Value).GetVersionlessUri(); dummyComponent = engine.GetObject(componentUri)作爲組件; bool isPublished = PublishEngine.IsPublished(matchComponent,publicationTarget);第三個語句在檢出組件時引發異常。 – AlokBhatt 2012-08-04 11:32:15
代碼示例沒有解釋您的問題。 dummyComponent似乎與代碼的其餘部分沒有關係(並且這是錯誤的強制類型)。我們無法看到matchComponent的來源。你確定這不僅僅是你的代碼中的邏輯問題嗎?你可以放置一個斷點並獲得導致問題的Uri的值,然後查看該物品是否存在? – 2012-08-05 17:03:28