Category Archives: Uncategorized

Full Hard Disk Backup under Vista

0
Filed under Uncategorized

Finally, something that actually works fairly nicely under Vista

Microsoft includes a tool with Vista (I have Vista Ultimate, I’m not sure if this is included on all versions of Vista or not), that can backup your entire harddisk (usually one at a time, but for most people these days, drive C IS their harddrive) all at once, WITHOUT resorting to funky dos boot disks and the like.

It’s called Backup Your Entire Computer (catchy, eh?), and it’s located in the Backup and Restore Center on the Control Panel.

image

Basically, grab yourself a USB drive big enough to hold your entire C drive, open this window and click the Back up Computer” button.

It could take a while, so USB 2.0 is best, esp if you have several hundred gig to back up.

But, there’s an even handier way to work with it!

The command line utility wbadmin (Windows Backup Administrator) allows you to perform a complete computer backup directly via command line (or, more conveniently, via a batch file).

You run it like this:

wbadmin start backup -backuptarget:k: -allcritical -quiet -vssFull

where k: is the drive letter of the USB drive that you want to backup onto.

Couple that with the Task Scheduler to run this batch file automatically every night and you have a nice, simple way to guarantee that your drive is completely backed up.

And finally, Windows Backup creates a VHD file from your harddrive as the backup. Anyone familiar with Virtual PC might recognize VHD files as Virtual HardDisks.

And that might also mean you could open that vhd file without actually having to restore the entire thing. And you’d be right! Very cool. The details on doing so are fairly involved, but mainly it requires that you install the free Microsoft Virtual Server, if only for the Mount Virtual Hard Disk tool, which comes with Virtual Server.

Once you have that tool installed, you can mount a VHD back up file and it will appear to be just another harddrive on your computer. You can actually copy files from it or to it at will.

It’s not as easy as it should be, but it’s not too tough. Bart DeSmet has a really good description of doing exactly this on his site.

Debugging VSTO problems

0
Filed under Uncategorized

If you’ve ever worked on a VSTO addin, you may know how frustrating it can be to try debugging problems with them, especially problems of the “my addin isn’t being loaded” variety.

There is a way to get a little more information on the process, however.

Just set the environment variable VSTO_SUPRESSDISPLAYALERTS to “0”, and then restart the Office app of you choice.

Now, instead of just quietly failing, the VSTO loader should be a little more verbose about what’s happening.

In my particular case, it didn’t help all that much, but I could definitely see it helping in many cases.

Microsoft also has a KB article about it, but you’d almost never find it unless you knew what your were looking for up front.

Vista, XP, SQL Server 2005, Workgroups and Connections

1
Filed under Uncategorized

Whew! The title says it all.

imageI recently had a little problem with my server. Notice the 3 blown caps.

I had my 5 year old daughter take a look. Without pointing out anything in particular, I asked her “Ok, this computer isn’t working right. Any idea why?”

She looked around with a flashlight for about a minute and states “Those 3 batteries look like they’ve gotten dirty. Maybe you need to clean then up?”<g>

So, I’ve got no server as of now.

Fortunately, all my SQL databases I use for testing get backed up every night, so I still have them all. Unfortunately, the SQL Server installation itself was on that blown machine<sigh>.

I’d been wanting to virtualize my server for some time now, so this was the perfect opportunity. I fired up VMWare, cloned an existing XP VM I often use for testing, cleaned it up, put SQL Server 2005 on it, ran the SQL SP2 update, then restored all my DB backups. No problem.

With the VM running on my workstation, I loaded SQL Server Management Studio on my workstation and tried to connect to the virtual server.

image

(for search purposes, the message is “Login failed for user ‘argos\guest’. (Microsoft SQL Server, Error: 18456)”)

Hmm. I was pretty sure I had things set up right. So I tried SQL Authentication with the SA user and password.

I’m in.

Ok. That’s odd. And why is it trying to connect me as guest? Wait… Originally, my server was running Win2003 Server, so it had DNS setup. With it gone, I’m in workgroup mode. Ah! I didn’t have matching user accounts on this new virtual server and on my workstation. Set up a matching account, and try a remote connection request to the SQL Server from my workstation. Still no dice.

I checked the SQL ERRORLOG file (you can typically find it in C:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG), and I end up with this:

2009-02-05 16:11:36.36 Logon       Error: 18456, Severity: 14, State: 11.
2009-02-05 16:11:36.36 Logon       Login failed for user ‘ARGOS\Guest’. [CLIENT: 192.168.100.110]

That STATE number is the key. A state of 11 means “Valid login but server access failure” (There’s a really good table of error states here).

That was the clue I needed. After way too much googling, scratching my head and trying random things, I eventually came across this post by Jens Suessmeyer.

The short of it is that, under XP anyway, if you are running in a workgroup (ie non-domain) and you have Simplified File Sharing turned on, this will cause SQL Server to ALWAYS force remote authentication requests to fall back to the Guest user. It was only after I’d found the above post that I came across this MSKB article that describes the problem in more detail.

So, it’s off to the Folder Options dialog, I uncheck the Use Simple File Sharing option:

image

And, no more connection failures!

So, to sum up. If:

  1. You’re using SQL Server 2005 (and likely other versions as well).
  2. You’re running in a WORKGROUP environment
  3. You need or want to use WINDOWS AUTHENTICATION and not just SQL Authentication
  4. You set up a login on your server and your remote machine that exactly match in username and password
  5. You’ve enabled SQL Ports 1433 and 1434 through your firewall.
  6. You can connect via Windows Auth just fine when you run SQL Management Studio from the server
  7. BUT you get a connection error indicating that your trying to connect as GUEST, when you were expecting to connect as your current username.

Then you most likely need to turn OFF Simple File Sharing on the SQL Server machine.

Changing the Windows XP Product Key

0
Filed under Uncategorized

I was working with a quite old inherited virtual machine today (VMs have a nasty habit of getting old and unpatched), and I needed to have SP2 (actually XP SP3 is out now) on it (to install SQL Express, among other things).

The problem was, this VM had a installation of XP, no service packs, using a product key who’s ancestry was, shall we say, questionable, at best.

Of course, I have several valid product keys from MSDN subscriptions, so I’m completely legit. But I needed to get this VM squared up so I could get products installed on it.

In the past, I’ve used a technique I found online whereby you edit a registry entry to invalidate your current activation (and thus force Windows to want to reactivate itself), then you run the msoobe.exe application with a certain command line to relaunch the activation process. Not to hard, but it didn’t work with my legitimate WinXP product keys. I have no idea why not, and there was nothing in any of the messages to indicate what was wrong.

Then I happened across a link to the Windows Product Key Update Tool.

A quick download and it worked perfectly. It properly accepted the product key for XP from my MSDN subscription, updated Windows and reactivated it straight away.

Certainly, a very handy tool to have in the stable!

XAML editor crashes Visual Studio 2008 SP1

0
Filed under Uncategorized

A week or so ago, I decided to try my hand at a little XAML, so I loaded up VS2008, started up a simple project and created a few forms (or whatever they’re called in WPF speak).

Anyway, I hadn’t gotten but maybe 10 minutes in when VS crashed. Hard crash. No error message, or dialog of any sort, just closed out.

I reloaded the project and tried again. Immediate crash as soon as I loaded up any XAML file.

I let it sit over Thanksgiving (I believe it’s always good to give a system a chance to think about what it’s doing before you really lay into it<g>) and tried again today.

No joy.

So I started researching the issue and came across a pretty active thread about just this problem.

Long story short, uninstall Power Commands for Visual Studio 2008 if you’ve got it installed and have VS2008 SP1. It doesn’t look like PowerCommands has changed since April and there definitely seems to be issues with it and SP1.

Compressing Memory Streams

0
Filed under Uncategorized

One thing that has definitely taken some getting used to (for me anyway) in VB.NET is the whole concept of streams.

I like the idea, generally, but I was working through some code to stream debugging info into a resource in an already compiled EXE file when I ran into a problem with decompressing the resource data.

It just wouldn’t decompress properly.

After backtracking and puzzling over it, I discovered that the problem was actually in the compression phase.

   Private Function pCompressStream(ByVal UncompressedStream As MemoryStream) As MemoryStream
      Dim CompressedStream As New System.IO.MemoryStream()
      Using GZip As New System.IO.Compression.GZipStream(CompressedStream, System.IO.Compression.CompressionMode.Compress)
         GZip.Write(UncompressedStream.ToArray, 0, UncompressedStream.Length)
      End Using
      Return CompressedStream
   End Function

Note the Dim GZip line? If you look at the overloads, there’s a possible 3’rd option, LeaveOpen. It defaults to false.

From what I can tell, if you connect a GZipStream up to a FileStream, there’s no need for this parameter. When the GZip closes, the file is closed and on you go.

But, with MemoryStreams, it’s quite unlikely that you’d want to close the resulting output memory stream after zipping data into it.

But that’s exactly what happens if you don’t set LeaveOpen to True.

What’s worse. You need to Close the GZipStream before reading that MemoryStream(either by using a USING block as I have, or by calling Close directly). If you don’t, garbage collection might not happen for some time and the final data in the internal GZip buffers won’t get written to your memory stream, resulting in only partial compressed data, which definitely won’t decompress properly!

All this is likely old hat to grizzled .NET heads, but if you’re like me and coming from an extensive VB6/assembler background, it can certainly causing some headscratching for a bit.

Slow Vista Copying and Deleting

0
Filed under Uncategorized

image Like a lot of people out there, I’ve been bitten by the Vista “Slow Copy/Delete” bug many many times myself.

I finally decided I’d had enough today and when looking for a solution.

I came across a couple of posts discussing a hotfix available from Microsoft, but it’s apparently not that easy to get a hold of, and its a questionable fix at that.

Then I happened across a short post in a SlashDot discussion that mentioned turning off thumbnails in the Explorer view.

I’ve never heard of that one, so I gave it a quick shot.

First, open the Folder Options:

image

Then, just make sure the first option “Always Show Icons, never thumbnails” is checked:

image

Surprisingly, this does seem to a have a pretty dramatic effect on the copying and deleting processes, as well as noticeably speeding up the time it takes to get from a right-click to actually seeing the right click context menu in Explorer. It’s still not instant like it should be, but it’s better than before.

I’ll keep playing with it and post if I discover any other interesting bits about this seemingly easy workaround.

Fixing System.String, part 2

0
Filed under Uncategorized

I talked about fixed the IsNullOrEmpty method on the string object here.

But another aspect of the string object that has irritated me for a while is the Length property.

Obviously, the Length property returns the length of the current instance of a string variable.

However, because it’s an instance property, it can only be invoked against variables that have actually already been initialized to some value.

If you try and run this code, you’ll get an Object Not Set error when you execute the second line:

dim s as string
debug.print s.Length

Now, anybody that’s coded in VB intuitively knows that an unitialized string has a length of 0, and such a request should certainly  not result in throwing an error. It doesn’t matter one whit whether this is technically incorrect or not. I my book, those issues are for the compiler to work out, NOT the programmer.

Since the string class is an intrinsic type and we really can’t inherit from it or extend it in any traditional way, is there any way to correct this gaff?

With VB 2008, there is.

I blogged a bit about extension methods in the previous mentioned post and that’s what I’ll use to fix the Length property as well.

Unfortunately, as I also mentioned in my previous post, Length is a property  and not a method, so you can’t create an extension method for it directly, which is a shame.

However, long time VB programmers don’t think to use “Length” anyway, you always retrieved the length of  string via LEN(stringname), and LEN is not a member of the string object.

So, just add the following to a module to your application:

Imports System.Runtime.CompilerServices

Module StringExtensions

    ''' <summary>
    ''' Returns length of the string or 0 if the string is empty or has never been assigned (is nothing)
    ''' </summary>
    ''' <param name="aString"></param>
    ''' <returns></returns>
    <Extension()> _
    Public Function Len(ByVal aString As String) As Integer
        Return Microsoft.VisualBasic.String.Len(aString)
    End Function
End Module

and you’ll have a LEN function available directly from any string variable that will work regardless of whether the variable is initialized or not.

Also, note the <summary> comment. This will be displayed by Intellisense in the IDE, which can be quite handy.

image

And finally, you can’t use Return Len(aString) in the function, because doing so would be treated as a recursive call to the Len Extension method itself! Thus, I fully qualify the call to the Microsoft.VisualBasic.Strings LEN function.

All of this begets the obvious next question, “Why not just use Len(stringvar)“?

To which, I have no good answer.

Maybe it’s just a .NET thing<g>

TurboTax no longer includes a free E-File

0
Filed under Uncategorized

image I realize this is a little late, and almost totally off topic from Visual Basic, but it is a peculiar business decision, if you ask me, which, in a way, has to do with developing VB apps.

Intuit has decided, according to their support staff, that as of this year, if you purchase the CD version or download version of TurboTax (ie, the fat client), you no longer get a single E-FILE for free. You have to pay an extra 17.95 for that privilege.

Now, TurboxTax has always been a pretty good deal in my book, but with the competition in the marketplace now, I can’t see how this is possibly a good idea, other than possibly to drive business to their online offering, which does still offer a free E-File.

Oddly, though, the online version doesn’t have the same “FORMS” mode that the fat client does, thus you can ONLY use their “interview” style format to enter data, which can be cumbersome in many cases. Hence, the two aren’t interchangeable.

I suppose to their credit, they did offer to refund the E-File charge when I complained about it. But by the time their support emailed me back, I’d already printed and mailed my return.

Yet one more reason that FairTax seems more and more like a better idea.

Go there, check it out, and if you agree, and sign the petition.

HyperTerminal and Vista

0
Filed under Uncategorized

Ok. Yet one more reason to dislike Vista.

Granted, I don’t regularly use HyperTerminal, but when you need to hack at some AT commands, well, it sure was handy to have around.

And it’s been there ever since, what, Windows -1?

But alas, no more.

So, off on the hunt I go. Now, I’ve known about puTTY for quite some time, but I always thought it was a telnet/TTY client. But much to my surprise, it just relatively recently got an upgrade with direct serial access under Windows.

image

I gotta say, for dinking around with your typical modem setup, this new puTTY honestly seems to work far smoother than HyperTerminal ever did.

C’est la vie, HyperTerminal. May you rest in peace.