How to change default error search in Visual Studio 2015

后端 未结 4 1899
予麋鹿
予麋鹿 2021-01-08 01:20

While I was writing my code in Visual Studio 2015CTP I got error as below in ErrorList window:

Error CS0117 \'Console\' does not co

4条回答
  •  太阳男子
    2021-01-08 01:39

    Simply redirecting the search provider probably won’t work. We generate a search string that is tailored to work with a specialized search engine on the Bing side. Passing that same search string to another search engine probably will give poor results.

    What you will need to do, instead, is define your own handler for the help event. This would extract relevant information from the error itself (such as error code, language, etc.) to create a generic search that would work with the provider of your choice. If this handler comes before the default handler, then you can handle the event and prevent the default (bing) search from executing.

    The interfaces your need to implement are:

    ITableControlEventProcessorProvider

    This is a MEF export and should have the following attributes:

    [Export(typeof(ITableControlEventProcessorProvider))]
    [DataSourceType(StandardTableDataSources.ErrorTableDataSourceString)]
    [DataSource(StandardTableDataSources.AnyDataSourceString)]
    [ManagerIdentifier(StandardTables.ErrorsTableString)]
    [Name("my custom event processor name")]
    [Order(Before=Priority.Default)]  
    

    ITableControlEventProcessor

    It is probably best to define a class that is derived from TableControlEventProcessorBase (which provides default/no-op implementations for all of the events) and then explicitly handle the PreprocessNavigateToHelp(ITableEntryHandle entry, TableEntryEventArgs e) event by:

    1. extracting the useful data from entry
    2. creating a generic search to the search provider of your choice
    3. opening an instance of the browser
    4. setting e.Handled to true (to prevent the other help handlers from executing).

提交回复
热议问题