Category Archives: Uncategorized

I fixed that, Dammit!

3
Filed under Uncategorized

If you’re trying to validate an installation in InstallShield (version 11.5, in case that matters), here’s a little something to be aware of.

First, some background.

InstallShield sucks.

Ok, now that that’s out of the way, if you have to use it, you may find yourself needing to perform a validation on your install. I did when a customer called up telling me that they couldn’t deploy my install using Active Directory Group Policy because when they tried, AD GPO gave them an error that the install wasn’t valid.

Which it most certainly was, because tons of people have used it to install over that past 2 years.

Anyway, the customer happened to have WISE, so they ran a validation on it and got quite a few errors flagged.

So, I run InstallShield validation on it and I see quite a few errors too. Oops.

Well, to be honest, installs aren’t job one, and if the damn thing installs and uninstalls properly under all the test scenarios that we’ve cooked up, why would I even think to validate it?

None-the-less, it had issues. So I start investigating. Come to find out, the errors are things like “Foreign key not found in table blah” and such forth.

Whah?! You mean, InstallShield will actually build an install that contains patently incorrect or missing foreign keys between tables. Hey, if I was using ORCA to build installs, I could see this, but isn’t that what spending all that dough on InstallShield is supposed to buy you?

Fine, so I fix the foreign keys and revalidate. Same damn errors! Not one thing is gone from the validation errors list. WTF!

I puzzle over it for 15 minutes or so and then give ’em a call.

Ah. You have to rebuild your entire installation before rerunning the validation! Oh. That makes sense. And, um, exactly why doesn’t IS simply pop up a msgbox telling me I need to rebuild, or better yet offering to rebuild. It knows I just ran a validation. It knows I just made a few changes. Shouldn’t it know I’m not going to get valid results if I just run the validation without rebuilding?

This just seems like UI 101 to me, not Advanced AI 5.

Living Code

0
Filed under Uncategorized

I’m sure someone, somewhere, has already done a dissertation on this, but I’ve often thought it would be interesting to look at the code of a project as if it was a living, growing thing.

You’d analyze the changes made over time to a piece of code to visualize how it becomes better, breaks, corrects, expands and ultimately dies or gets recycled refactored, as well as the people making those changes, how long it took to make the changes, the number of changes on any given day, or possibly daily trends. Does more get fixed on a monday? Do more fixes made on friday end up getting reverted and fixed again later (for obvious reasons <g>). How many changes are made on wednesdays after that big fajita lunch?

I have this mental picture of my project visually changing over time, allowing you to see things that you couldn’t see just by looking at tables and metrics. Imagine being able to look at a time-lapse video of the creation of the Grand Canyon, from, oh say 30million years back to the present, in a video of a few minutes. Or a bit like this guy’s video (taking pictures of himself everyday for 6 years or so).

But in my head the picture is a little prettier, may something like this: 

And many, probably too many, projects would be more like this:

 

Deploying VSTO

2
Filed under Uncategorized

Just follow these easy steps:

http://msdn2.microsoft.com/en-us/library/2ac08ee2(vs.80).aspx

Whatever happened to all that buzz about how great xcopy deployment was with .NET.? I seem to hear it out there…..somewhere….sinking slowly into that morass of the Windows API, calling out for help, meekly, gurgling, and then….

Fun With Word, or When is a Field not a Field

2
Filed under Uncategorized

I was investigating some strange behavior with respect to fields in Word and when, exactly, do they get “automagically” updated.

In this particular case, I had a document with a table of contents. The TOC looked completely correct, until the doc was “saved” as a PDF file using the Word 2007 PDF/XPS format plugin. In reality, it doesn’t matter whether the doc is saved as a PDF or printed, Word functions in the same way.

During the save to PDF, the TOC entries were all converted to “Error! Bookmark not defined”. In this case, that was correct. The bookmarks used to create the TOC entries had been removed, but, with the “Update fields” options set to false, I was expecting the fields in the TOC to NOT get updated.

image

As far as I can tell, they really shouldn’t  get updated, but they do anyway. This appears to apply to Word 2000 as well as 2007 (didn’t check all the interim versions).

So, TOC Entry fields appear to not behave by the same rules as other fields. For instance, I embedded an AUTHOR field, save the doc, then changed the Author Document property to something else, then saved as PDF. Lo and behold, the Author Field DID NOT change from it’s original value, meaning that that field type was not “auto updated” before the print/save as PDF.

Then I tried just a plain bookmark. Insert a named bookmark somewhere in the doc, then somewhere else, insert a PAGEREF field (type 37 for those Word VBA masochists) pointing to that bookmark.

The field should take on the value of the page the bookmark is defined on.

Now, delete the bookmark (not the pageref) and print.

Aha! Another “Error! Bookmark not defined”.

It’s not TOC Entries, per se, that have the problem. It’s bookmarks. It appears that even if you tell Word to NOT UPDATE fields at print, any field that references a bookmark, does get updated. And it’s not just that Word checks that the bookmark is defined or not. Word definitely updates the field referring to the bookmark. You can see this if you do the following:

  1. Create 3 HEADING1 lines
  2. Create a TOC, you should see 3 entries in the TOC, one for each heading 1 line, all pointing to page 1.
  3. Put page breaks between each heading 1 line, to force them to separate pages.
  4. Save the doc. The TOC page numbers don’t change.
  5. Now save as PDF. The TOC page number DO change at this point.

Looks like a Word bug, albeit a long standing one.

And the workaround?

You have to decide between:

  • Leaving the field that refer to the bookmark in the document, but deleting the bookmarks themselves, which will result in an Error.
  • Deleting the bookmark AND the field that references it (which would wipe out your TOC)
  • Converting all fields that reference bookmarks to text and then deleting the bookmarks (probably the best of the choices) 

There’s no easy answer to this one, unfortunately. That last option involves quite a bit of scanning through fields and bookmarks. Interestingly, Bookmarks must have a unique name, so they are pretty easy to get back to and track.

Fields, on the other hand, have no unique ID in Words object model. 

They have a “code”, but that can be the same across multiple fields.

They have an “index”, but that can change as you delete fields.

From my vantage, the lack of unique ID’s for many of the elements in the Word Object model is a significant, if not partially understandable, problem.

Strings in a File

0
Filed under Uncategorized

Working in metadata removal from Office documents, one thing I do almost constantly is dig through files with a hex editor looking for any text that’s readable.

I’d been contemplated writing a string filter utility for some time when I happened to see an offhand mention of something like that from SysInternals.

Now, if you’ve ever played with anything from the guys at Sysinternals (now a part of Microsoft), you know their stuff is gold, so I had to check it out.

The utility is called Strings. It does exactly that, pulls strings (both ANSI and UNICODE) from any file you throw at it and spits em out STDOUT. Pipe it to a file and it’s MONEY, BABY!

Even better, put STRINGS.EXE and this little BAT file somewhere on your path, then setup a shortcut to the BAT file in your SEND TO folder, and you can Right click-Send To on any file and immediately have all the strings loaded up into whatever Text Editor is currently associated with TXT files. And that, as an old boss of mine would say, is “bells, whistles, hell, it’s the whole damn midway!” 

ECHO OFF
REM Run the strings.exe program to extract all strings from a given file
REM Then load the file into an editor
REM 
REM Create a Shortcut to this BAT file in your SENDTO folder to make it even
REM better! Then, you can right click, select SEND TO and immediately get a full
REM list of strings embedded within the file loaded into your editor.


REM Extract the strings to a temp file
strings -q %1 >"%temp%\%~n1-Raw.txt"


REM Sort strings to make it a bit easier to find things
REM This may or may not be something you want to do consistently
REM Either do the sort or the copy
REM sort "%temp%\%~n1-raw.txt" /o "%temp%\%~n1.txt"
copy "%temp%\%~n1-Raw.txt" "%temp%\%~n1.txt"
del "%temp%\%~n1-Raw.txt"


REM -----------
REM Use this to load the file into whatever editor is associated with a TXT file
REM -----------
start "Strings" /I /B "%temp%\%~n1.txt"

REM OR

REM -----------
REM Use this to load the file into a specific named editor
REM -----------
REM o:\dev\protools\textpad\textpad "%temp%\%~n1.txt"

Vista Reliability Update

2
Filed under Uncategorized

If you’re running Vista, you might want to check into KB938979.

It’s call the “Performance and Reliability Update for Vista”. There’s actually 2 different packs, one for 32bit and one for 64bit.

In my case, Vista Explorer was just crashing, almost constantly, when I was copying files around (I got into a house cleaning mode this morning and started shuffling files into a little better folder structures).

It’s a 10mb download, so it’s not utterly trivial, but it’s not 300mb service pack either.

I just have to wonder what actually got changed when MS rolls out patches like this. Just once, wouldn’t be interesting for MS to roll out a patch that included a DIFF report. You know, not ALL the code, per se, just what the old line was and what it was changed to, what was deleted and what was added.

Wouldn’t THAT make for some interesting reading?

New Apophysis Piece, “Above and Below”

0
Filed under Uncategorized

image

I just kind of stumbled on this while playing with Joel Faber’s Flipped Disc technique. He and his brother do some amazing stuff in Apophysis.

I had no idea you can get two almost completely different fractal styles in a single image.  Definitely warrants more play.

dasBlog 2.0 is Up!

3
Filed under Uncategorized

Not sure if it’s working entirely yet, but it appears to at least be serving pages.

Let me know if you notice anything amiss.

Authentication Error running Web Site in VS2005 in debug mode under Vista

0
Filed under Uncategorized

I haven’t been coding too much in ASP.NET, and it seems like every time I sit down to do something in it, things have gone fubar in some random, unexplained way.

The latest example. I went to start a web app that I’d debugged plenty of times before and ended up with

Unable to start debugging on the web server. An authentication error occurred while communicating with the Server

Ok, start googling. 

I tried everything I could find to no avail.

Then I happened on Mike Volodarsky’s Server Side and this article.

I’d run smack into a full-on bug in VS2005, and not a small one. Mike’s post details why all of the alternatives have their drawbacks and then he presents his “Debug Assistant” that works around the bug and allows you to start in F5 debug mode anyway.

And even better, he updated the post with details about KB article 937523 that describes a hotfix to resolve this problem.

Unfortunately, the hotfix is one of those that MS insists you call them to obtain, but Mike makes the link available. It’s here.

Anyway, downloaded the hotfix, applied it, and I didn’t even have to reboot. Debugging works great (ie like it should have in the first place) now.

A big thanks to Mike, for posting about this bit of VS nastiness.

Now, it’s ~3hours later. What was it I sat down to take a look at in my ASP app again?

VB6 and Typelibs

5
Filed under Uncategorized

Ages ago, I happened onto Bruce McKinney’s HardCore VB and the Win.TLB file that he created and I was hooked.

Ever since, I’ve been a big fan of using typelibs with VB6. They’re relatively compact, support help, work nicely with Intellisense, and, most importantly, any elements of a typelib that your project doesn’t use, don’t get compiled into you project, unlike standard VB DECLARE statements.

Furthermore, typelibs provide just about the ONLY way to access certain COM interfaces that are normally declared with attributes that make them unusable by VB.

For examples of that, check out Edanmo’s page, or the VBAccelerator stuff.

I’ve been using Matt Curland’s Excellent PowerVB Typelib editor to edit, extend, and generally hack and bash the original win.tlb (I generally don’t use unicode much explicitly, so I haven’t kept the WINU.TLB unicode variant up to date, unfortunately). Note, though that you have to buy the book to get the editor. If you do this much, the editor alone is worth it, but the book is truly the best books on low level VB6 out there.

Doing things the Right Way

However, I really wanted to get this thing back into shape, and I felt like the best way to do that was to get it BACK into IDL format, and then use the MIDL compiler on it.

You’d think that doing so would be, basically:

  1. Load the TLB into OLEVIEW
  2. Export the whole thing as an IDL file.
  3. Edit the IDL with a text editor
  4. Run MIDL on it to recompile the WIN.TLB and presto! Nice new, clean tlb file.

Sigh. Is anything ever that simple?

Problems, Problems

First, OLEVIEW exports things in completely the wrong order (I’m not exactly sure what it uses to order things other than just the defined order in the TLB). As a result, I got tons of “symbol not defined” errors when I compiled, because a call referenced a structure that was defined later in the IDL, and didn’t have forward declaration.

Shuffling LOTS of typedefs around, I resolved all that, only to end up with tons of MIDL2022 “illegal or missing value for entry attribute”, as well as MIDL2270 “duplicate UUID” errors.

The duplicate UUID errors I fully understand, even though I really don’t like it. Basically, the TLB “redefines” a number of internal COM interfaces to make them usable by VB, for instance IEnumString.

However, MIDL doesn’t allow you to redefine an interface that already exists, and that particular interface does already exist.

In that case, commonly, you just rename your new definition to, say, IVBEnumString.

And with mktyplib and Matt’s TLB editor, that’s no problem. But MIDL see’s the old IEnumString (defined in the automatically INCLUDEd OBJIDL.IDL) and the new IVBEnumString, notices that they have the same UUID (which they must) and throws that MIDL2270 Duplicate UUID error.

Bruce resolved this by actually copying the OAIDL.IDL, OBJIDL.IDL, UNKNWN.IDL and WTYPES.IDL from the Visual Studio 6 Include dir right into his TLB project, and modified them as necessary. It works because of the MIDL search rules, but I REALLY didn’t want to continue mucking with the MS IDL files. I’d much rather just redefine those that I need to redefine and be done with it. Just seems like a safer alternative.

Ok, fine, so I go back to mktyplib and move on.

Not so fast, young Skywalker!

mktyplib is an older tool (read, unsupported, not maintained, and generally considered just that much bit junk now). And sure enough, a very common element in my type lib, it doesn’t support, namely non-variant optional parameters.

I have a line of ODL (mktyplib’s prefered input file type) like:

      HRESULT _stdcall Commit([in, optional, defaultvalue(0)] STGC grfCommitFlags);

And it has no idea how to handle that OPTIONAL and I have too many of these to bother counting them all (ok, not really, there’s 64).

I really don’t want to have to make all those method parms suddenly “required” when they’re not.

The Cycle of Irritation

So, here I am, hours later, and back where I started.

I’m going to continue using the PowerVB editor to update the WIN.TLB file.

And just to recap, my version started from Bruce McKinney’s ANSI version, generally targeted at VB5, then pulls in LOTS of additional COM interfaces, ala Edanmo, VBAccelerator, and others, corrects some issues with certain calls that VB5 had no issues with but VB6 didn’t like, throws in lots of new ENUMS for parameters of functions instead of just blind LONGs where you get no Intellisense, and rounds things out with a little bit more help text for some methods (though that’s still pretty spotty).

One nasty habit of TypeLibs

One thing to be very careful of if you do start working with typelibs, is to make sure that any API function you decide to pull in and actually use will exist on the target machine.

These days, that’s not particularly hard. Win2k through Vista have changed very little as far as typical low level API’s are concerned.

At one point, my apps were running on everything from Win95 through XP, and there were definitely issues with commonly used functions existing under Win2k or XP that had no equivalent under 95 or 98. In those few cases, I just resorted to a standard VB declare and then error trapped the call. If the function wasn’t available, you’d get an error, trap it and deal with it.

However, if that same function was defined in a typelib, the app loaded will validate all implicitly linked libs and try to resolve them all at load time. If it failed for ANY function, the app won’t load at all, and all this happens before any of you VB code has a chance to do anything about it.