Monday, October 20, 2008

Strange Behavior When Your .NET Application Uses ActiveX/COM and Data Execution Prevention (DEP) is Enabled?

This issue was extremely obscure, but I wanted to document it anyway. The moral of the story is, if your .NET application is using an ActiveX/COM object, and is behaving strangely on Vista with DEP enabled, try to get DEP turned off and see if anything changes. In our case, a third party ActiveX/COM object was trying to pop up a window, and DEP was killing it, causing strange behavior in the application we were debugging.

Details...

We've got a MagTek MICRImage check reader, and we've written a program in .NET that communicates with it, and everything works fine. We are using SaxComm8.ocx to communicate with the reader (an ActiveX object that is using AxInterop for .NET use).

Next thing you know, we are trying to debug the application, and the checkreader no longer triggers any "check read" events when you scan a check. Communication otherwise works fine with the reader. We'd checked everything to do with your serial ports.

In our case, it turns out it was a combination of the SaxComm8.ocx code being overwritten by a previous version we had that was a trial only. Typically this trial version pops up a warning box about the trial period. But in Vista with DEP running, this dialog was never appearing. Most likely this was then causing the SaxComm8 object to go into a weird state, no longer communicating with the reader.

Finally found that DEP was causing the problem. Then I discovered Vista would not allow me to disable DEP for this app (WHY?!). Used the command bcdedit /set nx AlwaysOff, and restarted. Of course, now DEP is totally disabled, but finally I was able to see the trial notice popup and realize what was happening.

Once I overwrote all trial copies of the .ocx file, I did a regsvr32 /u saxcomm8.ocx to unregister it, and a regsvr32 saxcomm8.ocx, to register it, and now everything works!

Wednesday, September 3, 2008

Unable to Install Update for Office 2008 for Mac

If you are trying to install an update for Office 2008 for Mac, and you're getting an error that says, "A version of the software required to install this update was not found on this volume," keep reading for a possible solution that worked for us....

We had installed Office 2008 for Mac fresh on an iMac with Mac OS X 10.5.4. We then ran auto update, and 12.1.1 updater ran successfully and patched Office. We then ran auto updater again, and it wanted to patch to 12.1.2. This FAILED indicating no volume could be found running the appropriate version, similar to this:



We did the steps below and it worked:

  1. Download the update from MacTopia, instead of letting the Microsoft AutoUpdater download it.
  2. Once the .dmg file is downloaded and mounts as a virtual disk, copy the updater software from the virtual disk over to your desktop, and unmount the virtual disk.
  3. OPTIONALLY: Temporarily run as an Administrator account, if possible... (this worked for me)
  4. OPTIONALLY: Run Disk Utility and fix permissions on your disk.
  5. OPTIONALLY: Reboot.
  6. Run the updater software directly from your desktop. It should work.
You can skip over the steps 3, 4, and 5 if you want to try your luck, but if it doesn't work, try it again doing those optional steps.

Wednesday, March 26, 2008

Triggering Events on page load (and right before)

  1. Use prototype.js in your page.

  2. Call the Prototype function Event.observe() for the 'load' event. You can call the Event.observe() function as many times as you want, it will simply append your code each time, so as not to clobber each other when the event is fired. There are two ways you might perform this call. If you have a function you want to run, simply call:

    Event.observe(window, 'load', yourFunctionName);

    If you have a bit of code you want to run, call this instead:

    Event.observe(window, 'load', function() {
    // your bit of code here
    });
Do you want it to run onLoad... or onDOMLoad?

One important thing to realize is that the 'load' event for a page only fires AFTER all images on the page have been loaded. This may take a while, depending on your page design. You may be thinking that you will just run your bit of code when the page first starts loading. The problem with that is the DOM is not completely available yet, so your code will usually fail.

This guy has some javascript code that allows you to basically "observe" the onDOMLoad event, even in browsers that don't really export such an event. If you use his code to attach code to this event, it will run after the DOM is available, but before the "onload" event is fired for the page body.

The downside is it doesn't use prototype.js, so it may actually overlap a bit of that functionality. However, as of Prototype.js 1.6, their site was actually pointing to people to this guy's examples, so presumably that means there is no current expectation that Prototype does or will offer similar functionality.