Apr 14 2008

My Experience with Visual Studio 2008 Remote Debugging

Tag: Visual StudioTyrone @ 10:16 pm

Surprisingly, it’s been quite pleasant.  I have tried Remote Debugging with VS.NET 2003, and I didn’t have much luck with it. However, last week there was a scenario where I desperately needed it and given that we have upgraded to VS 2008, I thought I should give it another try. There is two steps I had to perform to get this to work correctly:

  1. Configure your client machine using the Remote Debugger Configuration Wizard.
  2. Copy the Remote Debugger server components to the remote machine

That’s it.  Ok. I didn’t give you much here, so here is some more detail.

To run the Remote Debugger Configuration Wizard go to:

Start -> Program -> Microsoft Visual Studio 2008 -> Visual Studio Tools -> Visual Studio 2008 Remote Debugger Configuration Wizard

The wizard will begin and you will be brought to this screen:

 

 

 

 

 

 

 

 

 

This screen is basically asking if you want to run the remote debugger as a Windows Service. For me, I didn’t check the box to run as a service and it’s probably not even necessary. There is nothing much else to do but to click Next until the wizard completes. At the end it will tell you that all the necessary ports (most likely TCP) were opened and ready to connect to remote machines.

To run the server components on the remote machine, you need to copy the contents of this folder to the remote machine.

C:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\Remote Debugger\x86

Once copied to the remote machine you will just have to run the msvsmon.exe program. The main window would look like this when it’s ready to accept incoming connections:

image

 

 

 

 

 

Play close attention to the server name listed in the entry. This is the name you will need to enter into the Qualifier field in the Debug -> Attach to Process screen inside Visual Studio when you want to begin the debugging process.

image

 

 

 

 

 

 

 

 

Remember to set your breakpoint first and attach to the process you want on the remote machine. The process you will want to debug should be listed in the Available Processes list.

One thing to watch out for is that in my setup, my username and password on my client machine and my remote machine were kept in sync. This way I don’t run into any unexpected access/permissions issues when connecting to the remote machine. I would also note that I was an Administrator on both machines so this would rule out any permission issues.

Let me know if you found this helpful. I do appreciate how the Visual Studio tools team simplified this process to it is as easy as following the 2 steps I listed above.

Until next time…

Happy coding!

kick it on DotNetKicks.com


Mar 22 2008

I’m Back!!

Tag: PersonalTyrone @ 8:14 am

So, based on my last post you could probably tell that I’ve been quite busy lately. It’s been over 2 months now and Keira is doing wonderful. She just got her shots yesterday and now we could start taking her out a few places. Having said that, I have plans to begin posting again at least once a week. I apologize for that long, long commercial break; but it was necessary and worth it.  Here is the most recent photo of her. She is now 9 lbs 4oz and looking beautiful.

 

Keira_2_Months


Jan 20 2008

We interrupt your regular schedule programming to introduce…

Tag: PersonalTyrone @ 5:42 pm
P1180026_SMALL

P1180029

Name: Keira Cheyenne Davis
Born:  1/18/2008 @ 10:42am
Size:   4lbs. 10oz. 18 in.

Wow! Isn’t she beautiful!


Jan 15 2008

New Feature: Organize using statements with VS 2008

Tag: Visual StudioTyrone @ 1:21 pm

Wow!  I will be using ( no pun intended ) this feature quite often!

 

OrganizeUsings

 

I’ve seen some VS macros that currently do this in VS 2005 and I think Visual Studio IDE enhancement tools like Resharper, has this feature already baked into their product. However, in VS 2008, we get this for free, at least if you are using C#. Until next time…

 

Happy Coding!

 

kick it on DotNetKicks.com


Jan 09 2008

Strongly-Typed Session Properties in ASP.NET

Tag: .NET Framework, ASP.NETTyrone @ 10:02 pm

I recently was given the opportunity to comment on a blog post which discussed a method of using Strongly-Types Session Properties with ASP.NET. After reading it, I noticed that the implementation was quite similar to something I have been using for months now. I was able to provide some feedback on how his implementation differed from mine. Anyway’s, the link below will take you to the blog post which I am referring to and you could decide for yourself.

UPDATE: 1/11/2008

For those who would like to see my implementation here it is:

   1:  using System;
   2:   
   3:  using System.Web;
   4:   
   5:  [Serializable]
   6:   
   7:  public sealed class SessionManager {
   8:   
   9:     private const string SESSION_MANAGER = “SESSION_MANAGER”;
  10:   
  11:     private Product _product = null;
  12:   
  13:     private SessionManager( ) {
  14:   
  15:     }
  16:   
  17:     public static SessionManager Current {
  18:   
  19:         get {
  20:   
  21:             HttpContext context = HttpContext.Current;
  22:   
  23:             SessionManager manager =
  24:   
  25:                 context.Session[ SESSION_MANAGER ] as SessionManager;
  26:   
  27:             if ( manager == null ) {
  28:   
  29:                 manager = new SessionManager( );
  30:   
  31:                 context.Session[ SESSION_MANAGER ] = manager;
  32:   
  33:             }
  34:   
  35:             return manager;
  36:   
  37:         }
  38:   
  39:     }
  40:   
  41:     public Product ActiveProduct {
  42:   
  43:         get {
  44:   
  45:             return this._product;
  46:   
  47:         }
  48:   
  49:         set {
  50:   
  51:             this._product = value;
  52:   
  53:         }
  54:   
  55:     }
  56:   
  57:  }
  58:   
  59:  //And to access this property
  60:  SessionManager.Current.ActiveProduct = new Product();

 

If you would like to see what others have implemented, see the article below:

Strongly-Typed Session in ASP.NET - Chris Stewart’s ASP.NET Blog

Until next time…

 

Happy Coding!

 

kick it on DotNetKicks.com


Jan 05 2008

Ctrl-S in web.config in Visual Studio 2008 closes web.config file

Tag: Visual StudioTyrone @ 9:00 pm

Finally! Someone found a fix and root cause for this nagging bug I’ve been encountering with VS2008. You can find everything you need here. Thanks Rick! 

Until next time…

 

Happy Coding!


Dec 12 2007

TSQL, Looping through a result set without using database cursor

Tag: SQL Server, TSQLTyrone @ 12:18 pm

A few years ago a project that I was working on required me to loop through a result set from a select statement.  Most examples that I saw used database cursors. However, I came across an old article that shows an alternative method for doing this.  Let’s say we have a table that looks like this:

Table Name : Contacts

ID FirstName LastName EmailAddress
1 Jack Bauer jbauer@fox24.com
2 Dan Marino dmarino@dolphins.com
3 George Bush gbush@whitehouse.gov
4 Michael Jordan mjordan@bulls.com
5 Bill Clinton bj@whitehouse.gov

 

Please don’t pay attention to the names. I’m sure you did so already. Anyway, let’s pretend that we had a scenario that we want to loop over the rows in this table and send an email out to these individuals.  We can do this without using a database cursor. Here is some code to ponder on:

 
   1:  declare @email varchar(20)
   2:  declare @id int
   3:  declare @rowNum int
   4:  declare @maxrows int
   5:   
   6:  select top 1 @id = ID, @email = EmailAddress from Contacts
   7:  select @maxRows = count(*) from Contacts
   8:   
   9:  set @rowNum = 0
  10:   
  11:  – this will until the last row is reached
  12:  WHILE @rowNum < @maxRows
  13:   BEGIN
  14:      set @rowNum = @rowNum + 1
  15:      – this is where you can now do something like sending an email
  16:      – for now, we will just print the email to the output screen
  17:      print (‘Sending email to: ‘ + @email)
  18:   
  19:      – now we grab the next row making sure the ID of the next row
  20:      – is greater than previous row
  21:      select top 1 @id = ID, @email = EmailAddress from Contacts where ID > @id
  22:   END
 

I have tried to include additional comments in this code snippet so that it doesn’t require much explanation. However, you can see the original article if you need additional details.. Until next time…

 

Happy Coding!

 

 

kick it on DotNetKicks.com


Dec 11 2007

Appreciating a good, well-designed API

Tag: .NET FrameworkTyrone @ 3:46 pm

I have been using the .NET Framework heavily since 2002, and sometimes I have to sit back an marvel at a good, well-designed the API. I say this because just today I had to write some code to write to the file system, and it’s remarkable how simple it is to create a text file and write information to it.  You can all do it in just 2 lines of code using the System.IO.File class. Simply put, this class is a façade (or a wrapper) around the classes in the .NET Framework that work together to provide access to the file system on a Windows machine.  All the methods are static (shared for VB.NET) and it provides the most common functionality that you would normally need from the file system. Here is a little code to show you what I mean:

 
   1:  using System;
   2:  using System.IO;
   3:  using System.Text;
   4:   
   5:  namespace SimpleFileWriter {
   6:      class Program {
   7:          static void Main( string[ ] args ) {
   8:              using (StreamWriter writer = File.CreateText( @"c:\temp\test.txt" ))
   9:                  writer.WriteLine( "Hello World!" );
  10:   
  11:          }
  12:      }
  13:  }
 
 

I have posted the entire program just for your reference; but only lines 8 and 9 are needed to write data to the file system.  You can find more information on the other members of the File class here. I’m sure this may not be new to some of you; but the intent of this post was to emphasize how a well-designed API goes a long way. Until next time…

Happy Coding!

 

kick it on DotNetKicks.com


Dec 03 2007

Flash CS3, UIScrollBar, scroll arrows not displaying on dynamic text

Tag: FlashTyrone @ 10:01 pm

I am currently working on a Flash CS project and I recently came across an issue with using the UIScrollBar component..  The issue was quite intermittent; but after attaching the scroll bar component to dynamic the text box I was expecting to see bars and the arrows when the contents within the text box were larger than the constraints defined for the text box. After running the project both within the browser and in the SWF player, I noticed that on some occasions the scrolling was active and on some, inactive. 

After a few hours of research, I still couldn’t find a resolution to this issue. Then, I turned to the Flash CS3 documentation and after some careful reading of the UIScrollBar component documentation, I found the answer. The documentation mentioned that if you are dynamically loading text from an external source from ActionScript and then assigning that text to the dynamic text box, you must call the update() method on the scroll bar component to alert it that the contents have changed. So, if you have an instance of a dynamic text box on the stage called mytext_txt, and you attach a UIScrollBar component to the box by dragging the component on top of it.  You then must assign a instance name to the scroll bar component so that you can reference it within ActionScript.  Let’s say I name it mytext_scroll. Here is what the ActionScript 3 would look like:

 

   1:  import flash.display.*;
   2:  import flash.events.*;
   3:   
   4:  var textLoader:URLLoader = new URLLoader();
   5:  var simpleReq:URLRequest = new URLRequest("mytext.txt");
   6:   
   7:  textLoader.load(simpleReq);
   8:  textLoader.addEventListener(Event.COMPLETE, textComplete);
   9:   
  10:  function textComplete(event:Event):void {
  11:      mytext_txt.text = textLoader.data;
  12:      mytext_scroll.update();
  13:  }

 

Notice the update() on line 12. This seem to do the trick for me.  Hopefully, I was able to help someone figure this issue out. Until next time…

Happy Coding!


Nov 21 2007

VS 2008 - "Visual Studio encountered an unexpected error"

Tag: Visual StudioTyrone @ 8:23 am

Now that VS 2008 has been released to MSDN Subscribers, I went ahead like everyone else to rush to download and install it.  Not to my surprise, the install went perfectly since I didn’t install any pre-release version on my machine. I leaned my lesson last time when VS 2005 was released and all the headaches I had then. However, once installed, I was unable to use VS 2008 because it kept crashing and providing me with an error of "Visual Studio encountered an unexpected error"  when trying to interact with any part of the user interface. I couldn’t even exit from the program. I had to keep killing the process.  I’m like great, your not the only one who this error caught unexpectedly.  So, I figured a reboot would take care of it since I didn’t bother to reboot after the install. Nope, didn’t work.  I did a repair. Didn’t work. So, I did a complete uninstall, then reinstall and still didn’t work.  So, at this point I am frustrated since about 2 or 3 hrs have already passed.

I then decided to do some debugging…yes debugging…and I decided to start Visual Studio in Safe mode. You can do that by choosing:

Start, Run and enter this command     devenv /SafeMode

OR

Execute the same command from the command prompt directly.

After doing this, Visual Studio worked fine. I could use the menus, bring up dialog boxes, etc.  So, I believe that running is SafeMode doesn’t load any add-ins or custom VSIP packages, and I suspected one of these were probably causing the issue.  I was right, I use VisualSVN for accessing my Subversion source control repositories through Visual Studio. Its a great tool and even thought it $50, I find it very useful and much better than anything I could get for free.

So, I uninstall VisualSVN, version 1.2.4 (I think), and started VS 2008 and everything worked perfectly.  I then proceed to the VisualSVN web site to download the latest version, installed, and the new version and VS 2008 worked nicely.

I hope this helped somebody even if you don’t use VisualSVN, there may be some other add-in that may cause similar issues with VS 2008. Until next time…

Happy Coding!

 

 

kick it on DotNetKicks.com


Next Page »