我认为必须包含的一些功能包括:
情侣功能增加:
注意:有很多理由需要打印代码......一个非常好的是托管.
我在代码视图中使用右键菜单编写了visual studio(2010)扩展.我希望能够从我的菜单项事件处理程序中检查当前代码,但是无法在对象模型中找到某个位置来执行此操作.
如何在visual studio扩展中访问当前窗口中的代码?
下面是我用来获取当前文档文本的代码
DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE ;
TextDocument activeDoc = dte.ActiveDocument.Object() as TextDocument;
var text = activeDoc.CreateEditPoint(activeDoc.StartPoint).GetText(activeDoc.EndPoint);
Run Code Online (Sandbox Code Playgroud) c# visual-studio-2010 vspackage vsix visual-studio-extensions
我的Visual Studio(2010 SP1)有严重的内存泄漏,它似乎是由一个或多个已安装的扩展引起的.
我试图通过打开和关闭扩展和附加组件来缩小范围,但是需要花费一些时间来构建重大泄漏,结果并不完全是结论性的.在devenv.exe进程使用2GB内存并开始丢弃之前,它很少需要几个小时,这对于使用起来有点麻烦.
有没有办法让VS在为扩展分配的内存上发出信息?
托管扩展是否在自己的AppDomain中运行?也许这会让我打开一些可以帮助查明问题的性能计数器.
还有什么我可以解决这个问题,除了逐个禁用东西,直到问题消失?
我正在编写一些设计时间代码.我想使用这个片段:( 在这里找到)
var dte = (EnvDTE.DTE) GetService(typeof(EnvDTE.DTE));
if (dte != null)
{
var solution = dte.Solution;
if (solution != null)
{
string baseDir = Path.GetDirectoryName(solution.FullName);
}
}
Run Code Online (Sandbox Code Playgroud)
问题是这不能编译.(GetService不是已知的方法调用)我尝试添加Microsoft.VisualStudio.Shell(和Microsoft.VisualStudio.Shell.10.0),但它没有帮助.
在互联网上环顾四周,我发现你需要一个IServiceProvider来调用它.
但所有显示如何使IServiceProvider使用EnvDTE的示例.
所以,要获得当前的EnvDTE,我需要IServiceProvider.但要获得IServiceProvider,我需要一个EnvDTE.(我的桶里有一个洞......)
所以,这是我的问题:
在普通的WPF应用程序中,如何获取EnvDTE 的当前实例?
注意:我不是在寻找任何旧的EnvDTE实例.我需要一个用于我当前的Visual Studio实例(我一次运行3-4个Visual Studio实例.)
.net visual-studio-2010 visual-studio envdte visual-studio-extensions
我刚刚将Visual Studio扩展RazorGenerator升级到V1.5(上次更新时间为10/14/2012),现在出现以下问题.
如果我选择"运行自定义工具",现在编辑的每个cshtml文件都会删除生成的文件 The custom tool 'RazorGenerator' failed. The method or operation is not implemented.
我以前在我的项目中工作没有问题,但升级似乎打破了它.有谁知道如何解决这个问题?因为它是通过ExtensionManager安装的,所以我现在甚至无法回滚到以前的版本.
最新版本的Nuz中的RazorGenerator.MVC是1.4(2012年4月20日,星期五),所以版本不匹配可能是问题..?
我已经尝试重启VS和我的机器没有成功,我甚至卸载了扩展并重新安装,但也没有用.
Exception calling "RunCustomTool" with "0" argument(s): "The custom tool 'RazorGenerator' failed. The method or operation is not implemented."
At D:\Source\MySolution\MyProject\packages\RazorGenerator.Mvc.1.4.0.0\tools\RazorGenerator.psm1:32 char:32
+ $_.Object.RunCustomTool <<<< ()
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ComMethodTargetInvocation
Exception calling "GetItem" with "1" argument(s): "The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))"
At D:\Source\MySolution\MyProject\packages\RazorGenerator.Mvc.1.4.0.0\tools\RazorGenerator.psm1:62 char:46
+ $solutionExplorer.GetItem <<<< ("$SolutionName\$ProjectName$relativePath").UIHierarchyItems.Expanded …Run Code Online (Sandbox Code Playgroud) asp.net-mvc asp.net-mvc-3 visual-studio-extensions razorgenerator
我想配置一个RexEx来匹配任何打开文件的文件路径的任何文件夹(父或子).因此,如果文件路径中的任何文件夹包含打开文件的名称,则选项卡的颜色编码将根据RegEx匹配进行设置.
例如:websiteRoot/Content/MyName1/site.css =文件打开时的绿色标签
websiteRoot/Content/MyName2/site.css =文件打开时的橙色标签
打开文件时,websiste/Shared/MasterPages/MyName1/main.master =绿色标签
websiste/Shared/MasterPages/MyName2/main.master =文件打开时的橙色标签
我试过了:
.*MyName1?$但这只是看我认为的文件名.
还尝试过.*//MyName1//?$,如果此扩展的Regex在打开的文件路径上直接匹配,我认为下一个可以做到这一点:^.*\\MyName1
更有希望的正则表达式没有成功:
.*websiteRootPath.*MyName1|myname1|myName1
Run Code Online (Sandbox Code Playgroud)
如果Power Productivity Tools处理打开文件的相对路径:
.*MyName1|myname1|myName1
Run Code Online (Sandbox Code Playgroud) 我正在使用SettingsManager我的Visual Studio扩展来存储用户设置.
SettingsManager settingsManager = new ShellSettingsManager(ServiceProvider.GlobalProvider);
var store = settingsManager.GetWritableSettingsStore(SettingsScope.UserSettings);
Run Code Online (Sandbox Code Playgroud)
我有一个自定义的WPF选项页面,如本文所述.我还想将我的扩展设置为使用导入/导出设置,因此我按照创建选项页面和创建设置类别页面,将其添加到我的包属性:
[ProvideProfile(typeof(OptionsDialogPage), "Unit Test Boilerplate Generator", "Unit Test Boilerplate Generator Settings", 106, 107, true, DescriptionResourceID = 108)]
[ProvideOptionPage(typeof(OptionsDialogPage), "Unit Test Boilerplate Generator", "Templates", 101, 109, supportsAutomation: true)]
Run Code Online (Sandbox Code Playgroud)
我成功地将其显示为导入/导出设置下的标题,但导出后我的数据都没有存储SettingsManager.我一直在寻找在下方的选项ProvideProfile,并ProvideOptionPage和尝试设置SupportsProfiles = true,但没有帮助.
如何挂钩这两个系统?
(编辑)我运行了Process Monitor,在这里找到了SettingsManager键(CollectionPath UnitTestBoilerplateGenerator):
\REGISTRY\A\{08894cfc-f3a9-f49b-133e-3453dfe7a27d}\Software\Microsoft\VisualStudio\15.0_a703f143Exp\UnitTestBoilerplateGenerator\Template_VisualStudio_Moq_File
Run Code Online (Sandbox Code Playgroud)
此处存储的内置选项(来自另一个扩展的示例):
\REGISTRY\A\{22e40365-b8e3-e9b2-1315-55021a1e4c3d}\Software\Microsoft\VisualStudio\15.0_a703f143\ApplicationPrivateSettings\Xavalon\XamlStyler\Core\Options\StylerOptions\NoNewLineElement
Run Code Online (Sandbox Code Playgroud)
所以它们似乎存储在不同的区域.有没有办法以编程方式编写这些内置选项或在导入/导出中包含自定义CollectionPath?
参考AnkhSVN Visual Studio 2019的安装,虽然可以成功安装,但在Visual Studio 2022中仍然无法使用

活动日志.xml:
包的 CreateInstance 失败 [AnkhSVN - Visual Studio 的 Subversion 支持]源:'mscorlib' 描述:无法加载文件或程序集 'file:///c:\users\xxxx\appdata\local\microsoft\visualstudio\17.0_1d0575ca\ Extensions\mhbmk1bf.g1d\Ankh.Package.dll' 或其依赖项之一。
我正在寻找一个可视工作室插件,它可以拦截默认的在线帮助命令,并F1在类或类型上调用帮助时获取MSDN库URL .
例如,假设我将光标放在关键字字符串上并按下F1它通常会自动打开浏览器并导航到帮助文档以获取字符串引用类型.我想抓住在浏览器到达浏览器之前传递给浏览器的URL.
是否有可能编写一个可以拦截默认F1帮助命令的visual studio插件/扩展?
如果以上可以做任何指针,从哪里开始?
c# visual-studio-addins visual-studio visual-studio-extensions visual-studio-2012