我使用以下代码访问 VSS 项目:
Dim sItem As String = "$/MyVssProject/InexistentFile.txt"
Dim oItem As SourceSafeTypeLib.VSSItem = Nothing
Try
oItem = m_oSourceSafe.VSSItem(sItem)
Catch ex As Runtime.InteropServices.COMException
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Exclamation)
End Try
我面临的问题是,当我尝试获取 VSSDB 中不存在的文件的实例时,会导致 COMException,这基本上不会有问题(我希望)。实际上发生了异常,但调试光标没有继续执行 catch 代码,而是停留在“oItem = m_oSourceSafe.VSSItem(sItem)”行上,显示一个标题为“COMException crossed a native/managed boundary”的对话框。
从这里开始执行不会继续,直到我将 sItem 的内容更改为现有文件。
为什么异常没有被捕获,我该如何实现呢?
环境:在 WinXP SP3 x86 上使用 .Net 2.0 的 VS2010
谢谢小伙伴们!