简体   繁体   中英

Building a SQL Server Management Studio Extension via Visual Studio 2017 VSIX project: Bypass Initialiaze() for AsyncPackage class

I am using this guide to build a SSMS extension via visual studio 2017 VSIX project: https://www.codeproject.com/Articles/1243356/Create-Your-Own-SQL-Server-Management-Studio-SSMS

However, I am stuck on the last step. I did everything it said, but the project won't build because I get this error message from the Initialize() method:

protected override void Initialize()

  1. 'HelloWorldCommandPackage.Initialize()': cannot override inherited member 'AsyncPackage.Initialize()' because it is sealed.

It seems that creating a new VSIX Project in Visual Studio 2017 use the 'AsyncPackage' class for the HelloWorldCommandPackage.cs which seal the Initialize() method.

The guy in the article wrote it for Visual Studio 2015 which uses the 'Package' class when creating a new VSIX Project. I try implementing the 'Package' class after creating the main class like this:

public sealed class HelloWorldCommandPackage: Package

However, I get these errors:

  1. Error CS0115 'HelloWorldCommandPackage.InitializeAsync(CancellationToken, IProgress)': no suitable method found to override HelloWorldSsmsExtension

  2. Error VSSDK002 The PackageRegistrationAttribute.AllowsBackgroundLoading should be set to true if and only if the package derives from AsyncPackage.

  3. Error CS1061 'HelloWorldCommandPackage' does not contain a definition for 'JoinableTaskFactory' and no accessible extension method 'JoinableTaskFactory' accepting a first argument of type 'HelloWorldCommandPackage' could be found (are you missing a using directive or an assembly reference?)

  4. Error CS1503 Argument 1: cannot convert from 'HelloWorldSsmsExtension.HelloWorldCommandPackage' to 'Microsoft.VisualStudio.Shell.AsyncPackage'

How do I make this work in Visual Studio 2017?

Method overriding is possible only in derived classes. Because a method is overridden in the derived class from base class. A method must be a non-virtual or static method for override. Both the override method and the virtual method must have the same access level modifier.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM