Visual studio type library
I'm trying from Delphi to open up Visual Studio (for editing SSRS reports), and load up a particular projectitem from a solution file I have autogenerated.
I have imported the visual studio type library, and can create the object,
and drill through the solution until I have the right ProjectItem
objDTE := CreateOleObject('VisualStudio.DTE') as DTE;
However I am now at the point where I have the ProjectItem, and want to
do the following
_ProjectItem.Open(vsViewKindDesigner);
Unfortunately vsViewKindDesigner is some sort of constant that I can't
find a type library for, and it must relate to a particular Guid underneath.
Any ideas where I can import this type library from in order to use this constant in the ProjectItem.Open method?
ProjectItem = interface(IDispatch)
['{0B48100A-473E-433C-AB8F-66B9739AB620}']
.... etc
function Open(const ViewKind: WideString): Window; safecall;
.... etc
Thanks!
vsViewKindDesigner = {7651A702-06E5-11D1-8EBD-00A0C90F26EA} (Designer view).
source: http://msdn.microsoft.com/en-us/library/aa301250(VS.71).aspx
Have you looked for that constant in the Visual Studio SDK? MSDN? Google?
See http://social.msdn.microsoft.com/Search/en-US/?Query=vsViewKindDesigner.
Related
I am converting a Visual Studio 2010 macro to work in an addin. I am using VB. How do I correct the line below:
Dim win As Window = DTE.ActiveWindow
which gives this error:
Error 3 Reference to a non-shared member requires an object
reference. C:\Users\Frank\documents\visual studio
2010\Projects\MyAddin2\MyAddin2\Module1.vb 28
The DTE is passed via the Application parameter in IDTExtensibility2.OnConnection. This method is called when the AddIn is initialized by Visual Studio.
The AddIn project wizard should have generated some code that casts the Application parameter to a field of type DTE2. Use that field to access the ActiveWindow property.
Is there a a way to get the processor type, build type, etc, from a Visual Studio solution, via C#?
There is something called ConfigurationManager which takes care of the build type and other details.
Create a Visual Studio Addin (A Project Template is available in Visual Studio in the Extensibility Category) and access your current Solution Configuration with the ActionConfiguration Property from DTE.Solution. See this for further details:
I wrote my own Debugger Visualizer.
It, and the attributes, are in their own assembly. There is no references or attributes in the assembly containing the class to be debugged - I want to make a drop-in dll that is optional for people to use.
The class I am trying to debug is a generic.
[Serializable]
public class FinCellTable<S> : IFinCellTable, IEnumerable<List<FinCell.IFinCell>>
where S : class, FinCell.IFinHeaderCell, FinCell.IFinCell, new()
Here is the visualizer:
[assembly: System.Diagnostics.DebuggerVisualizer(
typeof(Financials.Debugging.CellTableVisualizer),
typeof(VisualizerObjectSource),
Target = typeof(Financials.Transformation.IFinCellTable),
Description = "FinCell Table Visualizer")]
[assembly: System.Diagnostics.DebuggerVisualizer(
typeof(Financials.Debugging.CellTableVisualizer),
typeof(VisualizerObjectSource),
Target = typeof(Financials.Transformation.FinCellTable<Financials.FinCell.FinHeaderCell>),
Description = "FinCell Table Visualizer")]
namespace Financials.Debugging
{
public class CellTableVisualizer : DialogDebuggerVisualizer
{
protected override void Show(IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider)
{
if (windowService == null) throw new ArgumentNullException("windowService");
if (objectProvider == null) throw new ArgumentNullException("objectProvider");
var data = (IFinCellTable)objectProvider.GetObject();
using (var displayForm = new CellTableVizForm())
{
displayForm.PopulateForm(data);
windowService.ShowDialog(displayForm);
}
}
}
}
I am running Visual Studio 2010, and the following directory contains the .dll and .pdb of the Visualizer Assembly:
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers
I place a breakpoint on an instance of IFinCellTable that is specifically FinCellTable. It does not show the magnifying glass.
I debugged Visual Studio using another Visual Studio as the first VS was debugging. I watched the output window as the first VS loaded dll's. When I triggered a visualizer on a datatable, the second VS outputted that it loaded Microsoft.VisualStudio.DebuggerVisualizers.dll and Microsoft.VisualStudio.Debugger.DataSetVisualizer.dll (the latter from the correct directory I said above). (The Modules window behaves/shows the same.)
So obviously my Debugger Visualizer Drop-In assembly is not be loaded by VS, so it doesn't know to show the magnifying glass.
How do you get visual studio to load Visualizers up-front, so drop-in visualizers work and you don't need to edit your original code?
Wild guess: are you sure the correct files are in C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers, not in C:\Users\<you>\AppData\Local\VirtualStore\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers?
If yes, that's due to UAC Virtualization.
This question is over 5 years old, so I assume it's no longer relevant to the original poster, but for anyone else trying to do something similar:
System.Diagnostics.DebuggerVisualizer does not work when target is an interface. You have to specify a concrete type. You have to specify the attribute on every single concrete type you want to visualize:
[System.Diagnostics.DebuggerVisualizer("Financials.Debugging.CellTableVisualizer, Financials.Debugging, Version=1.0.0.0, Culture=neutral, PublicKeyToken=...")]
[Serializable]
public class FinCellTable<S> : IFinCellTable, IEnumerable<List<FinCell.IFinCell>>
where S : class, FinCell.IFinHeaderCell, FinCell.IFinCell, new()
{
I believe this can be disabled in Tools > Options:
If you do not see the effects of DebuggerDisplay or DebuggerTypeProxy ensure that Tools > Options > Debugging > General > Show raw structure of objects in variables windows is NOT checked.
The correct folder to place it is:
C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\Packages\Debugger\Visualizers. Once you place this DLL there and restart visual studio then you should get a "magnifying glass" over "Expression" type of variables (in debugging mode you will get it in watch window and also when you move your mouse cursor over the variable)
I'm working on a Classic ASP (with VB Script) project where I'm instantiating an object from an ActiveX control like so:
Dim objHelper
Set objHelper = Server.CreateObject("HelperLib.HelperObj")
Visual Studio 2005 provides intellisense for the first "layer" of properties and methods, but it can't seem to see properties and methods that are members of the main objects. For example:
objHelper. 'Properties and methods show up after the period '
objHelper.FirstProperty. 'No properties and methods are shown after the period'
Is there a way to "help" Visual Studio in some way to see these object types so that I can work in a more strongly-typed environment?
Unfortunately, 2005 does not do this. 2008 does a very good job of it, however. Once you install sp1, that is.
This is the question that has been posted to MSDN forums some time ago, and stayed unanswered to this day:
http://social.msdn.microsoft.com/Forums/en-US/vsx/thread/676b13d4-acfc-4252-b102-5fc0553e4b81/
The property I'm interested in is ProjOutputReferences, stored in the Visual Studio solution (.sln) file.
In Visual Studio, this property is accessible through Property Pages dialog of a Silverlight WebSite project (requires that you have Silverlight Tools for VS2008 installed). There, there is a page called "Silverlight Applications" on which the content of the above mentioned property can be edited.
I need to access it programmatically inside my add-in, through VS automation or low-level interface(s).
In the latest released version of the Silverlight Tools for VS 2008 SP1, the list is persisted in the SilverlightApplicationList property in the referring project file.
For example, I have SilverlightApplication2 and SilverlightApplication2.Web in my solution (the latter references the former). I have the following node in my SilverlightApplication2.Web.csproj file:
<SilverlightApplicationList>{BBA7B148-42AE-477E-BB5E-0BA5AEC0A467}|..\SilverlightApplication2\SilverlightApplication2.csproj|ClientBin|False</SilverlightApplicationList>
There really isn’t a way to access this property via purely DTE, but you can use the Visual Studio SDK / VSIP interfaces to do so (specifically, you want to get the IVsBuildPropertyStorage interface for access to MSBuild properties). Here is a code snippet (runs in a menu command handler in a VSPackage):
IVsSolution solution = GetService(typeof(SVsSolution)) as IVsSolution;
IVsHierarchy hierarchy;
solution.GetProjectOfUniqueName(#"SilverlightApplication2.Web\SilverlightApplication2.Web.csproj", out hierarchy);
IVsBuildPropertyStorage buildPropertyStorage = hierarchy as IVsBuildPropertyStorage;
if (buildPropertyStorage != null)
{
string silverlightAppListValue;
buildPropertyStorage.GetPropertyValue("SilverlightApplicationList", "Debug", (uint)_PersistStorageType.PST_PROJECT_FILE, out silverlightAppListValue);
MessageBox.Show(silverlightAppListValue);
}
If you still want to try doing this from an Addin, you’ll have to get follow the approach that Craig mentions to cast the DTE object to an IServiceProvider (so you can call GetService).
-Aaron Marten
Since .sln files are just text files, try editing your .sln file using Notepad. You should be able to find the property you are looking for listed there. Assuming the information is in an understandable format, you should then be able to use a simple text parser to extract the info from the .sln programmatically.