What is the minimum working implementation of an IVsTextViewCreationListener?
I created a VISX project and wrote this piece of code:
using Microsoft.VisualStudio.Editor;
using Microsoft.VisualStudio.TextManager.Interop;
using System.ComponentModel.Composition;
namespace MyExtension
{
[Export(typeof(IVsTextViewCreationListener))]
public class Main : IVsTextViewCreationListener
{
public void VsTextViewCreated(IVsTextView textViewAdapter)
{
}
}
}
If I put a breakpoint inside the method VsTextViewCreated
, Visual Studio will tell me that it will never get hurt. Opening the files in a second instance of Visual Studio that runs in the debugger doesn't really call it.
What am I doing wrong?
+3
source to share
1 answer
You need to specify ContentType and TextViewRole for your class:
[Microsoft.VisualStudio.Utilities.ContentType("text")]
[Microsoft.VisualStudio.Text.Editor.TextViewRole(Microsoft.VisualStudio.Text.Editor.PredefinedTextViewRoles.Editable)]
Also don't forget to declare the MefComponent resource in your extension manifest:
+4
source to share