Question

In a VS2010 package, I have a piece of code that calls FileCodeModel.CodeElements, when the caret position changes. Also I registered a handler in the CodeModelEvents bound to the document.

When the package monitors a C# project, it works OK. However, when monitoring a VB project, the FileCodeModel.CodeElements call fails with an COMException that corresponds to an E_FAIL error.

any ideas why the behavior is different?

Was it helpful?

Solution

The C# and VB.net code models are completely separate implementations that both have their associated quirks.

In VB.Net the caret position change is part of a larger set of events which can trigger the line commit logic in the IDE. I'm not really surprised that it throws in this particular event, especially if the buffer is dirty.

One way to possibly work around this is to wait util the idle event after the caret move and query CodeElements there.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top