开发者

Invoking Visual Studio's visualizer manually

Scenario

I've been trying to manually invoke Visual Studio's visualizer from code/immediate window, so far without any luck.

I've written a simple console application with the following code:

var dataset = new System.Data.DataSet();

Then I added dataset into the Watch Window and visualized it using the DataSet开发者_如何学Go Visualizer. As expected, that worked.

Once I've done that, I entered the following code into the immediate window:

new Microsoft.VisualStudio.DebuggerVisualizers.VisualizerDevelopmentHost(dataset, typeof(EnhancedDataSetVisualizer.DataSetVisualizer)).ShowVisualizer();

Which caused the following exception (full exception):

System.IO.FileNotFoundException: Could not load file or assembly 'Microsoft.VisualStudio.Debugger.DataSetVisualizer, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
File name: 'Microsoft.VisualStudio.Debugger.DataSetVisualizer, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, 
….

Which is really strange to me because if I look into Debug->Widnow->Modules in Visual Studio, I see that DataSetVisualizer.dll is already loaded:

Microsoft.VisualStudio.Debugger.DataSetVisualizer.dll   C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\Packages\Debugger\Visualizers\Microsoft.VisualStudio.Debugger.DataSetVisualizer.dll No  No  Cannot find or open the PDB file.       18  10.0.30319.1    18/03/2010 12:06 PM 77AB0000-77AC2000   [6784] PresentingBugAid.vshost.exe: Managed (v2.0.50727)    

Yet, it tries to load it, and fails. I've tried to examine the fusion log (full log):

…
file:///C:/SVN/Debugger/src/Test/PresentingMyTest/PresentingMyTest/bin/Debug/Microsoft.VisualStudio.Debugger.DataSetVisualizer.DLL.
LOG: Attempting download of new URL 
...

And just for the sake of trying I copied Microsoft.VisualStudio.Debugger.DataSetVisualizer.dll to c:\SVN\Debugger\src\Test\PresentingMyTest\PresentingMyTest\bin\Debug\ then retried the scenario above. This time it seemed to work, the visualization appeared, yet, it froze the whole application. Moreover, trying it again no longer showed the visualization at all.

Afterthoughts

I realized after a while that what I did might be weird - Visual Studio's Visualizers are designed to run inside the debugger's process (devenv.exe), yet, in my case I've been trying to force the visualizer to load in the debuggee (PresentingMyTest.exe). While it doesn't explain why it tried to load Microsoft.VisualStudio.Debugger.DataSetVisualizer.dll even though it was loaded, I guess it explains why it didn't work in general.

Another solution I considered to try is skipping VisualizerDevelopmentHost completely, and instead, invoking via reflection DataSetVisualizer's Show method directly, a method that any visualization must have. Is that a good idea?

I realize the whole scenario is quite unsupported, yet, it is quite important for my project and I'be happy to hear additional thoughts and things I can try to make it work.

Thanks!


Maybe it's possible to use 'Microsoft.VisualStudio.DebuggerVisualizers.VisualizerDevelopmentHost' type and particular ShowVisualizer() method? I haven't had time to play around vizualization debuggers, so this is just a wild guess.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜