none
Writing a VB.NET extensibility project as a SSMS 2008 R2 add-in

    Question

  • Hi

    I am trying to write an add-in into the SSMS 2008 R2 IDE.  I believe it is possible, though maybe not fully supported by Microsoft. 
    I have created a new project in Visual Studio 2010 of type Extensibility - Visual Studio Add-in.  This has created my project and all of the relevant code to get the add-in loaded onto the Tools menu.  THe only line of code I have added is inot the OnConnection method to display a messagebox so I know it has at least loaded.

    When I build this as is, it will load as an Add-in into VS 2010 onto the Tools menu - which is fine - at least part is working.  But when I try to add this as an Add-in into SSMS 2008 it keeps giving me the error message:
    The Add-in 'DataFollower.Connect' failed to load or cause an exception.  Would you like to remove this add-in? ... Error Message: Class not registered  Error number: 80040154
    To get this add-in registerd in SSMS I followed the methods found using google searches.  And loaded into the registry :

    Windows Registry Editor Version 5.00

    [HKEY_CURRENT_USER\SOFTWARE\Microsoft\Microsoft SQL Server\100\Tools\Shell\Addins\DataFollower.Connect]
    "CommandLineSafe"=dword:00000000
    "LoadBehavior"=dword:00000001
    "ProductDescription"="DataFollower"
    "ProductName"="DataFollower"
    "SatelliteDllName"="DataFollower.dll"
    "SatelliteDllPath"="D:\\VB2008\\DataFollower\\DataFollower\\bin\\"

    This is all on a Windows 7 64bit machine, running SQL 2008 R264 bit and Visual Studio 2010.

    Is there anything obvious I am doing wrong - or is this just not possible in SSMS 2008?

    Thanks
    Rod

     

     

    Monday, June 7, 2010 1:08 AM

Answers

  • I haven't.

    I've given up on my project - for now.  I'm putting it down to changes in SQL 2008 R2 so it no longer supports the add-in projects from VS 2010.
    If you have any luck, let me know.

     

    Saturday, September 25, 2010 10:00 AM
  • You can no longer get to the DTE2 in this manner in SSMS 2008. But you can get there using the DTE property of the addInInst parameter to the OnConnection function:

     

    _addInInstance = (AddIn)addInInst;

    _applicationObject = (DTE2)_addInInstance.DTE;

     

    And thanks, I was wondering why my addin wasn't working on windows 7, I was creating the registry entry it in HKLM as I did when I was working on XP, not HKCU. Works now!

    Monday, January 3, 2011 4:46 AM

All replies

  • Hi Rod,

    Generally speaking, the issue occurs when the add-in registration is incorrect or the add-in throws an exception on load.

    From your descriptions, the registration looks good. So, the issue seems to be caused the code.

    I would suggest you debuging the code to check the issue.
    Or, if possible, please send us the sample code, I will try to debug it to find the cause.

    Thanks,
    Jin Chen


    Jin Chen - MSFT
    Tuesday, June 8, 2010 8:12 AM
    Moderator
  • Thanks Jin

    I've moved one step closer.  I added a setup project into the solution and if I install it that way (and adding the registry patch) it gets passed the 'class not registered error'.
    But now, the reason why it fails to load is 'No such interface supported.'

    Below is a top half of the code in questions.  This code was created directly from the VS Add-in template - nothing has been altered.  The error occurs on the highlighted line, when it tries to cast into the DTE2 type.

    I've heard of other people getting this problem - but no solution.

    Thanks
    Rod

    Imports System
    Imports Microsoft.VisualStudio.CommandBars
    Imports Extensibility
    Imports EnvDTE
    Imports EnvDTE80

    Public Class Connect
     
        Implements IDTExtensibility2
        Implements IDTCommandTarget
        Private _applicationObject As DTE2
        Private _DTE2 As DTE2
        Private _DTE As DTE
        Private _addInInstance As AddIn

        '''<summary>Implements the constructor for the Add-in object. Place your initialization code within this method.</summary>
        Public Sub New()

        End Sub

        '''<summary>Implements the OnConnection method of the IDTExtensibility2 interface. Receives notification that the Add-in is being loaded.</summary>
        '''<param name='application'>Root object of the host application.</param>
        '''<param name='connectMode'>Describes how the Add-in is being loaded.</param>
        '''<param name='addInInst'>Object representing this Add-in.</param>
        '''<remarks></remarks>
        Public Sub OnConnection(ByVal application As Object, ByVal connectMode As ext_ConnectMode, ByVal addInInst As Object, ByRef custom As Array) Implements IDTExtensibility2.OnConnection

            _applicationObject = CType(application, EnvDTE80.DTE2)
            _addInInstance = CType(addInInst, AddIn)

            If connectMode = ext_ConnectMode.ext_cm_UISetup Then

                Dim commands As Commands2 = CType(_applicationObject.Commands, Commands2)
                Dim toolsMenuName As String = "Tools"
    ......

    Friday, June 11, 2010 3:19 AM
  • I hope you got this working already.  If not, my working line looks like this:

      _applicationObject = CType(application, DTE2)
    
    

    ...without the "EnvDTE80."  Maybe that helps you or someone?

    Cheers!

    Jordan

    P.S. This post was extremely helpful on the deployment of my add-in.  Thanks.

     

    Thursday, July 15, 2010 12:57 AM
  • How did you resolve the "Class Not Registered" error. Can you post more details please. I'm getting the same error and I made a Setup project also, but I'm still getting the error. I appreciate your help.
    Wednesday, September 22, 2010 5:14 AM
  • I haven't.

    I've given up on my project - for now.  I'm putting it down to changes in SQL 2008 R2 so it no longer supports the add-in projects from VS 2010.
    If you have any luck, let me know.

     

    Saturday, September 25, 2010 10:00 AM
  • You can no longer get to the DTE2 in this manner in SSMS 2008. But you can get there using the DTE property of the addInInst parameter to the OnConnection function:

     

    _addInInstance = (AddIn)addInInst;

    _applicationObject = (DTE2)_addInInstance.DTE;

     

    And thanks, I was wondering why my addin wasn't working on windows 7, I was creating the registry entry it in HKLM as I did when I was working on XP, not HKCU. Works now!

    Monday, January 3, 2011 4:46 AM