简体   繁体   English

Visual Studio包的调用函数

[英]Call function of Visual Studio Package

I have created a new Visual Studio Package that when loaded creates a Tool Window that looks like this: 我创建了一个新的Visual Studio包,该包在加载时会创建一个如下所示的“工具”窗口:

在此处输入图片说明

It is comprised of some controls with canvases and such that draw shapes in 2 or 3 dimensions. 它由一些带有画布的控件组成,并且可以绘制2或3维的形状。 Right now they work in the initialization step to create the objects you see above. 现在,它们在初始化步骤中工作,以创建您在上面看到的对象。 For this tool to be useful I would like to call a method on those controls to pass it other objects to draw. 为了使该工具有用,我想在这些控件上调用一个方法以将其传递给其他对象以进行绘制。 For example, I am debugging some code with points and lines and want to see them graphically. 例如,我正在调试一些带有点和线的代码,并希望以图形方式查看它们。 (Perhaps using the Immeadiate Window? or something similar?) I would like to be able to call GeometryVisualToolWindow.DrawObject(myCircle); (也许使用Immeadiate窗口?还是类似的东西?)我希望能够调用GeometryVisualToolWindow.DrawObject(myCircle);

How can I access public methods within the package and pass arguments? 如何访问包中的公共方法并传递参数?

I don't want to use a debugger visualizer because I want to be able to selectively add and remove objects from the scene, where a debugger visualizer will only show the single object. 我不想使用调试器可视化器,因为我希望能够选择性地从场景中添加和删除对象,而调试器可视化器将仅显示单个对象。 (eg I want to see if two lines intersect, etc.) (例如,我想看看两条线是否相交,等等。)


Update 更新

I have attempted to use DTE.Debugger.GetExpression to solve the problem but after adding the appropriate references, I get this: 我试图使用DTE.Debugger.GetExpression解决问题,但是在添加了适当的引用之后,我得到了:

在此处输入图片说明

I'll give you an idea how to execute arbitrary code in visual studio debugging session. 我会给你一个想法,如何在Visual Studio调试会话中执行任意代码。

See automation model: http://i.msdn.microsoft.com/dynimg/IC75297.gif 请参阅自动化模型: http : //i.msdn.microsoft.com/dynimg/IC75297.gif

You have access to the instance of DTE.Debugger , this is described here: http://msdn.microsoft.com/en-us/library/aa291845(v=vs.71).aspx (Visual Studio Debugger Object Model). 您可以访问DTE.Debugger的实例,在这里对此进行了描述: http : //msdn.microsoft.com/zh-cn/library/aa291845 ( v=vs.71) .aspx (Visual Studio调试器对象模型)。

You then can choose: 然后,您可以选择:

1) Execute the actual statement in VS debugger( ExecuteStatement ). 1)在VS调试器( ExecuteStatement )中执行实际的语句。 This means you need to take care of loading all your assemblies into specific debugger session. 这意味着您需要注意将所有程序集加载到特定的调试器会话中。 The loaded assembly needs to take care of adding static function that user can call. 加载的程序集需要注意添加用户可以调用的静态函数。 Such as GeometryVisualToolWindow.DrawObject(myCircle); GeometryVisualToolWindow.DrawObject(myCircle); . The method needs to communicate with VSPackage. 该方法需要与VSPackage通信。

OR 要么

2) Use GetExpression("myVariable.SerializeToBase64()") from your VSPackage, and voila, you have serialized instance of your myVariable . 2)使用VSPackage中的GetExpression(“ myVariable.SerializeToBase64()”),瞧,您已经序列化了myVariable实例。 Ofcourse, you first need to inject such functionality. 当然,您首先需要注入这样的功能。

http://msdn.microsoft.com/en-us/library/aa291625(v=vs.71).aspx http://msdn.microsoft.com/en-us/library/aa291625(v=vs.71).aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 将.exe打包到.vsix中,然后从Visual Studio扩展中调用 - Package .exe into .vsix and call from Visual Studio extension 调试时Visual Studio包Initialize方法不调用 - Visual Studio Package Initialize method does not call when debugging 如何在Visual Studio 2012中通过HTML按钮调用以下CS函数 - How to call the following cs function by html button in visual studio 2012 从按钮窗体应用程序 Visual Studio 调用函数 - Call function from Button Form App Visual Studio 有没有办法用 C# 在 Visual Studio 中调用已经存在的表单的 function - Is there a way to call a function of an already existing form in Visual Studio with C# 使用Visual Studio 2013在C#调用堆栈中使用未知函数 - Unknown function in C# call stack with Visual Studio 2013 Visual Studio 2013套件问题 - Visual Studio 2013 package issue Nuget 包未在 Visual Studio 中更新 - Nuget package not updating in Visual Studio (使用Visual Studio 2013)如何使用Entity Framework在oracle包内调用存储过程? - (using Visual Studio 2013) How to call a Stored Procedure inside an oracle package with Entity Framework? 如何从Visual Studio中的包管理器控制台调用针对SQL Azure的update-database? - How to call update-database from package manager console in Visual Studio against SQL Azure?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM