I use ServiceCache.ScriptFactory.CurrentlyActiveWndConnectionInfo (from Microsoft.SqlServer.SqlTools.VSIntegration.VS.dll assembly) to get connection string for currently opened tab.
The problem is that if SQL Server Data Tools is installed NullReferenceException will be generated in ServiceCache.ScriptFactory property.
Analyzed disassembled propery and found that service provider is null. The only ways to initialize it - use SQLWorkbenchPackage.SetSite or ServiceCache.Init methods. But in this case IServiceProvider should be implemented.
Tried to use ScriptFactory.Instance.CurrentlyActiveWndConnectionInfo (from SQLEditors.dll assembly). But COMException is generated - after disassembling found that it happens because current connection isn't found.
Guys, any thoughts? How can I load connection information when SSDT is installed?
UPDATE: Tried to use DTE as IServiceProvider instance - current connection wasn't found (CurrentlyActiveWndConnectionInfo property value is null).
Based on this issue related to Sql, I am suggesting you go to sql forum to get help.
I am moving this thread to SQL Server Data Tools forum.
Thank you for your understanding and support.
I want nothing to clone. The only thing I want to get connection string (or SqlConnection instance) of currently opened sql tab. And the problem is that SSDT "breaks" working method.
Server Explorer data doesn't match as I can open sql tab (CTRL+O any sql file), manage connection for this tab and there is no connection in Server Explorer at the same time.
I suspect SSDT provides another solution for my problem. Otherwise it breaks working one.
As far as I know we don't allow you to get to the SqlConnection of the SQL editor due to security restrictions, we never allowed this.
-GertD @ www.sqlproj.com