开发者

How do i get the solution name when running from a extension?

I'm coding an extension in C# using the Managed Extensibility Framework (MEF).

How c开发者_高级运维an I get the current open solution name or the project names?

The class i'm been digging deep in is the IWpfTextView but I didn't find it.


If you have a Package class in your assembly, you can do:

DTE2 = Package.GetGlobalService(typeof(SDTE)) as DTE2; string fullName = dte.Solution.FullName;

Otherwise you can get the DTE via: DTE dte = System.Runtime.InteropServices.Marshal.GetActiveObject("VisualStudio.DTE") as DTE; string fullName = dte.Solution.FullName;

and I see people talk about a more 'MEF' oriented way of the getting the DTE but I've not tried it..

Once you have the DTE object you can then traverse the projects with the solution.

ref: VSIX: Getting DTE object ref: http://msdn.microsoft.com/en-us/library/envdte.solution.aspx

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜