I finally got a chance to play a little bit with Visual Studio 2010 while I was setting up the Mercurial source control system on my PC, and while I found a few cool improvements in the user interface, I was disgusted by how useless the help system has become. What were they thinking at Microsoft? The help system uses the default browser (in my case Firefox – you’ll never pay me enough to use IE), and gone are things such as the very useful index feature. All you get is a Search feature that returns everything and nothing, without any hint as to where it was found. Try searching for something that’s in multiple namespaces and/or languages. Horrible! Also it opens a new tab in the browser every time I press F1. Wow… They could at least have used VS2010’s internal browser – after all if you paste the help URL in there, it’s able to display it.
Apparently this will be fixed in SP1. Hey, that’s not any time soon! There are a couple of alternatives that aren’t quite up to the challenge, but may help fill the gap in the meantime:
H3Viewer: http://mshcmigrate.helpmvp.com/viewer
HelpViewerKeywordIndex: http://visualstudiogallery.msdn.microsoft.com/en-US/4af86641-a302-4edf-9853-007bcc670b30
Both are kind of slow and do not seem to work with context-sensitive help (if they do, I haven’t found how yet.) Even with their drawbacks, they seem more useful than the abomination Microsoft delivered to us. The Visual Studio help system started going down the drain with Visual Studio 2005 (it was great in 2003), but the 2010 system has to be a joke. Maybe they originally planned for an April 1 release…
The application I’m currently developing at work makes extensive use of GUIDs. If you’ve debugged Visual BASIC code in Visual Studio, you’ve probably noticed that it doesn’t display GUID values when watching a variables:

Not very useful, is it? I’ve heard that GUIDs display fine when debugging C#, but I haven’t tried (I’m lazy.)
A few weeks ago I ran into a blog that explained how to write a very basic visualizer to address this problem. Unfortunately I didn’t keep the link and have yet to remember the search text I used to get there – so somewhere somebody is not getting due credit for this post. I’m pretty sure it was on a Microsoft blog. Either way, I’ll update this post if I ever find it again – for now, let it just be known that I did not come up with this technique by myself.
Writing the Visualizer
- To create the visualizer, create a new Visual BASIC Class Library and call it “GuidVisualizer” (or whatever name you prefer.)
- Replace the generated class declaration with this code:
<Assembly: DebuggerDisplay("{ToString}", Target:=GetType(Guid))> Public Class GuidVisualizer End Class - Compile the library
Copy and try the Visualizer DLL
- Copy the generated DLL to My Documents\Visual Studio 2008\Visualizers
- Start Visual Studio 2008. Using the sample example as above, the GUID is now displayed

The watch window still obsesses on the “empty” if you keep expanding the value, but at least now you can see the real value.
GUIDs in Oracle
We’re starting a new project at work and we’ve decided to use GUIDs as unique identifiers in the tables. Now, if your database server is SQL Server, this is no big deal: You simply choose the uniqueidentifier column type and you’re in business. You can read and write that from .NET, use it in ad hoc SELECT statements, etc…
Oracle GUIDs don’t have much to do with the ones from Microsoft software, so let’s not go there. I started looking for a solution on the Internet and boy, did I see just about every possible solution out there, including storing it as a 37 character string. Call me crazy, but I wasn’t about to use this as a primary key.
Eventually I found a short post in a lengthy discussion, almost missed it actually, and the solution couldn’t have been simpler. So here it is. In this article I’ll explain how to use .NET GUIDs with Oracle, with a few short code samples. Hopefully it’ll result in some people not wasting as much time on this as I did.
Oracle Data Type for GUIDs
There is no GUID or uniqueidentifier type in Oracle, so what do you use to store a .NET GUID? (If you don’t want to store it as a string, that is.) A .NET GUID can be passed to Oracle as a 16-byte byte array, so the most efficient (at least I think so) data type is RAW(16).
Writing and reading GUIDs from .NET
You’ll have to convert your .NET GUID to pass it to Oracle. This is simple, since the GUID class has a ToByteArray method. This is some Visual BASIC sample code that creates a new GUID and puts it in an outbound parameter – in this example I use the syntax from the Oracle .NET Data Provider, but I’ve also done this using the Microsoft .NET Provider for Oracle, the Microsoft ODBC driver for Oracle, and Oracle’s own ODBC provider.
‘ Create a new GUID
Dim newguid As Guid = Guid.NewGuid
‘ Parameter settings
Dim empid As OracleParameter = _
cmd.Parameters.Add (“in_empid”, OracleDbType.Raw)
empid.Direction = ParameterDirection.Input
empid.Value = newguid.ToByteArray
Pretty simple, isn’t it? Of course, if you look at the result in the Oracle table, it won’t look like a GUID, but just a string of bytes – the content of the byte array. You can SELECT on that value by enclosing the content of the RAW(16) field in single quotes (a string), and using the HEXTORAW() function. That’s almost as good as selecting a GUID in SQL Server.
Reading the GUID back into .NET is quite straightforward as well. In the code below, dr is a DataReader, and the GUID is the first value returned in the row (hence the reference to the 0 index in GetOracleBinary). The code displays the GUID on the console:
Console.WriteLine(“GUID read from Oracle table: ” & _
New Guid(CType(dr.GetOracleBinary(0), _
Byte())).ToString)
A little bit cramped, but here’s what’s going on:
- We get the content of the RAW(16) field using GetOracleBinary
- We cast the value to a Byte array
- We create a new GUID object from that Byte array
That’s all there is to it!
