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)
Related
In earlier versions of Visual Studio, you could change the way that results from Find are presented by altering the value of HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\{VSVersion}\Find\Find result format. In particular, I would set it to $f$e($l): $t\\r\\n which removes the full path from the entry.
Making the same change to HKEY_CURRENT_USER\Software\Microsoft\VisualStudio\15.0\Find\Find result format doesn't seem to do anything. Is there another way to address this in VS2017?
VS 2017 now uses private registry (see Where does Visual Studio 2017 RC store its config?). One way to access it directly is from a running Visual Studio 2017 instance with my Visual Commander extension. For example, you can use the following C# command:
public class C : VisualCommanderExt.ICommand
{
public void Run(EnvDTE80.DTE2 DTE, Microsoft.VisualStudio.Shell.Package package)
{
var key = Microsoft.Win32.Registry.CurrentUser.CreateSubKey(
#"Software\Microsoft\VisualStudio\" + DTE.Version + #"\Find");
key.SetValue("Find result format", #"$f$e($l): $t\r\n");
}
}
We are doing QT development in Visual Studio 2010. I would like to be able to see the contents of A QDomNode variable in the Visual Studio Debugger.
It is possible to customize the display of variables in the Visual Studio Debugger by customizing the autoexp.dat file. The QT Add in for Visual Studio adds many customizations to autoexp.dat that enable you to see relevant information for QT classes, and there are a number of discussions on customizing the autoexep.dat that include a customization for QDomNode that appear to originate from this Daniel Albuschat blog entry QT Debugging with Visual Studio 2005. However, QDomNode is still not visible to me even with the described modifcations to autoexp.dat.
I notice that QDomNode uses a member variable QDomNodePrivate* impl as a PIMPL to hide its data members behind. This is similar to the "d" pointer commonly used in QT, notably in QString, which is able to see data correctly... Any pointers would be appreciated...
A simple preview would be:
QDomNode|*::QDomNode{
preview ($e.impl->name)
}
But this does not really work, because the debugger can see the structure of impl only when it is "inside" qdom.cpp wich contains the definition of QDomNodePrivate. You can test this by stepping inside some QDom method. One "hacky" solution would be to copy the class definition of QDomNodePrivate into some header file that you include in your program.
And don't forget: You have to be Administrator to successfully edit autoexp.dat!
When I try to inspect DataSet by standard DataSet visualizer I see this error "could not load this custom viewer".
I wrote simple dataset visualizer, but error throws anyway too.
On other computers with the same configuration visualizer show without any errors.
OS: Windows 7 x86 (Release)
VS: Visual Studio 2010 RC
has somebody any ideas?
I reinstall VS with no effect.
Try the following.
-Go to Tools->options->Debugging->Plz Uncheck "Use Managed Compatibility Mode"
I had the same issue in VS 2015 and none of the answers here helped me but I found an issue on github that described my problem.
The solution, or workaround might be more accurate, for me was to turn off the option "Use the legacy C# and VB evaluators" that I (apparently) had turned on in Tools -> Options -> Debugging -> General.
The best way to diagnose this is to debug Visual Studio itself. Try the following
Get Visual Studio into the state where you want to use your Visualizer
Attach another version of Visual Studio to the original one (managed only)
Disable Just My Code (Tools -> Options -> Debugger -> uncheck "Just my Code")
Go to Debug -> Exceptions
Check the Throw box for "CLR Exceptions"
Switch back to the first VS and Attempt to show your Visualizer
This should throw an exception which will then show up in the second instance of Visual Studio. Please post back with this information if it's not enough to solve your problem.
For me. Visual Studio 2010 restart helped.
I had the same issue in VS2017, I tried a lot but nothing was worked and finally, I reset all the VS settings which I made and the error was gone.
https://blogs.msdn.microsoft.com/zainnab/2010/07/16/reset-all-your-development-settings/
I found workaround!
I changed source code of DevExpress module and recompile it. After that I undo parameter to NetFx40_LegacySecurityPolicy enabled="false", and enjoy. :)
File is "%DeveloperExpress.NET%\Sources\DevExpress.Data\Utils\Security.cs"
using System;
using System.Security;
using System.Security.Permissions;
namespace DevExpress.Data.Helpers {
public static class SecurityHelper {
public static bool IsPartialTrust {
get {
return !IsPermissionGranted(new ReflectionPermission(ReflectionPermissionFlag.MemberAccess));
}
}
public static bool IsPermissionGranted(IPermission permission) {
bool result = true;
/* (changed by Lion)
try {
PermissionSet ps = SecurityManager.ResolvePolicy((System.Security.Policy.Evidence)null);
ps = ps.Copy();
ps.AddPermission(permission);
ps.Demand();
}
catch (SecurityException) {
result = false;
}
*/
return result;
}
}
}
For me, I had written my own visualizer for a type that I had created. Apparently, this was interfering with VS 2017's ability to display the built-in visualizer for datasets. Once I removed my own visualizer and the Microsoft Debugger Visualizer reference, I could use the built-in ones.
I have written other visualizers in earlier versions of VS that didn't cause any problems.
I found the cause of this error.
According this advice http://go.microsoft.com/fwlink/?LinkID=155570 I add to devenv.exe.config this parameter
NetFx40_LegacySecurityPolicy enabled="true"
and with this parameter in .config file I have the error when try to open DataSet visualizer.
When I remove this parameter all became ok. Execption "The security state of an AppDomain was modified by an AppDomainManager configured with the NoSecurityChanges flag" fixed too.
But I NEED NetFx40_LegacySecurityPolicy enabled="true" parameter to work with old projects.
Clearing Visual Studio Cache fixed it for me.
Just follow these basic steps:
Step 1: clear the Component Cache
Close Visual Studio (ensure devenv.exe is not present in the Task Manager)
Delete the directory:
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio\14.0\ComponentModelCache
If step 1 doesn't work then
Step 2: cleanup your user’s temp folder. Delete this directory:
%USERPROFILE%\AppData\Local\Temp
If step 2 doesn't work then
Step 3: Delete all these directories:
%USERPROFILE%\AppData\Local\Microsoft\Team Foundation
%USERPROFILE%\AppData\Local\Microsoft\VisualStudio
%USERPROFILE%\AppData\Local\Microsoft\VSCommon
Credit : https://errorhandlinginskills.wordpress.com/2018/07/28/how-to-clear-visual-studio-cache/
visual studio -> Tools-> options-> Debugging-> "Use Managed Compatibility Mode" - uncheck this and maybe it works fine then.
in visual studio 2019 community after an update between 16.4.x - 16.7.5 mine was broken all I had to do was uncheck "Warn when using custom debugger visualizers against potentially unsafe processes (Managed only)" and it allowed me to see a visual of the datatable. Under the tools>options>Debugging>general menu.
Just Restart your system. Your problem will be resolved.
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.
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.