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 VsTextViewCreated
method, Visual Studio informs me that it will never be hit. Opening files in the second instance of Visual Studio that launches in the debugger indeed does not trigger it.
What am I doing wrong?
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 a MefComponent asset in your extension manifest:
And make sure in .csproj:
<IncludeAssemblyInVSIXContainer>true</IncludeAssemblyInVSIXContainer>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With