Today I had to write some code that would detect the Emulator we use to test WP7 Silverlight applications. For some reason though I had a really hard time finding the answer. Therefore I decided to post the solution here and to link the thread I finally did find which helped me find figure it out, which is this thread here.
Solution:
string DeviceTypeDetected = string.Empty;
switch (Microsoft.Devices.Environment.DeviceType)
{
case Microsoft.Devices.DeviceType.Device:
DeviceTypeDetected = "Real Device Detected!";
break;
case Microsoft.Devices.DeviceType.Emulator:
DeviceTypeDetected = "Emulator Detected :(";
break;
}

In this episode, guest host Andrew Brust is back again, joining Dmitry & I to talk about all of the tech news from Microsoft’s Wordwide Partner Conference in Washington, DC. The trio talks about WebMatrix, Internet Explorer 9 Preview 3, Windows Phone 7, and the newly announced Windows Azure Appliance.
A raging Dmitry also shares his poppin’ passion for HTML5.
Today I was working with RowVersions (aka TimeStamp, aka binary(8)) and tried to update a table with a value I had retrieved and stored by doing select @@DTBS
My stored notepad value was ‘0x0000000027A3CC07’ so I had run a query to update a table with it, but it didn’t work, the set value was different (‘0x3078303030303030’).
Being puzzled I tried a few queries and all of them returned this unexpected result which explained why my update set the wrong value, examples:
Queries
select CONVERT(rowversion, '0x0000000027A3CC07')
select CONVERT(timestamp, '0x0000000027A3CC07')
select CONVERT(binary(8), '0x0000000027A3CC07')
The above returned a result that did not match the RowVersion im passing in, causing me a lot of pain
Result:

Solution
I asked some of my MSFT colleagues and they pointed out the basic mistake I was making, remove the quotes! This value is not a string, it’s a hex.
Example of a good query:
select CONVERT(rowversion, 0x0000000027A3CC07)
This will return the same exact value as the one I passed in. As you can see, CONVERT (and cast) does not convert properly if you pass in a string for this datatype, instead remove the single quotes and you’re all set.
Today I started Bitlocker (Windows 7 x64 bit OS) on an external drive but noticed something, the normal UI notification in the system tray that shows the progress indicator was missing. A bug? Perhaps.
When BitLocker starts it takes up the majority of the drive space to do the encryption, so to me it was clear the encryption was in progress but I couldn’t figure out how far along it was without the UI element.
Example: How I suspected encryption was still in progress (big red bar)
![image[4] image[4]](http://www.lyalin.com/Blog/images/www_lyalin_com/Blog/WindowsLiveWriter/BitlockerMissingUInotification_A31B/image4_thumb.png)
To try and figure out what’s going on I reached out to my colleagues and was given a suggestion, “start the command prompt in administrator mode and run ‘manage-bde.exe –status’ command to see the status of encryption. Sure enough it provided me both the ‘conversion status’ and ‘percentage encrypted’ as shown below:

So if you’re ever stuck not being sure if Bitlocker is encrypting or how far along it is simply run the command above for the answer. Hope this helps someone!
In this episode, guest Garrett Serack from the Microsoft Open Source Technology Center joins me to discuss CoApp, a new package manager for the Windows platform. Garrett tells us how CoApp will help make it easier for developers and users to build and install open source software on Windows.
(Interview starts at 34:15)
Also, Dmitry and I rap about Windows Phone 7, WCF, Outlook PST files, Visual Studio 2010 Power Tools, and IQueryable killing his cat.
CLICK HERE TO LISTEN!
Today I put together some notes around what the main differences are between a Silverlight 4 application running in-browser Vs. out-of-browser (OOB) with elevated trust enabled (elevated trust is new in SL4). After compiling them i realized it would make a good reference blog post, so here it is:
| | SL 4 (in-browser) | SL 4 (OOB + Elevated trust) |
| Summary | Runs in a limited security and feature context, but provides the least requirements on the user in terms of: · What security rights they have to install and promote applications (which is often an issue in the corporate world) · Auto updating (no re-start required) | Runs out-of-Brower and in elevated trust environment providing for the most features and capabilities to interact with web services and local computer resources (Elevated trust is separate from OOB and must be requested via options when configuring your application) |
| Feature: Web Browser | N/A (Third party components do exist to render HTML in SL even when web browser isn’t available, example: HtmlHost from ComponentOne | Available · Display any web-page · Supports plug-ins like Flash (plays back video just fine for example!) · Can display HTML string |
| Feature: COM Objects Interop | N/A | Available (OS dependent) Example: Interop with Excel via COM to create spreadsheet data |
| Features: Auto-updates | Auto updates when the web page loads | You can implement code to auto update and it will be applied on next restart (at least I see no way to do it otherwise) |
| Feature: Full Screen | Requires user interaction | Can go into full screen without user interaction (example: using code to do so at startup) |
| | | |
| Restrictions: Cross-Domain | Requires a clientaccesspolicy.xml or crossdomain.xml file | No restriction, access any URI |
| Restrictions: Access to local files | Via OpenFile / SaveFile Dialog control | No restriction on My Documents, My Pictures, My Music, et Still cannot access any other folders on the computer |
Some additional notes:
If anything above is incorrect please let me know folks, I’d love to improve my own knowledge. In the end which scenario you go after gets down the details and what the developers need to accomplish.
One of my recent fascinations has been with the “Metro” UX concept from Microsoft. This is the user interface concept that is being developed for Windows Phone 7 and often is talked about when describing the idea behind Zune software UX.
In my quest to understand what Metro style applications should look like i’ve collected some good links, so here they are in case you’re also interested. (Have more examples? email me using the Contact link in this blog)
Metro User Interface Related Links:
Screenshots (from links above)




In this episode, guests Kanwaljeet Singla, Don Raman, and Wade Hilmo from the Microsoft IIS team join Peter to discuss the evolution of PHP on the Windows Platform. The IIS folks tell us about the improvements made to Windows in order to support PHP, including: Fast CGI, WinCache, PHP 5.3, the Web PI, and the SQL Server driver for PHP. (Interview starts at 24:31)

Also, Dmitry and Peter rap about Windows Azure, Bing Maps, Expression Studio 4, & some “select developer” news about Windows Phone 7! All in Klingon to boot!
If you’re building a WPF application and are getting an exception “Value does not fall within the expected range” while trying to set the Content property of a ContentControl you might have run into the same scenario I have, let me explain.
Lets assume you have registered a View (xaml UserControl) with your Unity container and you use ‘ContainerControlledLifetimeManager()’ to make it a singleton, you can then Resolve that view and display it inside of a ContentControl’s content property. But be aware, if you attempt to set that control to another ContentControl’s content property you will likely get the “Value does not fall within the expected range” exception.
This has something to do with assigning the same object to two different Visual Tree’s at the same time. I wont claim to be an expert here but at least now you understand what is happening and can resolve it.
I fixed my problem by removing the ContainerControlledLifetimeManager() from my registered component.
(Thanks to Min-Hong Tang from Microsoft who helped lead me in the right direction by posting the Visual tree comment in this thread)


In this episode, the man, the myth, the legend: C# MVP Jon Skeet joins Peter on a whirlwind tour into the bowels of the C# language. Jon talks up lambdas, expression trees, and other C# goodness. Prepare to have your brain tickled! (Interview starts at 31:18)
Also, guest host Andrew Brust joins Peter to rap about phpBB in the Microsoft Web Platform Installer, Office 2010, Windows Phone 7, and HTML5 video.
CLICK HERE TO LISTEN!