Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1108043
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:01:22+00:00 2026-05-17T02:01:22+00:00

I’m trying to get a DataRow[] DebuggerVisualizer working for VisualStudio 2010 and unfortunately I

  • 0

I’m trying to get a DataRow[] DebuggerVisualizer working for VisualStudio 2010 and unfortunately I can’t get it work work. I’m able to get the DataRow one working but not the DataRow[], I would love any please?

The meat of the code is here.


    [assembly: DebuggerVisualizer(
        typeof( PCHenry.DR ),
        typeof( PCHenry.DRObjectSource ),
        Target = typeof( DataRow[] ),
        Description = "DataRow Array Debugger Visualizer (or so if you see this then it's working YAHOO!)" )]
    namespace PCHenry
    {
      public class DR : DialogDebuggerVisualizer
      {
        protected override void Show( IDialogVisualizerService windowService, IVisualizerObjectProvider objectProvider )
        {
          StringBuilder stringToDebug = new StringBuilder();
          using( Stream dataStream = objectProvider.GetData() )
          {
            BinaryFormatter formatter = new BinaryFormatter();
            string incomingData = formatter.Deserialize( dataStream ) as string;
            stringToDebug.Append( string.Format( "*!!!!{0}!!!!*", incomingData ) );
          }

          MessageBox.Show( stringToDebug.ToString(), "PCH String Debugger Visualizer", MessageBoxButtons.OK, MessageBoxIcon.Asterisk );
        }
      }

  public class DRObjectSource : VisualizerObjectSource
  {
    public override void GetData( object target, Stream outgoingData )
    {
      if( target != null && target is DataRow[] )
      {
        DataRow[] rows = target as DataRow[];
        BinaryFormatter formatter = new BinaryFormatter();
        //formatter.Serialize( outgoingData, target );

        formatter.Serialize( outgoingData, string.Format( "There are {0} rows of data", rows.Length ) );
      }
    }
  }
}

As I hope you can see, I’m trying to set the Target correctly, but it’s not being used by VS at runtime/debugging time. Yes, I am copying the DLLs to the correct Visualizers directory. In fact, I’m using a BuildEvent to do that work for me.


xcopy "$(SolutionDir)$(ProjectName)\$(OutDir)$(TargetFileName)" "$(USERPROFILE)\Documents\Visual Studio 2010\Visualizers" /y

When I test this, I use this.


static void Main( string[] args )
    {
      //String myName = "Peter Henry";
      #region DataSetup, create a Habs DataTable and populate it with players
      DataTable table = new DataTable( "Habs" );
      table.Columns.Add( "PlayerNumber", typeof( Int32 ) );
      table.Columns.Add( "PlayerName", typeof( string ) );
      table.Columns.Add( "Position", typeof( string ) );

      //team as current as 09-23-2010 from the Canadiens!  GO HABS GO!
      table.Rows.Add( new object[] { 32, "Travis Moen", "F" } );
      table.Rows.Add( new object[] { 94, "Tom Pyatt", "F" } );
      table.Rows.Add( new object[] { 75, "Hal Gill", "D" } );
      table.Rows.Add( new object[] { 26, "Josh Gorges", "D" } );
      table.Rows.Add( new object[] { 76, "P.K. Subban", "D" } );
      table.Rows.Add( new object[] { 35, "Alex Auld", "G" } );
      #endregion

      //use this to show the debugger in two different ways
      DataRow[] defencemen = table.Select( "Position = 'D'", "PlayerNumber" );

      //this proves this works when told which ObjectSource to use
      VisualizerDevelopmentHost host = new VisualizerDevelopmentHost( 
          defencemen, typeof( PCHenry.DR ), 
          typeof( PCHenry.DRObjectSource ) );
      host.ShowVisualizer();

      //but when I try to use VS debugging here, it can't seem to find the custom DebuggerVisualizer as I would expect
      defencemen = table.Select( "Position = 'D'", "PlayerNumber" );
      Debugger.Break();

      Console.WriteLine( "FIN" );
      Console.ReadLine();
    }

The key here is, the VisualizerDevelopmentHost works correctly, and I can only guess cause it’s told which VisualizerObjectSource to use. But when I hit the Debugger.Break(); line and try to use it like normal, I can’t see the magnifying glass for the defencemen DataRow[].

I believe in the bottom of my heart this can be done. I read on MSDN DataRow couldn’t be done, but I got it to work. I really do hope you can help me out there to get this working.


Thank you very much guys for your replies. You confirmed what I was thinking (well, what I was coming to realize after four nights of fighting with it!). Thanks again. I blogged about it and referenced this information. Thank you very much for your time.

Visual Studio Debugger Visualizers (Take Three)

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T02:01:23+00:00Added an answer on May 17, 2026 at 2:01 am

    For the most part what Spike says is true. You can write a visualizer for anything “except Object or Array”: http://msdn.microsoft.com/en-us/library/e2zc529c.aspx

    “Array” seems a little ambiguous; but there’s lots of people with the same problem…

    I haven’t been able to find anything specific to this (and haven’t tried it) but, what about IEnumerable? Does that work?

    There’s also an interesting article of getting around limitations on the types of objects a Visualizer can except here: http://joshsmithonwpf.wordpress.com/2008/01/20/the-rock-star-hack-of-2008/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I'm making a simple page using Google Maps API 3. My first. One marker
I have a bunch of posts stored in text files formatted in yaml/textile (from
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.