Wednesday, March 26, 2008

Slide.Show installed as my photo viewer

Finally got around to hacking in Slide.Show as my photo viewer.  Yup, you need Silverlight installed to see them but with the way that Silverlight is growing that shouldn't be a problem.

Go check it out and let me know what you think!

Thursday, March 13, 2008

Getting the built in data browser to work in 2005 and 2008

When we last left our hero he had just got the global data menu working under '05 and '08.  Next step was use of the table browser.  Here's a shot of it working with SQL Server data.  Now there is no particular reason to use this data browser instead of writing our own other than it's just less work and it has a nice look and feel.

On the surface this looks pretty easy.  After a little digging I discovered that this command binding will add a "Show Table Data" menu option and bring up a nice OleDB-based data browser under VS 2005.
<CommandBinding name="Browse_Data" guid="501822E1-B5AF-11d0-B4DC-00A0C91506EF" cmdid="12384"
  <Parameter value="Open"/>

The problem, of course, is that this doesn't work under VS 2008.  The handler under VS 2008 is implemented by an object with the guid of 884DD964-5327-461f-9F06-6484DD540F8F.  My first approach was to define two of these bindings and no matter which version of VS ran one of them would fail (and not add any menu item) while the other would succeed.  VS doesn't like that.  Apparently the guid and cmdId together form a key and you get a key added twice error. Hmmm
My good buddy Stephen at Microsoft offered up the solution of overriding the GetDataViews method of DataViewSupport and tweaking the XML that is returned.  It turns out that he was spot on.  I set all the handlers in the XML file to be proper for VS 2005, changed my DataViewSupport derived class to now use the no parameter constructor base, and then overrode the GetDataViews method like so.
public override Stream GetDataViews() { string xmlName = "MySql.Data.VisualStudio.DDEX.MySqlDataViewSupport.xml"; Assembly executingAssembly = Assembly.GetExecutingAssembly(); Stream stream = executingAssembly.GetManifestResourceStream(xmlName); StreamReader reader = new StreamReader(stream); string xml = reader.ReadToEnd(); reader.Close(); // if we are running under VS 2008 then we need to switch out a couple // of command handlers DTE dte = Package.GetGlobalService(typeof(DTE)) as DTE; if (dte.Version.StartsWith("9")) xml = xml.Replace ("Microsoft.VisualStudio.DataTools.DBPackage.VDT_OLEDB_CommandHandler_TableTools", "884DD964-5327-461f-9F06-6484DD540F8F"); MemoryStream ms = new MemoryStream(xml.Length); StreamWriter writer = new StreamWriter(ms); writer.Write(xml); writer.Flush(); ms.Position = 0; return ms; }

I won't bother with showing you a pic of it working in MySQL because it looks just like the other pic.  But, then again, that's the point.  :)

Supporting a global data menu option under 2005 and 2008

It's no secret that that SQL Server integrates better into Visual Studio than any other database.  We are trying to change that.  Two of the things that I wanted to implement in the new version of our integration code is to replicate the Add New submenu and use the the built-in table browsers that Sql Server uses.  Here is a screen shot of the global data menu we wanted to reproduce.

This menu should also work in Visual Studio 2005 though the top four items (Schema Compare, Data Compare, Refactor, and T-SQL Editor) won't be there.  The problem is that adding items to the global data menu is not directly supported in Visual Studio 2005 but it is supported in 2008.  This is further complicated due to the fact that Microsoft moved from using CTC files to VSCT files to define package resources.  I didn't want to ship two binaries (one for 2005 and one for 2008) so I have continued to use the CTC format.  Here is what I had to do to get it working.
First, I defined a constant for the appropriate menu group in VS 2005.  I put this in my file named guids.h
#define guidVS2005Data          { 0x501822e5, 0xb5af, 0x11d0, { 0xb4, 0xdc, 0x00, 0xa0, 0xc9, 0x15, 0x06, 0xef } }
Then I defined two menus and two groups (one for 2005 and one for 2008).
    guidMySqlProviderCmdSet:menuAddNew2005, guidVS2005Data:8706, 0x1000,, "MySQLAdd", "&Add New";
    guidMySqlProviderCmdSet:menuAddNew2008, guidVSData:IDG_DV_GLOBAL1, 0x1000,, "MySQLAdd", "&Add New";

    guidMySqlProviderCmdSet:groupAddNew2005, guidMySqlProviderCmdSet:menuAddNew2005, 0x0000;
    guidMySqlProviderCmdSet:groupAddNew2008, guidMySqlProviderCmdSet:menuAddNew2008, 0x0000;

Note here that 8706 is the id of the global data menu in VS 2005 and IDG_DV_GLOBAL1 is the id under VS 2008.  menuAddNew2005, menuAddNew2008, groupAddNew2005, and groupAddNew2008 are just simple ids I assigned. The reason you need to define the menu twice is because no matter which version of VS you use it will balk at adding the same menu to two different top level groups.
Then I define the commands I want to appear on the menus but I don't put them on the menus here since I need to put them on two different menus.
/* global data menu items */
guidMySqlProviderCmdSet:cmdidAddNewTableGlobal, Group_Undefined:0, 0x0000, OI_NOID, BUTTON, DIS_DEF, "&Table";
guidMySqlProviderCmdSet:cmdidAddNewViewGlobal, Group_Undefined:0, 0x0001, OI_NOID, BUTTON, DIS_DEF, "Vie&w";
guidMySqlProviderCmdSet:cmdidAddNewProcedureGlobal, Group_Undefined:0, 0x0002, OI_NOID, BUTTON, DIS_DEF, "Stored &Procedure";
guidMySqlProviderCmdSet:cmdidAddNewFunctionGlobal, Group_Undefined:0, 0x0003, OI_NOID, BUTTON, DIS_DEF, "Stored &Function";
guidMySqlProviderCmdSet:cmdidAddNewUDFGlobal, Group_Undefined:0, 0x0004, OI_NOID, BUTTON, DIS_DEF, "&UDF";

Now I add the commands to both menus
guidMySqlProviderCmdSet:cmdidAddNewTableGlobal, guidMySqlProviderCmdSet:groupAddNew2005, 1;
guidMySqlProviderCmdSet:cmdidAddNewTableGlobal, guidMySqlProviderCmdSet:groupAddNew2008, 1;

/* others omitted for brevity  */
Now we need to add our commands to our data view XML file.  Here is what one command binding looks like.
<CommandBinding name="AddNewTable" guid="B87CB51F-8A01-4c5e-BF3E-5D0565D5397D"
                cmdid="500" handler="MySql.Data.VisualStudio.MySqlDataViewCommandHandler">
  <Parameter value="HighLevel"/>

Notice the command parameter named "HighLevel".  This is important because without it the menus will not function correctly in VS 2005.  You also need to add all the commands into the command bindings of every node.  Yes, this is very repetitious but is necessary due to a bug in VS 2005.  Without doing that the menu will appear when the connection node is selected but will disappear when on the other nodes.
I would also like to thank a developer at Microsoft who answered tons of my questions and helped me sort this out.  His name is Stephen Provine and I really appreciate all his hard work.  With all this done, here is the same shot working with MySQL.

Windows Server 2008 on the Mac

It's about 5pm and I'm sitting watching my son play in his second tennis match and working on my Mac.  Boy I have to get used to saying that.  This is a beautiful machine.  After I used Boot Camp to install Windows Server 2008 x64 I started searching Google for driver locations and tricks to get everything working.  After the default install I had the built-in NIC, wireless NIC (Broadcom), iSight, and audio not working.  The blogs that talked about installing the Aetheros wireless driver obviously would not work since this is a new Mac and they've started using Broadcom.  I even found a post giving a download link to some HP driver that was supposed to work.  Frustrated, I decided to simply insert my Leopard disk and see what would happen.  I had heard that x64 drivers had shipped with the new Mac Pros but not with the MacBook Pros so when I ran the installer I expected a polite error message.  Instead, something really cool happened.  All of my devices (except the Bluetooth hub) just started working.  Yup.  Every driver installed cleanly.  No unsigned driver warnings.  Nothing but cool clean workiness.  Yes, that's a made up word.

Since this is Windows Server 2008 I can't run the tool that gives me an experience index but from reading other blog posts I would imagine it is around 5.3-5.5.  Very fast I can tell you that.  I can also tell you without a doubt that Windows Server 2008 *is* faster than Vista.  If you are running Vista and don't have crazy application compatibility issues then do yourself a favor and try out Win2k8.  There are lots of posts out there talking about all the steps you need to do to make it look and act like Vista. 

So, I've installed Visual Studio 2005 and now I'm installing Visual Studio 2008.  No wireless here at the tennis courts and I don't have Live Writer installed so I'm typing this blog post into visual notepad.  :0

Oh, one other nice bit of coolness.  I installed the demo of VMWare Fusion and used it to boot my boot camp partition.  First, it was nice to see that Fusion has experimental support for Windows Server 2008.  That makes sense since it is basically Vista.  In any case, I was certain that once I booted under Fusion that all my drivers would be replaced with generic SVGA, mouse, etc drivers and that I would have to endure a re-discovery of hardware when I booted natively into Window.  I was prepared for that actually. But no, my boot camp partition boots nicely under Fusion but also boots natively with all the optimized drivers still in place.  Call me naive but I didn't expect that.  Very, very nice.  By default the vm only had 512 meg assigned and that's like trying to carry the Brady Bunch in a Yugo.  So I'll have more to say about Fusion and Unity once I get back to Mac land and give the vm a more appropriate 1.5 gig.  I'm sure I'll be shopping for a 2 gig ram upgrade soon enough. 

Wednesday, March 12, 2008

First day on the new MacBook Pro

The power connector broke on my old laptop and with several trips coming up I really needed to get some new iron.  So the question is which one.  I originally looked at a nice Sony Vaio and then I saw one of those nice Dell XPS m1330 machines.  They have a very sweet LED screen and a nice form factor but I really wanted a larger screen.  The problem is that the m1530 doesn't yet ship with Penryn processors or a LED screen.  The other option was the MacBook Pro.  Yes, I know...

So, after a lot of consideration, I chose to go with the Mac.  Pretty easy decision actually.  The Dell configures up with 3 year warranty at $1800 and the Mac at $2200.  Now if you consider the upgrade costs for when the 1530 will support Penryn processors and an LED screen (the 1330 costs $200 more with these options), that puts the Dell at about $2000.  The difference of $200 is a small amount when you consider that the Mac is the only laptop that can run all 3 major systems today.  Yep, pretty easy decision.

So, the new Mac arrived today and I'm writing this blog entry on it.  I plan to write for the next 30 days on my experiences on the machine.  I'v always worked on Windows machines so it's a brave new world for me.  I'll be testing out Parallels and VMWare fusion for my development work and playing with such gems as iMovie and iDVD around the house.

I had several good impressions during the first hour or so of us.  Initial startup had a nice touch where it let me use the web cam to take a personal picture for the login screen.  Anyway, I have lots more to talk about but I'll save it for the next entry. 

Wednesday, March 5, 2008

Switched to BlogEngine.NET

Well, I ran out of database room on my hosting account yesterday so the only thing to do was to move back to a blogging package that is not database backed.  I thought about going back to dasBlog but instead decided to try out BlogEngine.NET.  It's a new blog engine written in .NET and open source.

It seems to have quite a bit of traction and has some nice features.  After a few minor skirmishes I got my blog exported out of Subtext in a BlogML format and it imported into BlogEngine very easily.  The only issue right now is existing URLs that are out there and waiting for Google to re-index the site.

Anyway, so far I like it.  Let me know what you think!

Windows Server 2008 - the best Windows yet!

I ran Windows Server 2003 as my desktop from the time it came out until Vista shipped and now I'm on Windows Server 2008.  And boy does it rock!

I won't repeat the many blog posts that are out there that go over the steps needed to get Win2k8 running just like Vista (though I will refer you to my last blog post about getting sidebar working right).  What I will tell you is that almost everything runs under Win2k8 with less RAM than under Vista.  People will tell you all day that there is no difference between the Vista SP1 and Win2k8 binaries but there is a difference somewhere.

Actually I checked the ntoskrnl.exe binary from both Vista SP1 and Win2k8 and they are truly exactly the same.  However, that doesn't mean they run the same.  The Vista kernel could have all sorts of compatibility shims that get loaded dynamically or checked at runtime.  One piece of evidence that Win2k8 is different is the fact that a few programs don't function correctly.  The latest version of skype and microTorrent do not function (you can use an older version of Skype though).

What I know is that it *feels* tons faster.  IE just appears instantly.  Explorer windows open immediately.  And the RAM usage just speaks for itself.  The table below shows what the memory usage typically is on my system for


Application Vista SP1 Windows Server 2008
Desktop Window Manager 40-50 meg 756k (yes, k!).  Part of this is the fact that I have not yet been able to enalble taskbar video thumbnails.
Sidebar 25 meg 12 meg

Sidebar working nicely on Windows Server 2008

I've been running with Windows Server 2008 as my primary desktop OS now for a few weeks and one of the things that I had not got to work was Sidebar.  I found several blog posts on the net where people claim to have it working but following their steps always resulted in failure.

More specifically running sidebar would show the icon in the system tray but the app would immediately exit.  Turns out that I needed on extra step.  So, without further delay, here are the steps I did to get sidebar working in Windows Server 2008 x64.

  1. Copy the Windows Sidebar folder from c:\Program Files on a Vista x64 SP1 installation to your Win2k8 install.
  2. From an administrator console run:
    regsvr32 sbdrop.dll
    regsvr32 wlsrvc.dll
  3. From that same console run:
    sidebar /RegServer
  4. Move the Sidebar registry information from a working Vista SP1 x64 install.  You can find it at HKLM/Software/Microsoft/Windows/CurrentVersion/SideBar.
  5. Run sidebar!

Here's a screenie showing it working on my setup.


Tuesday, March 4, 2008

Syntax highlighting on the way!

I've been working very hard on adding new features to our Visual Studio integration and one of those features is syntax highlighting of SQL when creating and editing stored procedures.  With this new build we are using the core editor that is built inside Visual Studio.  This brings other features such as the ability to split the code window.  Currently I am hoping to have these new features in our 5.3 product.