May 272008
 

Rob Burke is teaching a WPF training course through Toronto-based consultancy ObjectSharp. The course is called “Windows Presentation Foundation for Developers and Lead Designers,” and, as the title suggests, it offers a hands-on experience designed to give developers and lead designers the knowledge, background, tips and references they’ll need to build smart client applications using the Windows Presentation Foundation.

After enjoying the process of training a team of developers and designers to use WPF, this course is the result of turning that material into a course that we could offer here.

The inaugural course offering is currently scheduled for August 13th-15th. If you’re interested in taking part, please find more information about the course on ObjectSharp’s site. Also, if August 13th is too long for you to wait, or you’re interested in an on-site course, please contact Julie James, ObjectSharp’s Training Manager.

More on Rob Burke.

May 262008
 

What is Pex?

Pex generates test inputs that cover all, or at least many of the corner cases in your .NET code. These test inputs are plugged into parameterized unit test that you write. The result is a small unit test suite, where each unit test calls the parameterized unit test with particular test inputs. There is a great picture on the main Pex page that illustrates this process.

Pex supports other unit test frameworks since the unit tests that Pex generates can be executed by other unit test frameworks without Pex. Pex comes with support for MSTest, the unit test framework of Visual Studio, out of the box. For support for other unit test frameworks, please look at the Pex Extensions project.

Parameterized unit tests have been around for quite some time already, under several names — row tests, data-driven tests, theories, etc.

What is really unique about Pex is that it analyzes your .NET code, instruction by instruction, to understand what your code is doing. Then, in a fully automatic way, Pex computes relevant test inputs that trigger the corner cases of the code. When you write assertions, Pex will try to come up with test inputs that cause an assertion to fail.

Feedback

To ask questions, get help, or just give feedback, please take a look at our mailing lists.

Links

Homepage: http://research.microsoft.com/pex

Download: http://research.microsoft.com/pex/downloads.aspx

Nikolai Tillmann’s Blog: http://blogs.msdn.com/nikolait

Peli de Halleux’s Blog: http://blog.dotnetwiki.org/

May 232008
 

Here’s a very simple QuickSort algorithm from Wikipedia written in a very Functional way of C#. Notice that it looks very close to the pseudo-code algorithm shown in Wikipedia. The pivot used is just sequence.First(). You can replace the pivot by some random position if you wish.

   1:          public static IEnumerable<T> QuickSort<T>(this IEnumerable<T> sequence) where T : IComparable<T>
   2:          {
   3:              return !sequence.Any()
   4:                         ? sequence
   5:                         : ((from x in sequence.Skip(1)
   6:                             where x.CompareTo(sequence.First()) < 0
   7:                             select x)
   8:                               .QuickSort()
   9:                           ).Concat(new[] { sequence.First() }).Concat((from x in sequence.Skip(1)
  10:                                                                        where x.CompareTo(sequence.First()) >= 0
  11:                                                                        select x).QuickSort());
  12:          }

I tried making this more fun by using the Fix Point Generator which I mentioned previously, and converted that code into a Func<IEnumerable<T>> instead. Here’s the code.

   1:          public static Func<T, T> Fix<T>(Func<Func<T, T>, Func<T, T>> F)
   2:          {
   3:              return x => F(Fix(F))(x);
   4:          }
   5:   
   6:          static void Main()
   7:          {
   8:              var quicksort = Fix<IEnumerable<int>>(
   9:                  qsort =>
  10:                  sequence =>
  11:                  !sequence.Any()
  12:                      ? sequence
  13:                      : qsort(from x in sequence.Skip(1)
  14:                              where x.CompareTo(sequence.First()) < 0
  15:                              select x)
  16:                            .Concat(new[] { sequence.First() })
  17:                            .Concat(qsort(from x in sequence.Skip(1)
  18:                                          where x.CompareTo(sequence.First()) >= 0
  19:                                          select x)));
  20:          }

This is a perfect example of how you can use the Fix Point Generator to create your recursive functions on the fly. If you want to make it reusable with an extension method, you can easily convert it to the extension method, or a normal method. Personally I feel that using the Fix Point Generator is more intuitive and slightly more readable as oppose to the extension method way of doing things.

One point to note is that the “Concat” extension only accepts an IEnumerable<T> and not a single item. You can solve this by the above, “new[] { sequence.First() }” which is a cleaner way if you don’t want to write your own extension method (which you could too).

Crazy stuff eh?

May 092008
 

If your bluetooth adapter is a Broadcom Bluetooth 2.0 EDR, like the “ThinkPad Bluetooth with Enhanced Data Rate” or any Broadcom Bluetooth 2.0 EDR type adapter, you can follow the steps below to get bluetooth working on Windows Server 2008.

Required for install:

Vista or WS2008 x86: http://www.toshiba-tro.de/tools/bluetooth/BT-stack.zip
Vista or WS2008 x64: http://www.toshiba-tro.de/tools/bluetooth/BT-stack-64bit.zip

Hex Editor, e.g. WinHex or CodePad
 

1. If you down it, you will install this software. When Toshiba Setup say Plug your BT device, you’ll click to cancel. Install is succesfull.

2. Open Device Manager (Start | Control Panel | Device Manager) or Start | Run… | devmgmt.msc

You find in Other devices – Bluetooth dongle. Get Properties of it. On fold Details you see Property, It scroll to Hardware Ids. In Value Box u see two line, e.g.:

USBVID_0A5C&PID_2101&REV_0100

USBVID_0A5C&PID_2101

You copy second line with short Ids (‘USBVID_0A5C&PID_2101‘)

3. Now you going to folder:
Vista or WS2008 x86: %PROGRAMFILES%ToshibaBluetooth Toshiba StackDriverstosrfusb

Vista or WS2008 x64: %PROGRAMFILES(x86)%ToshibaBluetooth Toshiba StackDriverstosrfusb

Here are files: tosrfusb.cat, tosrfusb.inf, tosrfusb.sys
You need edited *.cat, and *.inf file.

4. Open tosrfusb.inf in Notepad.exe (e.g. Start | Run… | Notepad.exe)

Here you must edited line 161:

%TosrfUsb.DeviceDesc97%=TosrfUsb_Device,  USBVID_0C24&PID_000F

and line 288:

%TosrfUsb.DeviceDesc97%=TosrfUsb_Device,  USBVID_0C24&PID_000F

You edit this lines to:

%TosrfUsb.DeviceDesc97%=TosrfUsb_Device,  USBVID_0A5C&PID_2101

And save as tosrfusb.inf (replace original file).

5. Open tosrfusb.cat in Hex Editor (e.g. WinHex, CodePad).

Ctrl+F.. You need line of characters (but not find this data as text value!):

4800570049004400390037020410010001042C7500730062005C007600690064005F00300063003200340026007000690064005F0030003000300035

or

H.W.I.D.9.7…….,u.s.b..v.i.d._.0.c.2.4.&.p.i.d._.0.0.0.5

or

HWID97   ,usbvid_0c24&pid_0005

There you must change value help by ASCI table, e.g.:

4800570049004400390037020410010001042C7500730062005C007600690064005F00300041003500430026007000690064005F0032003100300031

or

H.W.I.D.9.7…….,u.s.b..v.i.d._.0.A.5.C.&.p.i.d._.2.1.0.1

or

HWID97   ,usbvid_0A5C&pid_2101

And save as tosrfusb.cat (replace original file).

6. Now you can install your BT.

Vista or WS2008 x86: %PROGRAMFILES%ToshibaBluetooth Toshiba StackECCenter.exe

Vista or WS2008 x64: %PROGRAMFILES(x86)%ToshibaBluetooth Toshiba StackECCenter.exe

You must Ignore install not sign drivers and all is Okay.

[Source: MSDN Forums]

May 032008
 

If anyone tried to install WMP plugin for Firefox on Windows Server 2008 (or any server os), they will get an error stating that server os are not supported. In order to get it working, you need to do the following steps.

  1. Rename wmpfirefoxplugin.exe to wmpfirefoxplugin.zip.
  2. Extract it into a directory.
  3. Type the following command in a console:
    msiexec /a ffplugin.msi
  4. It will install it probably in C:
  5. Copy this file, np-mswmp.dll, into your plugins directory of Firefox (usually C:Program FilesMozilla Firefoxplugins)

Restart Firefox and it should work.