I use the following code to access a VSS item:
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
The problem I face is when I try to get an instance to a file that doesn’t exist in the VSSDB, thus leading to a COMException, which basically wouldn’t be of a problem (I would expect).
In fact the exception occurs, but instead of proceeding with the catch code, the debug cursor stays on the line “oItem = m_oSourceSafe.VSSItem(sItem)”, showing a dialog with title “COMException crossed a native/managed boundary.
From here the execution doesn’t proceed, until I change the content of sItem to an existing file.
Why does the exception not get caught, and how can I achieve it?
Environment: VS2010 with .Net 2.0 on WinXP SP3 x86
Thanks mates!
I found out how to catch:
In the project’s settings, on the “Debug” tab, select “Enable unmanaged code debugging”. From now on you should be able to chatch the exception.
The disadvantage of this though is, that it is no longer possible to edit code while stepping through the code.