Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

problem with trying to create ssms add-in

Tags:

.net

ssms

add-in

I'm trying to create an add-in for SSMS 2008 and/or 2008 R2 but I've run into a problem straight away.

I can get my add-in to work and on SSMS start-up get it to simply show a message box.

However, after downloading various code-samples, when trying to reference Microsoft.SqlServer.Management.UI.VSIntegration.ServiceCache I get a null reference exception:

Commands2 commands = (Commands2)ServiceCache.ExtensibilityModel.Commands;

I get this problem when using SSMS 2008 or SSMS 2008 R2. I'm working on Visual Studio 2010.

It's a bit frustrating because I'm keen to learn more about SSMS add-ins but can't seem to get past the few samples out there.

Any advice/tips appreciated.

Thanks

like image 311
Karl Avatar asked Dec 17 '25 18:12

Karl


2 Answers

Karl, I don't know about your concrete problem here, but answering another question, I came across a bunch of articles and links on writing SSMS plug-ins - maybe one of them will be useful to you:

Some information can be found here:

  • The Black Art of Writing a SQL Server Management Studio Add-In
  • Building a SQL Server Management Studio Add-In
  • Extend Functionality in SQL Server 2005 Management Studio with Add-ins
  • SSMS Scripter - Internals, part 2 - plugging in
like image 170
marc_s Avatar answered Dec 20 '25 06:12

marc_s


ServiceCache is unreliable - from version to version it supports less and less and probable will go away at some point.

If you write SSMS Add-in, you can access internals by accessing VS ApplicationModel. Something like that:

public void OnConnection(object application, ext_ConnectMode connectMode, object addInInst, ref Array custom)
        {
            _addInInstance = (AddIn)addInInst;
            _applicationObject = _addInInstance.DTE as DTE2;

_applicationObject has Commands and other interesting stuff.

Please note, that application argument of OnConnection has an incorrect object passed in. That's why you have to use this line to get the right object: _applicationObject = _addInInstance.DTE as DTE2;

like image 31
TTRider Avatar answered Dec 20 '25 08:12

TTRider



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!