How to update SQL addins to work in SSMS 2016?
Asked Answered
H

2

6

Years ago I wrote an addin to do specific things I want in SSMS. I use it all the time and have gone through the pain of working out how to get it running again each time a new version of SQL server breaks the addin model.

I've now installed SSMS 2016 side by side with 2014, but despite a lot of searching I can find nothing about how to update addins for 2016 and I have not found a way to do it. My addin continues to work in 2014.

To be clear, my addin uses the common approach of a class that implements IDTExtensibility2 and IDTCommandTarget:

public partial class SSMSAddin : IDTExtensibility2, IDTCommandTarget 
{
    /// <summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
    /// <param term='application'>Root object of the host application.</param>
    /// <param term='connectMode'>Describes how the Add-in is being loaded.</param>
    /// <param term='addInInst'>Object representing this Add-in.</param>
    /// <seealso class='IDTExtensibility2' />
    public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
    {
     .
     .
     .  
    }        
 .
 .
 .  
}

plus an XML configuration file (.addin) placed in one of the locations listed in the LookInFolders registry key such as

%APPDATA%\Microsoft\MSEnvShared\Addins

Evidently SSMS 2016 introduces changes such that existing addins will not work without some kind of rewrite. Also it seems it no longer uses the traditional .addin configuration file, as its registry entries no longer include the LookInFolders registry key which older versions use to find it. I read in the first of the two linked questions below that SSMS 2016 uses a new interface for addins, based on Visual Studio 2015 Shell, but I was unable to find any details of how to use the new interface or update legacy addin code.

Note: there are a couple of related SE questions Does the Poor Man's T-SQL formatting add-in for Management Studio 2012 work in Management Studio 2016? and SQL Server 2016 Plugins not working but they are different questions, people wanting to make third-party addins work. This question is about how to change my own addin to make it work in SSMS 2016.

Heimdall answered 10/10, 2016 at 3:49 Comment(0)
E
4

Indeed, .Addin are no longer supported. You need a VSIX project building into "C:\Program Files (x86)\Microsoft SQL Server\130\Tools\Binn\ManagementStudio\Extensions[Your extension name]". There is not much information on how to extend SSMS 2016 but:

Here is some documentation for VSIX projects: https://learn.microsoft.com/fr-fr/visualstudio/extensibility/index

That forum helped me a lot: https://www.sqlservercentral.com/Forums/1802009/Developing-Extensions-for-SSMS-2016

You can't use Connect.cs anymore. The link between SSMS and your code now works with commands and packages as explained in the second link I posted.

Hope that helps

Evaluate answered 14/6, 2017 at 18:41 Comment(3)
Sounds promising! Thanks, I'll take a look and respond further.Heimdall
Yes, very good, this was the missing link. Now we're getting somewhere...Heimdall
Nice to hear that! Here is another link I found helpful as an example: github.com/ErikEJ/SqlCeToolbox/tree/master/src/GUI/SSMSToolboxEvaluate
H
1

Since the time when I asked this question back in 2016, Microsoft have continued to release new versions of SSMS without maintaining backward compatibility with existing extensions. There are details of the new changes needed for extensions to work in newer SSMS versions here:

SSMS 2017: https://www.codeproject.com/Articles/1243356/Create-Your-Own-SQL-Server-Management-Studio-SSMS

SSMS 2018: https://www.codeproject.com/Articles/1377559/How-to-Create-SQL-Server-Management-Studio-18-SSMS

Note 1: unless you are unable to (due to corporate restrictions etc), switch to SSMS 2018 or greater as soon as possible. New SSMS versions are always backwardly compatible with earlier databases, and, as of SSMS 2018, Microsoft removed the registry complications that previously caused so much grief for developers.

Note 2: pay careful attention to the Visual Studio version used to develop for a given SSMS version. Otherwise things are likely not to work. For example, for SSMS 2017, you should develop using VS2015, and for SSMS 2018, you should use VS2017. This is detailed further at the above links but in general, SSMS tends to be one behind the latest Visual Studio shell. You may be able to make it work with latest VS/assemblies too but this is a good rule of thumb to get something working.

Heimdall answered 11/12, 2019 at 12:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.