Archive for March, 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!

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.

table_browswer

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"
                handler="Microsoft.VisualStudio.DataTools.DBPackage.VDT_OLEDB_CommandHandler_TableTools">
  <Parameter value="Open"/>
</CommandBinding>

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.

data_menu

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          { 0×501822e5, 0xb5af, 0×11d0, { 0xb4, 0xdc, 0×00, 0xa0, 0xc9, 0×15, 0×06, 0xef } }

Then I defined two menus and two groups (one for 2005 and one for 2008).

MENUS_BEGIN
    guidMySqlProviderCmdSet:menuAddNew2005, guidVS2005Data:8706, 0×1000,, "MySQLAdd", "&Add New";
    guidMySqlProviderCmdSet:menuAddNew2008, guidVSData:IDG_DV_GLOBAL1, 0×1000,, "MySQLAdd", "&Add New";
MENUS_END

NEWGROUPS_BEGIN
    guidMySqlProviderCmdSet:groupAddNew2005, guidMySqlProviderCmdSet:menuAddNew2005, 0×0000;
    guidMySqlProviderCmdSet:groupAddNew2008, guidMySqlProviderCmdSet:menuAddNew2008, 0×0000;
NEWGROUPS_END

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, 0×0000, OI_NOID, BUTTON, DIS_DEF, "&Table";
guidMySqlProviderCmdSet:cmdidAddNewViewGlobal, Group_Undefined:0, 0×0001, OI_NOID, BUTTON, DIS_DEF, "Vie&w";
guidMySqlProviderCmdSet:cmdidAddNewProcedureGlobal, Group_Undefined:0, 0×0002, OI_NOID, BUTTON, DIS_DEF, "Stored &Procedure";
guidMySqlProviderCmdSet:cmdidAddNewFunctionGlobal, Group_Undefined:0, 0×0003, OI_NOID, BUTTON, DIS_DEF, "Stored &Function";
guidMySqlProviderCmdSet:cmdidAddNewUDFGlobal, Group_Undefined:0, 0×0004, 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"/>
</CommandBinding>

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.

mysql_data_menu

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. 

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.