SSD’s firmware version might be really important

I had a good old Asus EEE 1005HA netbook running Windows 7 just fine, albeit slow. The best way of speed it up was to upgrade it to a SSD. The I/O difference should speed it up considerably as the original disk was a 5400rpm one. The SSD prices are low enough, too.

So I went and bought a small, reasonably priced OCZ Vertex Plush 60GB SSD. The disk replacement process isn’t a very simple one because the disk is buried in the guts of the netbook. See one and two (there are more videos, just google them) and be careful with the connectors as they are really fragile.

I’ve replaced the disk, put everything back together and then booted Windows 8 x86 from an USB stick (the easiest way to burn an ISO to an USB stick is to use Windows 7 USB/DVD Download tool). Everything went smooth until Windows finalized the setup. Bam. I’ve got an “Windows couldn’t configure hardware on this device” error (very helpful description, isn’t it). After restart the computer didn’t boot but rather complained about missing boot disk. Huh? That’s odd and when Windows install fails it has to do with hardware issues usually – this time it hinted some sort of problems related to the SSD. Perhaps the problem lies in the Intel Atom CPU or something other on my netbook. Hence I’ve tried installing Windows 7 x86 as I knew it works. Bam. The same error. Changing BIOS settings didn’t help either. Same error over and over again. I’ve also got odd errors during partition management. BTW I’d really like to know which genius at Microsoft thought of requiring the Windows license key before OS is installed (yes, yes, you have to retype it each try you make, very annoying in such cases). Just for fun I tried installing Ubuntu and, surprisingly, I had no problems and everything was really smooth. At this point I was tempted to leave it with Ubuntu but I had other requirements and had to have Windows.

Then I started googling around if somebody experienced similar problem and after a while I’ve come to a forum thread where they mentioned very faulty OCZ Vertex Plus firmware. According to that thread older (than the latest 3.55) firmware versions have fatal issues with Windows. Only the latest and newest 3.55 should work. Coming from HDD world I never thought that a disk firmware could create such havoc but it fitted the description of my problems. Note that there is no easy way to check the disk’s firmware version without the OS installed (and even then). Anyway, there is an ISO you have to burn to a CD and boot computer from there (beforehand make sure the SSD is in IDE, not AHCI mode). The ISO is linux based and you’d need an utility to burn it to USB stick (netbooks don’t have CD drives usually). Free UNetbootin does the work just fine.

Once I’ve booted from firmware upgrade USB stick I discovered that my SSD was running firmware version 3.50. Bingo. Update went smoothly and after yet another Windows 8 reinstall everything worked as it should.

Sometimes (Visual Studio) error messages are just misleading

Take into account this code

Task.Factory.StartNew(
    () =>
    {
        throw new Exception();
    }).
    ContinueWith(
        t =>
        {
        },
    TaskScheduler.FromCurrentSynchronizationContext);

Which results in following error:

error CS1593: Delegate 'System.Action<System.Threading.Tasks.Task,object>' does not take 1 arguments

If I use an overload that takes TaskContinuationOptions.OnlyOnFaulted instead of TaskScheduler.FromCurrentSynchronizationContext it just works. There are two overloads (among twenty of them) of ContinueWith:

public Task ContinueWith(Action<Task> continuationAction, TaskContinuationOptions continuationOptions);
public Task ContinueWith(Action<Task> continuationAction, TaskScheduler scheduler);

So, why does the later work and the former doesn’t? Can you guess without reading on?

The explanation is really simple - TaskScheduler.FromCurrentSynchronizationContext is not a property but a method and thus it should be used like TaskScheduler.FromCurrentSynchronizationContext(). Once brackets are in place it works. Rookie mistake.

However the C# compiler’s error message is misleading in this case. Instead of reporting that FromCurrentSynchronizationContext is a method and not a property it yields “can’t find proper overloaded method”. At least it could yield both errors.

Righthand Dataset Debugger Visualizer updated to 1.0.8

Here is the list of what’s have been added/changed in 1.0.8.:

  • Fixed Next Change, Next Error
  • Added contextual menu features on row right click: Delete/Remove row, Accept/Reject row changes, Clear row errors
  • Fixed original value showing (it could appear multiple times)
  • Added a bunch of columns in table list (Errors count, Changed rows count, Rows count, Added rows count, Modified rows count, Deleted rows count). Errors and Changed count are background-lit when non zero to emphasize errors and change presence
  • Renamed File/Commit and Exit to Persist and Exit to avoid confusion (this item persists changes back to the data owner - your application being debugged)
  • A message box warning when closing visualizer when changes are present
  • Empty table's name is gray in table list
  • Added tooltip on column header showing column's name, caption, datatype, defaultvalue and whether it is nullable
  • Grouping now works on RowState

Go, grab v1.0.8 from dedicated page and visit forums as well.

Intel Smart Response Technology and not so smart UI technology

Due to some recent BSODs on my system where I couldn’t find out the source of the problems I’ve opted for a simple solution of replacing CPU, motherboard and RAM. I am not a huge believer in SSDs due to their problems (pricey, not exactly super reliable) but still, I decided to go with a SSD used for caching purposes – small and relatively inexpensive SSD required.

Currently I am running a pair of WD Velociraptor disks in a RAID array and a pair of Seagate’s 1.5TB disks in the second RAID array both controlled by Intel Rapid Storage Technology (IRST). On each of the RAID arrays I have two volumes – one in RAID 0 and the other in RAID 1 configuration (I use the zeros for speed and non critical data – mixing RAID modes on the same array is courtesy of IRST driver). SSD caching would improve the read time while I would keep the RAID benefits. The only downside to this approach is SSD wear time, but time will tell.

There are basically two SSD caching options I am aware of – either a SSD with bundled Dataplex caching software or motherboard that supports Intel Smart Response Technology (ISRT). Mind though they are both purely software solutions. Well, Intel is Intel and ISRT supports RAID arrays (probably just the ones based on their Rapid Storage Technology which I am using). One of the few motherboards supporting ISRT is Gigabyte Z68XP-UD3 (there is even Z68XP-UD3-iSSD version with Intel 311 20GB SSD (<- Intel’s recommended SSD for caching) on the mainboard). However the later is hard to find in my country so I went with the former. ISRT is limited to max 64GB SSD size and thus I bought an OCZ Vertex 3 60GB SSD.

With all pieces at my disposal I built new hardware configuration, properly attached SSD to a shiny SATA III port, installed the EZ Smart Response drivers that come with motherboard (ISRT drivers are not downloadable from Intel’s Download Center for some reason) and restarted the computer. Once rebooted I went into Rapid Storage Technology control center (where ISRT UI feature is supposed to live) and nothing. No such option, nada.

image

There was no sign of Acceleration options. Nothing. Huh? EZ Smart Response drivers installed a shortcut in Start/Programs menu. Tried clicking that and received a very useless dialog box stating:

---------------------------
Warning
---------------------------
This hard drive can't be supported.
---------------------------
OK  
---------------------------

Whoa, what hard drive and why?

Updating motherboard BIOS to the latest F10 version didn’t produce results. At this point I turned to my best friend Google search but found no solutions nor explanations, just a bunch of people with similar problem. Since my friend failed (which is a rare occasion) I even read the instructions that came with motherboard – ISRT has its own booklet. Nothing. I suspected a problem with caching RAID arrays. Thus I quickly thrown in a blank disk as a standalone one thinking that it should le me cache at least this standalone one, restarted and … still nothing.

While poking in BIOS RAID settings I received warning “max number of  arrays created” or something like that. Hm, can it be that caching requires a volume on its own? Next step, since the second RAID array isn’t critical to the boot process I simply detached both Seagate’s and restarted. Booting the system with a single RAID array and a standalone disk finally produced some results. This time the acceleration option magically appeared for the standalone disk but not for the RAID array. But hey, that’s some progress and I was happy to see acceleration option. It is supposed to cache RAID arrays as well, why doesn’t it?

There was one option remaining. I had a suspicion that what was causing the missing caching option was the fact that I had two volumes (RAID 0, RAID 1) on the same array. Next step was elimination of the RAID 0 volume and leaving a single RAID 1 volume on the array (I resized the partitions extremely easily using Acronis Disk Director Suite). Rebooting, crossing fingers, and … a disappointment. Still couldn’t enable caching of the RAID array. However something else was going on at this point. Once during my many reboots I had to force the reboot using the hardware button. As a consequence IRST went into RAID array verification mode – a normal procedure, which takes some time. I just left it do its job and once RAID array was verified – success! The caching option just appeared for the RAID volume out of blue sky. Few more clicks and my boot RAID volume was SSD cached.

Once cache is enabled the system becomes much faster of course, well, the loading from disk is faster. It might be significant or not, depends on your typical work scenario. I don’t often start new programs thus the benefits aren’t stellar in my case but speeding things up doesn’t hurt, eh.

The bottom line

  1. Intel Smart Response Technology user interface is bad beyond explanation (the same goes to IRST). Instead of telling me why it can’t enable caching on a volume the options are just missing. And if it starts doing this right after installation one is left to wonder what’s wrong, where is the problem and whether the thing even works. Much much better approach would be to have acceleration option always present with a clear explanation in the case of the problem.
  2. Intel Smart Response Technology documentation is poor as well.
  3. If it doesn’t work is either because you reached the maximum RAID volume number (4 in my case), because IRST is doing RAID array verification or because there is more than one volume on the array.
  4. Once it works it speeds things considerably up. I am using read-only cache mode at this point (there is maximized mode that features caching writes as well)
  5. It produces near-pure-SSD experience for considerably less price.
  6. The caching algorithm is a black box and cache utilization and other metrics aren’t exposed thus I have no idea what it does and how it does.
  7. SSD might wear off sooner, no idea on this, time will tell.

Hope this will help others venturing into Intel Smart Response Technology. You know, the brave fools Smile

Fuslogvw.exe aka Fusion Log Viewer aka Assembly Binding Log Viewer troubleshooting

What do you do when you have problems with assembly binding? Exceptions don’t tell very much (failed to load for some reason is all you get). You call Fuslogvw.exe to the rescue of course.

But what do you do when Fuslogvw.exe doesn’t work? You delete IE’s temporary internet files. Of course.

You might wonder what do IE’s temporary internet files have to do with fuslogvw? Here is straight from the documentation:

The Fuslogvw.exe (Assembly Binding Log Viewer) uses the Internet Explorer (IE) cache to store its binding log.

And here is the kicker

Due to occasional corruption in the IE cache, the Fuslogvw.exe (Assembly Binding Log Viewer)can sometimes stop showing new binding logs in the viewing window. As a result of this corruption, the .NET binding infrastructure (fusion) cannot write to or read from the binding log. (This issue is not encountered if you use a custom log path.) To fix the corruption and allow fusion to show binding logs again, clear the IE cache by deleting temporary internet files from within the IE Internet Options dialog.

I won’t even start how stupid the decision to use anything from IE for such a core functionality is. Besides fuslogvw will silently do nothing in case of temporary internet files corruption – instead of notifying user of a problem. Excellent and very friendly behaviour.

Anyway, clear temporary files and run fuslogvw under Administration privileges and it should work. If it still doesn’t then block a few people on Twitter, check privacy settings on Facebook and uninstall Chrome. It can’t fail!

FindViewById<> CodeRush template

Here is an useful CodeRush editor template if you work with Mono For Android.

FindViewById<«FieldStart»«Caret»«FieldEnd»>(Resource.Id.«FieldStart»«FieldEnd»);«Target()»

I use string fv as trigger. That makes binding variables/fields to Views a bit faster and with less typing.

Example, I’d type

someView = fv

then I’d press SPACE and I’d get an extended template

someView = FindViewById<|>(Resource.Id.|);|

Then I have to type just TextView, ENTER, someView, ENTER, ENTER and I’d get

someView = FindViewById<TextView>(Resource.Id.someView);| <- this is cursor

So instead of typing the whole enchillada I had to type only the letters in yellow.

someView = fvSPACEFindViewById<TextView>(Resource.Id.someView);

With Android these statements are quite common and thus the fv template spares me a lot of typing.

But hey it can get better. If stick to a naming convetion that variable name is the same as Id name + View suffix I can enhance the template, I will name it fvx.

«FieldStart(Name)»«Caret»«Link(viewName)»«BlockAnchor»«FieldEnd»View = FindViewById<«FieldStart»«FieldEnd»>(Resource.Id.«FieldStart»«Link(viewName)»«FieldEnd»);«Target()»

Note the «Link» directive that copies the typed text. And the typing result is

fvxSPACEsomeView = FindViewById<TextView>(Resource.Id.some);

Even better now, eh. The only further improvement is to deduce the variable type and type in TextView automatically. I have to investigate this option to refine the template even further.

You can use the two templates by simply creating them in CodeRush (DevExpress/Options/Editor/Selections/Templates) or you can import them (see attached file) into templates – right click in templates list and select Import Templates…

 

CSharp_Righthand_MonoForAndroid.xml (10.42 kb)

Writing to SD card and notifying outside world of changes

When writing a logging part of an application (Mono For Android/Visual Studio) I got some, seemingly, weird Android behaviour. Since my application transmits large strings over the net I wanted to have a history of these so I can check them out. I could do it with a simple string visualizer but the thing is that Mono For Android isn’t supporting any visualizer in Visual Studio at all – they are just not there. So I’ve decided to write those strings to a SD card in a folder accessible to Windows Explorer. Which is a better option anyway, as I could manipulate those later.

Here is the (simplified) code I use to write these to SD card

string path = Path.Combine(Context.GetExternalFilesDir(null), "file.txt");
File.WriteAllText(path, "large text here");

And I get a nice file in /Android/data/[package]/files. That’s all fine. However, Windows Explorer is unaware of newly created file at all. The file is there it just doesn’t see it. Looks like the problem is that Android (tested on two devices) doesn’t notify the outside world about the file system changes. Instead one has to do it manually. But how? AFAIK it can’t be done from within Windows Explorer.

After some googling I’ve found this stackoverflow thread. I’ve ported the MediaScannerConnection solution to C#.

public class SingleMediaScanner : Java.Lang.Object, MediaScannerConnection.IMediaScannerConnectionClient
{
    private MediaScannerConnection connection;
    private string file;

    public SingleMediaScanner(Context context, string file)
    {
        connection = new MediaScannerConnection(context, this);
        this.file = file;
    }

    public void Connect()
    {
        connection.Connect();
    }

    public void OnMediaScannerConnected()
    {
        connection.ScanFile(file, null);
    }

    public void OnScanCompleted(string path, Android.Net.Uri uri)
    {
        connection.Disconnect();
    }

    protected override void Dispose(bool disposing)
    {
        if (disposing)
            connection.Dispose();
        base.Dispose(disposing);
    }

    public static void NotifyFile(Context context, string file)
    {
        SingleMediaScanner scanner = new SingleMediaScanner(context, file);
        scanner.Connect();
    }
}

One would call SingleMediaScanner.NotifyFile(Context, “FILEPATH”) to let the outside world of the changes to the file.

Not sure whether this is the best of even correct solution but it gets the job done.