我正在尝试为 SSMS 2008 和/或 2008 R2 创建加载项,但我立即遇到了问题。
我可以让我的加载项正常工作,并在 SSMS 启动时让它仅显示一个消息框。
但是,下载各种代码示例后,在尝试引用 Microsoft.SqlServer.Management.UI.VSIntegration.ServiceCache 时,出现空引用异常:
Commands2 commands = (Commands2)ServiceCache.ExtensibilityModel.Commands;
使用 SSMS 2008 或 SSMS 2008 R2 时遇到此问题。我正在使用 Visual Studio 2010。
这有点令人沮丧,因为我很想了解有关 SSMS 加载项的更多信息,但似乎无法超越那里的几个示例。
任何建议/提示表示赞赏。
谢谢
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
发布评论
评论(6)
Karl,我不知道你在这里的具体问题,但回答另一个问题时,我发现了一堆关于编写 SSMS 插件的文章和链接 - 也许其中一篇对你有用:
可以在这里找到一些信息:
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:
ServiceCache 是不可靠的——从一个版本到另一个版本,它支持的越来越少,并且可能会在某个时候消失。
如果您编写SSMS Add-in,则可以通过访问VS ApplicationModel来访问内部。
类似的东西:
_applicationObject 有命令和其他有趣的东西。
请注意,OnConnection 的 application 参数传入了不正确的对象。这就是为什么您必须使用此行来获取正确的对象:_applicationObject = _addInInstance。 DTE 为 DTE2;
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:
_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;
我已经为此苦苦挣扎了一段时间。
我有一个在 sql 2008 中工作的插件 - 用 VS2008 编写。
我将项目升级到 VS2010 并开始致力于让 sql 2008 r2 加载项正常工作 - 我无法因为爱和金钱而让它工作。
我尝试了很多不同的事情;
* 删除并重新添加所有引用。
* 改变目标框架。
不是香肠。
没有任何效果....
直到我回到 VS2008 - 我进行了更改。 (请参阅 Jonathan Kehayias 博客:https://www.sqlskills.com/blogs/jonathan/sql-server-2012-extended-events-add-in-to-manage-2008r2-instances/)
万岁新版本!!
I've been struggling with this for a while.
I've got an add-in what work in sql 2008 - written in VS2008.
I upgraded the project to VS2010 and started working on getting the sql 2008 r2 add-in working - I could not get this working for love nor money.
I tried lots of different things;
* deleting and re-adding all the references.
* changing the target framework.
Not a sausage.
Nothing worked....
Until I went back to VS2008 - I made the changes. (see Jonathan Kehayias blog: https://www.sqlskills.com/blogs/jonathan/sql-server-2012-extended-events-add-in-to-manage-2008r2-instances/)
Hurray for new versions!!
好的,我找到解决方案,问题出在 CLR2.0 和 CLR 4.0 之间
来源:http://blogs.msdn.com/b/mshneer/archive/2010/03/19/com-shim-wizards-for-vs-2010.aspx< /a>
Ok I find solution, the problem is between CLR2.0 and CLR 4.0
Source : http://blogs.msdn.com/b/mshneer/archive/2010/03/19/com-shim-wizards-for-vs-2010.aspx
我有同样的问题。我认为它更喜欢 Framework
3.5
对于 Framework 4.0,
I've the same problem. I think that it's liked to the Framework
With Framework 3.5
With Framework 4.0
好的,谢谢你的这种方式,但是如果我有一个 Framework 3.5 中的项目,VS2010 不会在我的断点处停止。
但是如果我将Framework更改为4,VS2010就会在断点处停止。但 CreateToolWindow2 引发异常,因为不是同一个 Framework !
我将代码简化为最少:
Ok, thanks for this way, but if I have a project in Framework 3.5, VS2010 doesn't stop on my break point.
But if I change the Framework to 4, VS2010 stop on the breakpoint. But CreateToolWindow2 raise an exception, because isn't the same Framework !
I simplify the code as minimum :