How to get active IWpfTextView in VS2019 extension (MEF)
问题 I'm trying to get the active C# Editor IWpfTextView in VS2019 extension. I'm using a small MEF service to inject a view into the VSAsyncPackage. But it is not very reliable - sometimes the injected view is wrong (e.g. from another view) or missing. Here is the service: public interface IActiveViewAccessor { IWpfTextView? ActiveView { get; } } [Export(typeof(IWpfTextViewConnectionListener))] [Export(typeof(IActiveViewAccessor))] [ContentType("text")] [TextViewRole(PredefinedTextViewRoles