Category Archives: Windows 8

101 Questions and Answers About Windows 8

1. What tools and information do I need to develop Windows 8 Store applications?

a. Windows 8 – Download free version here

b. Visual Studio 2012 Express - Download free version here

c. Windows Phone - Download free version here

d. Windows Server 2012 – Download free version here (Optional)

e. Microsoft Virtual Academy – Register here

2. How to develop a Windows Phone 8 app in 30 days?

Register at
http://www.microsoft.com/click/services/Redirect2.ashx?CR_CC=200134727

3. For a Mac user, where can I get the free tools to build Windows Store apps for Windows 8?

Install Windows 8 and the dev tools on your Mac.

4. How to start planning now for a cloud-based backend service—user authentication, push notifications, and structured data?

Sign up for the Windows Azure 90-day Free Trial and receive 10 free Mobile Services running on shared instances.

5. Get the samples and get started!? Download the design assets—PSD assets include templates, common controls, and common components—and the sample apps pack.

6. Where to find Windows 8 Sessions and Keynotes — //BUILD Conference Site

7. Download the Bits — Windows Dev Center

8. PDF Manual — Windows Developer Preview Guide

9. Code Examples — MSDN “Metro Style” app examples (or get them all together in a Single ZIP)

10. What Devices will Run It? — List of Devices in Microsoft’s Test Lab

11. How to Install on My Machine without Losing Everything even if I don’t have Dual-Format DVDs or 8 GB Memory Sticks Handy — Installing Windows 8 Developer Preview as a Bootable VHD

12. What About Silver light? — It’s still here, with a diagram from Microsoft to prove it

13. Chat about Windows 8 or Cry for Help — MSDN Forums for Windows 8

14. What is WinRT? — Introduction to WinRT and WinRT demystified

15. Touch Input — Quickstart: Touch Input

16. Comfort Guide to Controls for Silverlight and WPF Developers — Controls List (for Xaml)

17. How do I Convert Silverlight to WinRT/Metro? — Blog Series on WinRT vs. Silverlight

18. But is Xaml REALLY There? — Yes, It Is

19. The New Architecture — Windows 8 WinRT Capabilities (Tip: Lean forward to make it look flat)

20. Platform and Tools Architecture — Windows 8 Platform and Tools (Tip: this time lean sideways)

21. Can I Borrow Someone’s Opinion? — Sure thing: Yours Truly, Michael Crump, Engadget, Wired

22. Create a bootable USB? jerrynixon.com

23. Setup boot to VHD? jerrynixon.com

24. Get an Azure account?
http://aka.ms/w8cloud

25. Get Windows 8?
http://aka.ms/w8download

26. Get Visual Studio 2012?
http://aka.ms/w8tools

27. Get Windows Live SDK?
http://aka.ms/w8live

28. Get Windows 8 Samples?
http://aka.ms/w8samples

29. Get Multilingual Toolkit?
http://aka.ms/w8language

30. Get Advertising SDK?
http://aka.ms/w8ads

31. Get Design Assets?
http://aka.ms/w8design

32. Register your App?
http://aka.ms/w8reg

33. Join 30 to Launch?
http://aka.ms/w8launch

34. View the online labs?
http://aka.ms/w8vlabs

35. Does Windows 8 run Windows 7 software? Yes

36. Does Windows 8 support .Net 4.0? Yes

37. Does WinRT replace the .Net framework? No

38. Can users re-enable the start button in Windows 8? No

39. Can enterprises disable Microsoft Design Style on their Windows 8 desktops? No

40. Will Microsoft Design Style be part of the server version of Windows? Yes

41. Do developers need two apps in the Windows 8 store to support ARM? No

42. Can apps have a hidden URL in the Windows 8 store? No

43. What is the revenue split with Microsoft for the Store? 80/20

44. Do developers need a developer account in order publish an app? Yes

45. Can developers use payment systems other than Microsoft? Yes

46. Is HTML5 and JavaScript (JS) supported in Microsoft Design Style development? Yes

47. What is the HTML rendering engine in HTML-based Microsoft Design Style apps? IE10

48. Is IE10 Microsoft Design Style the same engine as IE10 desktop? Yes

49. Can desktop applications create live tiles? No

50. Can desktop applications use WinRT? Yes

51. Can desktop HTTP end point be accessed by Microsoft Design Style apps? No

52. Can Microsoft Design Style applications access a local SQL server? No

53. Do Microsoft Design Style applications have a local database solution? Yes, Sqlite

54. Can Microsoft Design Style applications access the internet while the pc is in standby? Yes

55. Can Microsoft Design Style applications access SkyDrive? Yes

56. Can Microsoft Design Style applications iterate through the user’s hard drive? No

57. Is there a Microsoft Design Style version of windows file explorer? No, see above

58. Can Microsoft Design Style applications detect other Microsoft Design Style apps? No

59. Can more than one Microsoft Design Style application run at one time? Yes, two

60. Can push notifications execute client code? No

61. Are there background tasks in Microsoft Design Style? Yes

62. Is the performance of HTML5 Microsoft Design Style applications comparable to XAML? Yes

63. Is native code (C++) supported in Microsoft Design Style development? Yes

64. Is Microsoft Design Style C different than traditional CPP? Yes

65. Should all desktop apps be migrate to Microsoft Design Style? No

66. Will the Windows 8 store support trials? Yes

67. Will the Windows 8 store support subscriptions? No

68. Will enterprise apps deliver through the Windows 8 store? No

69. Can enterprises disable the Windows 8 store? Yes

70. Can enterprises disable side-loading of apps? Yes

71. Can apps in the Windows 8 store access desktop apps & services? No

72. Can side-loaded apps access desktop apps & services? Yes

73. Can parents disable the Windows 8 store for kids? Yes

74. Can parents limit the hours in the day their kids can log in? Yes

75. Can parents limit the cumulative time in a day kids can use the PC? Yes

76. Can parents filter available web sites? Yes

77. Can parents disable games based on their rating? Yes

78. Can Visual Studio 2010 be used to build Microsoft Design Style apps? No

79. Can Visual Studio 2012 be used to build Windows 7 apps? Yes

80. Can Visual Studio 2010 access Team Foundation Server 2012? Yes

81. Can Visual Studio 2012 open 2010 projects without altering them? Yes

82. Can Visual Studio 2010 open 2012 projects? No

83. Does the .Net 4 async keyword work in WinRT? Yes

84. Does Windows 8 WinRT code run on Windows Phone 7? No

85. Does Windows Phone 7 code run on Windows 8? Yes, some

86. Does Windows Phone 8 code run on Windows 8? Yes, more

87. Does Windows 8 code run on Windows Phone 7? Yes, some

88. Does Windows 8 code run on Windows Phone 8? Yes, more

89. Can Microsoft Design Style applications roam settings/files across desktops? Yes

90. Can desktop applications roam settings, too? No

91. Can Microsoft Design Style applications roam settings/files to Windows Phone? No

92. Can Windows Phone roam settings to Windows 8? No

93. Does Windows 8 Microsoft Design Style support XNA game development? No

94. When was Windows 8 released? Friday, October 26, 2012.

95. Win+E – Explorer

96. Win+R – Run

97. Win+D – Desktop

98. Win+Plus or Win+Minus (no shift) – Magnifier/Zoom In and Out

99. Win+F – Find Files

100. Alt-Tab – Switch between Apps

101. Win-Tab – Switch between Full Screen Apps

    Free Microsoft Developer Training Kits

    Windows Azure Training Kit – August 2012 REFRESH Update

    The August 2012 REFRESH update of the Windows Azure Training Kit includes 42 hands-on labs, 15 demos and 38 presentations. Some of the updates in this version include:

    • Added the Windows Azure Device + Services 1-day event agenda
    • Added the Windows Azure ITProCamp 1-day event agenda
    • Added 2 presentations designed for Windows Azure Mobile Services
    • Added 15 Demos with Demo Scripts for content delivery

    The previous August 2012 update of the Windows Azure Training Kit includes 41 hands-on labs and 35 presentations. Some of the updates in the version include:

    • Added 7 presentations specifically designed for the Windows Azure DevCamps
    • Added 4 presentations for Windows Azure SQL Database, SQL Federation, Reporting, and Data Sync
    • Added presentation on Security & Identity
    • Added presentation on Building Scalable, Global, and Highly Available Web Apps
    • Several hands-on lab bug fixes
    • Added the Windows Azure DevCamp 1-day event agenda
    • Updated Windows Azure Foundation Training Workshop 3-day event agenda

    Release date: 8/20/2012

    Internet Explorer 10 Training Kit

    This training kit covers development specifics for developers who will be targeting Internet Explorer 10 in their development experience. This kit contains documentation and details on things pertinent to developing applications that target features of the Internet Explorer 10 browser.

    Release Date: 8/8/2012

    Windows 8 Camp in a Box, Release Preview Edition

    This download includes the hands-on-labs, presentations, samples and resources from the Windows 8 camps for developers ramping up on Metro style app development.

    • Windows 8CampinaBoxJS includes the hands-on labs for those using HTML + Javascript.
    • Windows8CampinaBoxCS includes the hands-on-labs that use XAML + C#.

    Release Date: 7/18/2012

    SQL Server 2012 Developer Training Kit

    The SQL Server 2012 Developer Training Kit includes technical content designed to help you learn how to develop SQL Server 2012 database and BI solutions.

    Release date: 7/16/2012

    Identity Developer Training Kit

    The Identity Developer Training Kit contains hands-on labs, presentations and pointers to training videos. This page contains three versions of the Identity Developer Training Kit :

    • Identity Developer Training Kit (July 2012) for Visual Studio 2012 RC
    • Identity Developer Training Kit (April 2011) for Visual Studio 2010 RTM
    • Identity Developer Training Kit (March 2010) for Visual Studio 2008 SP1

    Release Date: 7/5/2012

    Web Camps Training Kit

    Web Camps Training Kit May 2012 Release featuring ASP.NET MVC 4, ASP.NET 4.5, ASP.NET Web API, VS 11

    Release Date: 5/9/2012

    Visual Studio 2010 and .NET Framework 4 Training Kit

    Visual Studio 2010 and .NET Framework 4 Training Kit December 2011 Release

    Release date: 12/30/2011

    Windows Phone 7.5 Training Kit

    Hands on Labs for the Windows Phone 7.5 Application Platform

    Release date: 12/19/2011

    Visual Studio 11 Developer Preview Training Kit

    Visual Studio 11 Developer Preview Training Kit December 2011 Release

    Release date: 12/15/2011

    Dynamics CRM 2011 Developer Training Kit

    This training kit is for .NET developers to learn the development features of Dynamics CRM and help them build applications using Microsoft Dynamics CRM 2011 and CRM Online.

    Release Date:9/6/2011

    Introduction to Visual Studio Team Foundation Server 2010 Training Kit

    Introduction to Team Foundation Server 2010

    Release Date:8/22/2011

    BizTalk Server 2010 Administrator Training Kit

    This training kit contains a complete set of materials that will enable you to learn the core administrator capabilities in BizTalk Server 2010. This kit includes lab manuals, PowerPoint presentations and videos, all designed to help you learn…

    Release Date:8/21/2011

    BizTalk Server 2010 ESB Training Kit

    This training kit contains a complete set of materials that will enable you to learn about the ESB Toolkit in BizTalk Server 2010. This kit includes lab manuals, PowerPoint presentations and videos, all designed to help you learn about the ESB…

    Release Date:8/20/2011

    Visual Studio LightSwitch Training Kit

    Visual Studio LightSwitch Training Kit

    Release Date:7/28/2011

    SharePoint 2010 and Windows Phone 7 Training Kit

    Provides developers with advanced guidance on how to develop Windows Phone 7 Applications for SharePoint.

    Release Date:7/22/2011

    BizTalk Server 2010 Developer Training Kit

    This training kit contains a complete set of materials that will…developer capabilities in BizTalk Server 2010. This kit includes lab manuals, PowerPoint presentations…Virtual Machine that is ready for you to use with the training kit.

    Release Date:7/18/2011

    SharePoint and Windows Azure Development Kit

    The July 2011 release of the SharePoint and Azure Development Kit is a training course to help developers integrate SharePoint and Windows Azure.

    Release Date:7/15/2011

    Office 365 Developer Training Kit – June 2011 Update

    Guidance that provides developers with advanced guidance on how to develop for Office 365 including SharePoint Online, Exchange Online and Lync Online

    Release Date:6/28/2011

    Office 2010 Developer Training Kit – June 2011

    Training kit that provides developers with collateral to get started quickly developing for Office 2010.

    Release Date:6/7/2011

    PHP on Windows and SQL Server Training Kit (March 2011 Update)

    The PHP on Windows and SQL Server Training Kit includes a comprehensive set of technical content including demos and hands-on labs to help you understand how to build PHP applications using Windows, IIS 7.5 and SQL Server 2008 R2.

    Release Date:6/6/2011

    SQL Server 2008 R2 Update for Developers Training Kit (May 2011 Update)

    This training kit is a great resource for developers, trainers, consultants and evangelists who need to understand…hands-on labs and videos that are perfect for self-paced learning or for conducting your own training.

    Release Date:6/2/2011

    SharePoint and Silverlight Training Kit

    Provides developers with advanced guidance on how to develop Silverlight Applications for SharePoint.

    Release Date:4/7/2011

    Web Camps Training Kit

    February 2011 release of the Web Camps Training Kit

    Release Date:2/21/2011

    Windows Phone 7 Training Kit for Developers – RTM Refresh

    This Windows Phone 7 Training Kit for developers will give you a jumpstart into the new Windows Phone world by providing you with a step-by-step explanation of the tools to use and some key concepts for programming Windows Phones.

    Release Date:2/3/2011

    Silverlight 4 Training

    Silverlight 4 Training

    Release Date:12/20/2010

    UC “14″ Developer Training Kit

    This training kit provides deep technical training on all aspects of the Lync Server 2010 and Exchange Server 2010 SDKs to give developers the skills they need to be productive developing communications driven business processes.

    Release Date:12/10/2010

    Windows Server AppFabric Training Kit

    This training kit contains a complete set of materials that will…capabilities in Windows Server AppFabric. The kit has two main sections, one for the AppFabric Hosting…Virtual Machine that is ready for you to use with the training kit.

    Release Date:10/26/2010

    What’s New in BizTalk Server 2010 Training Kit

    Learn about the new features of BizTalk Server 2010

    Release Date:9/23/2010

    SharePoint 2010 Developer Training Kit

    Guidance that provides developers with advanced guidance on how to develop for SharePoint.

    Release Date:5/8/2010

    Windows 7 Training Kit For Developers

    The Windows 7 Training Kit for Developers includes presentations, hands-on labs, and demos designed to help you learn how to build applications that are compatible with and shine on Windows 7

    Release Date:10/22/2009

    Windows Server 2008 R2 Developer Training Kit – July 2009

    A collection of presentations, demos, and hands-on-labs for Windows Server solution developers.

    Release Date:7/20/2009

    ASP.NET MVC Training Kit

    ASP.NET MVC Training Kit containing: hands-on-labs, demos, decks, FAQs, etc.

    Release Date:3/27/2009

    Business Activity Monitoring (BAM) Training Kit

    This training kit provides learning information for Business Activity Monitoring (BAM).

    Release Date:8/21/2008

    .NET Framework 3.5 Enhancements Training Kit

    .NET Framework 3.5 Enhancements Training Kit containing Labs, Demos and PPTs

    Release Date:8/11/2008

    Visual Studio 2008 and .NET Framework 3.5 Training Kit

    Visual Studio 2008 and .NET Framework 3.5 Training Kit containing Labs, Demos and PPTs

    Release Date:11/30/2007

    First Impressions of Intel Next Generation Ultrabook™ with Windows 8

    Few days ago I received an Ultrabook from Intel as part of winning the Round 1 of Windows 8 & Ultrabook™ App Innovation Contest as shown in figure 1.

    IMG_0561

    Fig 1: Ultrabook box

    Intel sent me an Ivy Bridge Ultrabook as shown in Figure 2 to review. This Ultrabook from Intel will never be a production hardware – This laptop will never be made. It’s meant to be a reference example for hardware makers to make Ultrabooks of their own. This particular device will not be made available for purchase. So It’s just a proof of concept from Intel. The only manufacturer branding on it is Intel’s Ultrabook TM, as you can see from Fig 2.

    IMG_0600

    Fig 2: Picture of Intel’s concept Ultrabook (Nice to see Intel logo on the cover)

    IMG_0601

    Fig 3: Nice touch screen  (Intel Logo on the Ultrabook)

    IMG_0577

    Fig 4: Ultrabook next to my existing laptops at home.

    Following are my initial observations of the new “on the road laptop.”

    Sensors that are present in the Ultrabook

    • 5 point multi-touch screen
    • Accelerometer
    • Magnetometer
    • Gyroscope
    • Ambient light sensor
    • GPS
    • NFC (Near Field Communication)
    • Bluetooth 4.0
    • WiFi (b/g/n)

    sensors

    Fig 5: Sensors present in Ultrabook.

    Physical Factors First:
    • High Definition Web Cam
    • Slot for SDHC card
    • Slot for SIM Card (Yes, you can out the phone SIM card in this Ultrabook)
    • Two USB-3  slots on either side
    • Mini-HDMI connector
    • Headphone jack
    • Power Connector
    • Weighs 3.5 pounds (Very very  light compared to other laptops)
    • Great built-in audio
    Performance Factors:
    • Intel Core i7 CPU @ 2.0 GHz (Windows 8 shuts down in 2 seconds)
    • 180 GB Solid State Hard Drive
    • 4GB RAM

    The laptop came with Windows 8 Pro which I immediately activated through MSDN and the computer was ready to go with zero adware. There was also included a 16GB thumb drive with all the drivers and everything it takes to return the machine to factory conditions which was very nice. Responsiveness and speed is amazing. The computer itself feels substantial and has a very beautiful “rubberized” top. It just looks sharp, closed or open. I read on some posts about fan being loud, but the ultra book i received is as silent as thought.

    Hardware and Physical Form Factor

    The Ultrabook is really thin, light, powerful, fast and run Windows 8. The book weighs in at about 3.5 pounds. On the outside it’s got 1.5MP web-cam camera, a 5-point touch screen, a mini HDMI connector port, a pair of USB 3.0 ports on either side, an HD webcam,  a headphone jack, power connector slot and a 13.3” multi-touch display. Inside, it has Intel Core i7-3667U processor (4M cache, 2.00 GHZ) which is one of the new Ivy Bridge processors, 4 GB of DDR3L RAM, a 180 GB SSD hard drive, and the following specifications (to name just a few):

    • 802.11 b/g/n WiFi
    • Bluetooth
    • NFC
    • Multi-Touch Pad
    • Sensors
    Activating Windows 8:

    The machine came with the Windows 8 Pro (64 bit) pre-installed. Now that Windows 8 is released to manufacturing (RTM) and available to MSDN subscribers, I was able to successfully activate Windows 8 Pro through the license key obtained from my MSDN account .

    TouchScreen & Sensors:

    My prediction is that Touch screen is going to be the default feature like USB port in every laptop within a couple of years. A touch screen on a laptop? Why? What kind of madness is this? After using it for a while having a touch screen is a nice to have. I believe that in two to three years from now, all display devices will be touch enabled like monitors in office and laptops. Swipe in from the right to get the charms menu, in from the left to task switch and down from the top for menus and browser tabs. This is such a clean and clear extension of the “touch” experience that if I were in charge of the Windows hardware ecosystem I would require it. Pinch to zoom works as well, just as it should. I found myself using the touch screen more than I expected to. I don’t much like taking my hands off the keyboard, but once I do, the multi-touch screen is a lot more physically intuitive than a mouse, even though I have been using mice for over 20 years. It is, in any case, much more satisfying.

    Most new tablets and Ultrabooks running Windows 8 are going to have a slew of sensors. Here are the sensors and other advanced features included in this proof of concept device:

    • GPS (Location Sensors)
    • NFC
    • Multi-Touch (display and touchpad)
    • Accelerometer ( acceleration along 3 axes)
    • Compass (orientation and position)
    • Gyro meter (angular velocity)
    • Inclinometer (angle of incline)
    • Light Sensor (ambient lighting)
    • Orientation Sensor (combines accelerometer, compass, gyro meter to get more sensitive movement)
    • Simple Orientation (orientation of the device including face up or down)

    Detecting Sensors on an Ultrabook: There are a few ways in which to determine if a system supports the sensors, and if so, which sensors:

    • Computer Management/Device Manager: Find the Computer Management App on the Windows UI Start Menu (if it isn’t there you can view “All Apps” by right-clicking in the window and then click on the “All Apps” icon in the lower right-hand side of the window. Once the Device Manager is up, look for “Sensors” in the device tree as shown in Figure 6.

     sensorsmmc

    Fig 6: Sensors and Proximity devices in Device Manager.

    • Sensor Diagnostic Tool: If you want to get finer detail regarding each sensor and possibly even have some control over some of the sensor parameters (for testing purposes) you can run the Sensor Diagnostic Tool – it is part of the Windows Driver Kit ( WDK). The Sensor Diagnostic tool uses the Sensor and Location API for data retrieval, event handling, report intervals, changing sensitivity, and property retrieval. The tool can also be used to write the sensor data to a CSV file. I should note, however that the Sensor Diagnostic Tool really exists to aid with the development of Windows Drivers; its true use is to help with the testing and optimization of Windows Drivers. This tool can be found in the following folder once you have installed the Windows Driver Kit: C:\Program Files (x86)\Windows Kits\8.0\Tools\x86\Sesnsordiagnotictool as shown in Figure 7.

    path

    Fig 7: Sensor Diagnostic Tool (sensordiagnostictool.exe)

    Figure 8 shows the Sensor Diagnostic Tool that comes with the WDK talking to this Ivy Bridge Ultrabook’s sensors:

    Untitled

    Fig 8: Sensor Diagnostic Tool run on an Ivy Bridge Software Development Platform + USB Sensor Hub

    The following table shown in Figure 9 provides information about the new sensors that are recommended for the Ultrabook (and required for convertibles). It will be up to the OEMs which sensors are included for their specific models/usages.

    sensortable1

    Fig 9: Sensor information table.

     

    Performance Speed & Software Development:

    This feels like a high performance machine in a small package, and an interesting middle ground between a slate and a laptop. 

    • Loads Visual Studio 2012 in about 2 seconds (amazing speed) and builds of average-sized projects are also just 6 seconds on my stopwatch. Not bad at all.
    • System shuts down in 3 seconds
    • How about a reboot of the system:
      • 3 second to the windows lock screen
      • another 2 seconds to login to windows. So in total 5 seconds you can logon to Windows8 from cold start. This a machine I can use to develop, test and write about Windows 8 code. All in all, this machine is clearly a contender.  More to come in a subsequent review once I’ve lived with it for a while.
    • Processor i7 at 2.49GHz – It’s a physical Dual Core with Hyper threading so that’s 4 logical processors as shown in Figure 10.

    jj 

    Fig 10: Task manager showing 4 logical processor information

    Conclusion

    I could develop real serious applications on an Ultrabook and i see it as the future of today’s laptops. It pains me to say it as I have been carrying around 10lb laptops in the name of power for over a decade. In the coming days, I will publish more information around how Windows 8 developers can use this type of device to develop Windows 8 Modern UI style apps.

    Disclosure of Material Connection: I received one or more of the products or services mentioned above for free in the hope that I would mention it on my blog. Regardless, I only recommend products or services I use personally and believe my readers will enjoy. I am disclosing this in accordance with the Federal Trade Commission’s 16 CFR, Part 255: “Guides Concerning the Use of Endorsements and Testimonials in Advertising.”

    25 Reasons to develop Microsoft Design Style Apps in C#/XAML

    Windows 8 introduces Microsoft Design Style as a new a development paradigm on the Microsoft platform. Windows store apps can be developed using .NET/XAML, C++/XAML or HTML5/Java Script technologies. Now, the tricky question is “which technology should people choose to develop Windows store apps?”. For me, I chose C#/XAML. Here I wanted to walk through some of the key reasons for the choice of technology. Also,  as a Windows Store App developer, there are some things XAML developers should know that will save them serious time.

    1. Easy to find .NET developers

    It’s easy to find .NET developers for development and maintenance of Windows Store Apps. Also, Windows 8 provides no-compromise options to developers to choose JavaScript/HTML5, C#/XAML, and C++/XAML without giving up on features and support. But i would choose C++ if i am developing an application that has to perform at the highest level with good memory management.

    2. Bind to Anything

    The power of XAML really starts at its native ability to data bind. Nothing data binds like XAML – one way, two way, one time, and to almost any property. Not only is it built-in, not only is it powerful, not only is it fast, but it’s simple. Check out this snippet:

    image

    In the code above, I am binding the Text property of of the TextBox to the Value property of the Slider. All of the event listening and value conversion is done for me. I just write it up with a syntax that is easy to understand (although you have to get it correct).

    3. Resolution Independence

    XAML has always had resolution independency. And, here’s what it means. Let’s say you have a 17 inch monitor with 1024×768 resolution. The XAML app looks perfect. You upgrade to the same size (17 inches) but higher pixel density (1680×1050). What happens to your app? Because of XAML’s resolution independency, it looks completely the same – just clearer, sharper.

    Hh465362.ux_scaling(en-us,WIN.10).png

    Resolution dependency would have caused the application to get smaller. But we don’t buy high resolution to get application thumbnails. We get high resolution so applications are crisp and clear. Size values in XAML are not pixels, they are device-independent units.

    4. Dependency Properties

    A XAML UI could have a hundred controls, easily – especially in the visual tree. XAML controls could have a hundred properties, easily – especially with attached properties. 100×100 is 10,000 properties. That’s a lot, huh? Fortunately, XAML solves this with Dependency Properties.

    Dependency Properties can be inherited from parent controls. They can be attached by outside assemblies. They can be animated and automated. Plus they fire change events. But, even better is – they take up no memory until they are actually set. Brilliant.

    MSDN: The purpose of dependency properties is to provide a way to compute the value of a property based on the value of other inputs. These other inputs might include system properties such as themes and user preference, just-in-time property determination mechanisms such as data binding and animations/storyboards, multiple-use templates such as resources and styles, or values known through parent-child relationships with other elements in the element tree. In addition, a dependency property can be implemented to provide self-contained validation, default values, callbacks that monitor changes to other properties, and a system that can coerce property values based on potentially runtime information. Derived classes can also change some specific characteristics of an existing property by overriding dependency property metadata, rather than overriding the actual implementation of existing properties or creating new properties.

    5. Platform Adoption

    Name a Microsoft platform. Xbox? Windows Phone? Windows Embedded? Windows Desktop? Windows Microsoft Design Style? Silverlight? Every one has something in common: XAML. Some platforms support other UI technologies, but XAML is the common denominator.

    XAML has a strategic value to developers and enterprises alike because the developed skillset is reusable across the Microsoft stack. From WPF to Silverlight to Microsoft Design Style, XAML is pervasive. One reason XAML is great is because of its wide platform adoption.

    6. Object Oriented Programming

    HTML5 and JavaScript are powerful. Granted. But unit testing, inheritance, polymorphism, architectural reuse, and pervasive design patters are enabled by object oriented languages like C++, C#, and Visual Basic. If it is up to me, and it is, I want OOP so my projects are logical, testable, and scalable.

    7. State

    XAML applications are persistent (stateful). It means static methods and properties work. It means in memory references work. And, it means MVVM works. XAML applications maintain state which helps developers maintain sanity – and  prevents the many hacks like state stores. More.

    Gg430869.C1C498204EFDB6E753EC8164CD18F023(en-us,PandP.40).png

    8. Expression Blend

    Since WPF, XAML designers and developers have enjoyed Expression Blend (part of the Expression Suite of tools). Expression Blend provides a visual and designer interface to accomplish complex actions and interactions in XAML UIs. Nothing compares.

    Many developers have avoided Blend because of the initial learning curve. The reality is, whatever can be accomplished in Blend could also be accomplished in Visual Studio. Similarly, whatever could be accomplished in Visual Studio could be accomplished in Notepad. Blend is worth it.

    9. Debugging

    C# developers have long used the debugging features in Visual Studio. Just set a breakpoint a build. Now with Intellitrace, there’s even more ways developers can debug an application. But XAML developers (evident in Silverlight 5) have the option to debug bindings right in the XAML.

    But it’s not just that. Only robust languages like C# give you full intellisense, symbolic refactoring, incredible code analysis, and complexity metrics. One of the reasons I choose XAML is because I choose C#. And I choose C# because it has everything.

    10. Vectors, Vectors, Vectors

    Vector and Bitmap Differences

    A key benefit of WPF (the first XAML) over WinForms was that WPF was a vector-based rendering engine. It could leverage GPU acceleration and scale indefinitely. All XAML is vector-based, can leverage GPU acceleration and scale indefinitely. Boom!

    MSDN: WPF uses vector graphics as its rendering data format. Vector graphics—which include Scalable Vector Graphics (SVG), Windows metafiles (.wmf), and TrueType fonts—store rendering data and transmit it as a list of instructions that describe how to recreate an image using graphics primitives… One of the key benefits of vector graphics is the ability to scale to any size and resolution.

    11. Attached Properties

    Dependency Properties made it in my first list. But I was remiss to not mention Attached Properties. Like Dependency Properties, they are property bags and can be bound and animated. But, unlike Dependency Properties, Attached Properties can be “attached” to controls (any control) without the control’s knowledge.

    Attached Properties let developers extend control behavior or store information. Canvas.* and Grid.* are familiar attached properties. Literally, they extend controls to meet the developer’s needs, easily.

    Hint: there is a built-in Visual Studio C# snippet (propa) that creates the basic structure of an attached property for you.

    imageMSDN: One scenario that calls for the creation of an attached property is to enable an object to specify a unique value for a property that is defined in a different class object model. The defining class can read this value at run time after the various objects are created in relationships in an object tree.

    Remember the pain

    Native and third party controls deliver 99% of what your applications needs. With attached properties you extend behaviors without work-around or non-standard implementations. Problem solved.

    12. Control Templates

    Control templates remind me of OuterHtml but without losing the functionality of the element. XAML developers, using Control Templates, turn controls (visually) into anything without losing its underlying behaviors. It’s like a Transformer (the good kind!).

    As a result, we see scroll bars looking like candles, radio buttons like chilies, and textboxes like televisions. Textboxes can be Images, Grids can be Radio Buttons, whatever you need! The real advantage is when you want to “tweak” a control by inheriting its template and adding some extra something your application needs. If you can dream it, XAML can do it.

    imageMSDN: In the XAML framework for Microsoft design style apps, you create a control template when you want to customize a control’s visual structure and visual behavior. Controls have many properties, such as Background, Foreground, and FontFamily, that you can set to specify different aspects of the control’s appearance. But the changes that you can make by setting these properties are limited. You can use the ControlTemplate class to create a template that provides additional customization. Here we show you how to create a ControlTemplate to customize the appearance of a CheckBox control.

    Remember the pain

    Native and third party controls provide significant benefit to your project but do not match the overall look and feel. With control templates, you can “skin” controls to fit your model. Problem solved.

    13. Data Template Selectors

    Data templates are fundamentally your ability to show data. If you are repeating data in some type of items control or individually in a content control, it’s the data template that defines how the data appears. Just set it or select it.

    imageMSDN: You can place a DataTemplate as the direct child of an ItemTemplate property element in XAML. You can also define a DataTemplate as a resource and then reference the resource as the value of the ItemTemplate property. The XAML usage that defines the content for creating a data template is not exposed as a settable property. It is special behavior built into the XAML processing of a DataTemplate object element.

    Even cooler? Let’s say you have a list of mixed data types – like dogs, cats, and birds. You may have a data template for each. It’s the data template selector that allows you to use ANY logic you want to determine which data template is used for a record. Go selectors!

    imageMSDN: The base DataTemplateSelector class is not used as an object element in XAML. However, it is a common scenario to derive a custom DataTemplateSelector, map a xmlns prefix for the custom class and its namespace/assembly, and then refer to an instance of the custom class as defined in a Resources block in XAML. This makes it possible to refer to the custom template selector class by x:Key, and use that reference to set the value of properties such as ItemTemplateSelector in XAML templates and particular visual states.

    Remember the pain

    You show the same data in multiple places in your application. Because data templates can be a shared resource, you don’t have to repeat yourself. Some lists contain a mixture of item types, using data template selectors you can swap the data template before it is applied. Problem solved.

    14. Linq & Lambda

    To understand Linq & Lambda is to understand what makes them different. Regardless, they have been part of the .Net family since Framework 3.5 (Visual Studio 2008). Although there is a learning curve, developers who use them swear by them for enumerable operations like sorting, filtering, and so much more. There are technical reasons why they improve on traditional techniques. Linq (Language integrated query) has exposed databases, XAML, objects, even custom sources like Twitter to .Net developers with super-easy interoperability.

    imageMSDN: LINQ introduces standard, easily-learned patterns for querying and updating data, and the technology can be extended to support potentially any kind of data store. Visual Studio 2008 includes LINQ provider assemblies that enable the use of LINQ with .NET Framework collections, SQL Server databases, ADO.NET Datasets, and XML documents.

    Lambda expressions are anonymous methods that build expression trees to accomplish some task. I think Lambdas are *the* sufficient reason for picking XAML, period. What I mean is, the productivity gains, the reduction code, they are all amazing. I could stop here. But I won’t.

    imageMSDN: When you use method-based syntax to call the Where method in the Enumerable class (as you do in LINQ to Objects and LINQ to XML) the parameter is a delegate type System.Func<T, TResult>. A lambda expression is the most convenient way to create that delegate. When you call the same method in, for example, the System.Linq.Queryable class (as you do in LINQ to SQL) then the parameter type is an System.Linq.Expressions.Expression<Func> where Func is any Func delegates with up to sixteen input parameters. Again, a lambda expression is just a very concise way to construct that expression tree. The lambdas allow the Where calls to look similar although in fact the type of object created from the lambda is different.

    Remember the pain

    Working with collections is a common task. You frequently have to filter, bubble sort, and distinct your lists. The work isn’t hard but the code is long and confusing to maintain. With Linq and Lambda the same solutions are just a few characters. Maintenance is easier. problem solved.

    15. It’s not standards-based

    Anyone noticed the return of browser wars? It frustrates developers and is expensive for companies. Why? Because browser subtleties are not ironed out, they are positioned as differentiators. And so it goes.

    This will never end you know. The HTML5 peace & harmony dream is a little naïve and a little stupid. Why? Because everyone wants to make their mark. Everyone wants to make their buck. And everyone sees themselves in a crusader.

    The disadvantage to HTML is specification; as noble and as comprehensive as it may be, it will always be incomplete, always in despite, and always speculative. The tides of opinion may prefer one implementation over another, but it will never matter. Non-standard is the density of standards.

    XAML, on the other hand, is less like democracy and more a dictatorship. The analogy is bitter but the reality is sweet. There is always a consensus, and it is what it is. It’s like comfort food. There is never wiggle room. Implementation is consistent across platforms.  Period.

    Remember the pain

    Writing HTML and JavaScript that worked the same on all systems and all browsers meant a lot of extra development and, eventually, the lowest common denominator. Your lines of code exploded. XAML applications are all the same and always look the same. Problem solved.

    16. Model view view model (MVVM)

    One of the most popular and easy to use design patterns is Model View View Model (MVVM). Believe it or not, MVVM is from XAML! True. Check out this article snippet:

    MSDN Mag: In 2005, John Gossman, currently one of the WPF and Silverlight Architects at Microsoft, unveiled the Model-View-ViewModel (MVVM) pattern on his blog. MVVM is identical to Fowler’s Presentation Model, in that both patterns feature an abstraction of a View, which contains a View’s state and behavior. Fowler introduced Presentation Model as a means of creating a UI platform-independent abstraction of a View, whereas Gossman introduced MVVM as a standardized way to leverage core features of WPF to simplify the creation of user interfaces. In that sense, I consider MVVM to be a specialization of the more general PM pattern, tailor-made for the WPF and Silverlight platforms.

    It’s easy to love MVVM. It’s appeal explains its popularularity. It’s abstraction and separation of duties is clean and simple. And, it goes with XAML like peanut butter and jelly.

    Remember the pain

    Adding data to your application used to mean adding complexity. But MVVM is a consistent, simple approach. Now there’s similarity across projects and development teams. Problem solved.

    17. Intellectual Property

    Intellectual property is a legal term, right? We’re all grown ups here. We know there is no software silver bullet to hide code or logic from prying eyes. Tempt the tech community and it’s game over. We can make it difficult, but that’s it. Let’s not pretend.

    So, this is a real problem. You or your company is paying real money to build a real product. Your solution, your approach, your code – it’s all property and it’s all worthwhile and worth money.

    If you take your keys with you when you into the mall. If you lock your house when you go on vacation. Any of those, then you understand the value of risk and value. You’ve spent the money and time. Why give it away?

    Having said that, we want to make it freaking difficult. 99% of all the IP snoops will stop at the first (maybe second) gate they hit. .Net developers have enjoyed dotfuscator for a long time. It makes .Net code run faster,sure, but also nearly impossible to reflect (reverse-engineer).

    Boom. JavaScript has a similar obfuscator, but really is just a minify engine. Minify. That helps. Good for JavaScript, but .Net obfuscation is significant, improves performance, provides error reporting, and so much more. Give me a choice. I choose .Ne obfuscation to protect my software investment.

    Techniques to protect IP (oh yeah, these are built in to the obfuscators!) – and makes it obvious why JS minify is more like a toy than real Intellectual Property protection: Symbol renaming, Overload renaming, String encryption, Tamper detection, Flow obfuscation, ILDASM suppression, Reflection suppression, Decompile suppression, Resource encryption, and Assembly encryption.

    Remember the pain

    Your code is worth time and money and you didn’t spend it to teach everyone else your magic. Using obfuscation, your intellectual property is protected. Problem solved.

    18. Service Proxy Generation

    When I call a cloud service, data is returned to me. Sometimes it is a string I parse myself, deserializing XML or JSON. I love to use Json2Sharp to save time (check it out!).

    The process is easy and fast.  But the bulk of well-designed line-of-business services are SOAP, not REST. For a WSDL-defined service, adding a reference in Visual Studio automatically builds the proxies for to interoperate and leverage client-side, typed classes.

    Unless you are paid by the hour (or the line), you will love the code generation in Visual Studio. (called T4 templates). Now, the interoperability is something you can assume. Best of all, updates or changes to service signatures is as simple as a right-click “Update Service Reference”.

    imageMSDN: A WCF client consists of a proxy that enables an application to communicate with a WCF service, and an endpoint that matches an endpoint defined for the service. The proxy is generated on the client side in the app.config file and includes information about the types and methods that are exposed by the service. For services that expose multiple endpoints, the client can select the one that best fits its needs, for example, to communicate over HTTP and use Windows Authentication.

    Remember the pain

    Manually accessing services meant your application was brittle and needlessly complex. Using Visual Studio service proxy generation creates your code for robust interaction. Problem sovled.

    19. The Desktop

    If you are building a skill, why not unlock every Microsoft platform? XAML does that. Best of all, learning XAML gives you both the ability to write awesome, touch-ready Microsoft design style apps, windows phone apps, and web apps.

    But, also use XAML for Windows 8 desktop applications (in WPF); reuse your C# in services, leverage it in web sites. XAML makes the most of your skills – even unlocking the desktop for custom LOB applications.

    Remember the pain

    Adobe Air and tech like HTML are cool but limit you too much. With the .Net framework and XAML you have the skills to build on every Microsoft platform. Problem solved.

    20. A Culture of Design

    WPF enabled it, Silverlight made it real, and it continues today through Microsoft design style. Any app, in any tech, must meet the needs of users, the business, and efficiency. That’s custom software’s definition of success. The latter, however, is best handled through User Experience and design.

    XAML, more than most, intentionally targets designers to get involved early and often. Its separation of UI and implementation is a huge first step. But, Blend seals the deal. Blend delivers designers tooling  designers specific to UI layout and interactions.

    MSDN: Depending on your own role in the development process, you might not interact with XAML much. The degree to which you do interact with XAML files also depends on which development environment you are using, whether you use interactive design environment features such as toolboxes and property editors, and the scope and purpose of your Microsoft design style app. Nevertheless, it is likely that during development of the app, you will be editing a XAML file at the element level using a text or XML editor. Using this info, you can confidently edit XAML in a text or XML representation and maintain the validity of that XAML file’s declarations and purpose when it is consumed by tools, markup compile operations, or the run-time phase of your Microsoft design style app.

    And here’s my point. Now that we (Microsoft) have extended Blend to serve HTML developers, too, everyone benefits. I won’t attempt to equate the functionality of Blend for HTML to Blend for XAML, but who’s counting? XAML, however, is steeped in a culture of design. It is the go-to UI for anything cool (think Silverlight & Surface) that Microsoft creates.

    Reality check: many software projects don’t benefit from a budget that affords a designer. Or, many projects don’t benefit from a manager who values design. XAML’s culture of design is a self-fulfilling prophesy, a kind of positive peer pressure. Because XAML focuses on UX, XAML projects often reflect this predilection – even without a formal designer. It’s not ideal, but it’s better. Really better.

    Remember the pain

    Most apps are ugly. Just admit it. And your’s might be part of the problem. XAML enables better design, but also fosters it. Slowly we are seeing better UX. Problem solved.

    21. Separation of Concerns

    In software engineering separation of concerns has a few different meanings: To some it means scope creep. To others it means maintenance nightmare. To others it means job security. But, to a few, it means encapsulation, components, and testability.

    Wiki: In computer science, separation of concerns (SoC) is the process of separating a computer program into distinct features that overlap in functionality as little as possible.

    Look, your mother’s cookies are not the reason your are fat. But, they are an enabler that makes it possible. XAML is not the reason for separation of concerns, other technologies allow the same principles with distinct implementations, but the fundamental structure of XAML enables it, too. And when you end up knee deep in SoC, you end up liking it.

    Listen, I am not talking about the shallow separation of HTML, CSS, and JavaScript. I am talking about symbolic separation in software. This is Aspect-oriented programming; it partitions code based on duty, vertical domain, or use case. One is a black box of function, one is a black box of activity.

    Your architect can choose one over the other based on the latest magazine cover. ;) Either way, both are important – and show up frequently and rightly in larger projects. And, of course, both are equally enabled by XAML and the underlying OOP code.

    Soap box: I am *not* talking about reuse here. Budgets are frequently subjected to developers chasing reusability. But developers rarely accomplish it, fellow developers rarely know about reusable components, and calcification sets in fast – reducing reusability to an expensive pipe dream. Yes, work to eliminate redundant code when possible; but, please, don’t target endless reuse. Just complete your task card and deliver a working product. Be proud of completion, not complexity.  </speech>

    Remember the pain

    Repeating yourself in software is sometimes okay, but typically just introduces needless maintenance costs. With Seperation of Concerns you get less redundancy. Problem solved.

    22. Inline Invocation

    XAML isn’t really markup, you know. XAML is a declarative UI referencing CLR objects, not page content, text, or layout. For example, placing a <GridView/> in XAML really is invoking the GridView control. The control then manipulates presentation. Built-in or custom, XAML references controls. This is what makes XAML powerful, but it is also why XAML provides inline invocation.

    Consider these classes:

    image

    Such a structure is common to create a containers with data. When PEOPLE is invoked, data is generated by its constructor. Since we can invoke classes directly in XAML, our PEOPLE constructor runs before we ever debug the app! This gives us real data that really binds in our design surface – executing transitions, bindings, and repeaters inside Visual Studio.

    Here’s how we do it:

    image

    In the code above, we are invoking a new instance of People. That instance is placed in the DataContext property of the Page. But we leverage the “d:” prefix which indicates XAML intended only for design time. As a result of this approach we have design time data that we know wont pollute our runtime experience. (This is an excellent way to implement MVVM with Design-time data)

    But XAML also allows us to set properties after our invocation. Imagine the same scenario but without a constructor that creates sample data. We can, instead, create the sample data we need in our XAML directly. This helps us manage the data to suit our Page’s use case.

    Like this:

    image

    In the code above, just like before, we are invoking the People list. But in addition, we are invoking our own Person members of the collection. With every invocation we have the ability to specify property values and use the resulting instances as our design time data context. I love it. You will, too.

    Remember the pain

    Design time data let’s you manipulate our UI with a real context. Otherwise, you have to run everytime you want to see a chance. With inline invocation design data is a snap. Problem solved.

    23. Drawing Objects

    Path illustrationNo need for canvas. No need for SVG containers. Just stinkin’ draw – anywhere. That’s right, and the drawing capabilities in XAML are (and have been) flexible and vector-based.

    MSDN: The Path class enables you to draw curves and complex shapes. These curves and shapes are described using Geometry objects. To use a Path, you create a Geometry and use it to set the Path object’s Data property.

    image

    In the code above, you can see the value of a design tool like Blend, no? I know Data could do it, but some of us need tooling. Nonetheless, the data attribute contains the definition for the arc. The rest are styling properties you use to make it look just so.

    Line, Ellipse, and Rectangle are all wrappers for the Path element – so common shapes can be easily integrated by XAML developers. XAML can draw any 2/3d shape and leverage any transform to give the perspective or movement (which can leverage animation) you want.

    MSDN: Because they derive from UIElement, shape objects can be used inside panels and most controls. The Canvas panel is a particularly good choice for creating complex drawings because it supports absolute positioning of its child objects.

    Remember the pain

    Not everything in your UI is going to be a rectangle. When you need a custom shape, there’s no need for third party libraries. Complex drawing is part of XAML. Problem solved.

    24. Event and Data Triggers

    XAML has the Routed Event. Consider this: a Routed Event can raise an event like a button’s click event, but it can also travel upward through the XAML visual tree (called bubbling). This allows containers to register for their children’s events.

    MSDN: A routed event is a CLR event that is backed by an instance of the RoutedEvent class and registered with the WPF event system. The RoutedEvent instance obtained from registration is typically retained as a public static readonly field member of the class that registers and thus “owns” the routed event.

    Here’s how Triggers look:

    image

    But even better than Routed Events are Routed Event Triggers. On XAML controls, developers leverage Routed Event Triggers to listen and react to Routed Events. Routed Event Triggers can then start or restart waiting storyboards. In this way, developers can declare a response to user action(s) without code behind. The execution engine builds the implementation.

    MSDN: EventTrigger s apply a set of actions when the specified routed event occurs. For example, you may want to use EventTriggers to start a set of animations when the mouse pointer is over a certain user interface (UI) control.

    Remember the pain

    Interacting with the user is important but not always worth an additional code base. Using Event Triggers, your XAML can declare storyboard interactions directly. Problem solved.

    25. Cascading Styles

    XAML’s “cascading styles” are so much more than simple CSS classes. Remember in #22 where we discussed how XAML elements actually invoke CLR objects? <Style> is the same. And just like inheritance in Object Oriented Programming is a goliath benefit, Style inheritance is the ultimate!

    Aside: I talked bout BasedOn in a previous article

    Consider this:

    image

    In the code above, I am creating two TextBox styles – each of the two (good/green and bad/red) inherit from the base. This allows me to maintain the complexity within the base, then adjustment it in the concrete styles that are based on it.

    Unlike CSS, I do not use multiple or nested styles or classes (confusing developers with an invisible priority tree), just the style I want. And every style can have a base or lineage of bases that create rich, themed and skinned interfaces that I can control programatically.

    MSDN: There are several ways that styles in WPF can be extended or inherited. Styles can be based on other styles through this property. When you use this property, the new style will inherit the values of the original style that are not explicitly redefined in the new style.

    Remember the pain

    Themes, skins, and styles are important to create a rich application but can make things complex and confusing. With style inheritence, we control the style tree intuitively. Problem solved.

    XAML developers can save time by knowing the deltas between the previous XAML development experience and what to expect in Microsoft design style. 

    1. The binding Mode is not TwoWay by default. OneWay is, even for TextBoxes. That means Mode=TwoWay needs to become something you type by default. Otherwise, you might start thinking that simple binding does not work when it really works just fine.
    2. The ImageBrush’s TileMode is missing because TileBrush is missing. The RadialGradientBrush and VisualBrush are missing. You can burn hours looking for these (like I did). As a result, you will be using more images than you typically would in your designs.
    3. There is no ability to PriorityBinding or MultiBinding in Microsoft design style(this was also true in SL). Combine that with missing StringFormat and TargetNullValue, though, and you will be using more converters than you might otherwise. Leverage MVVM for formatting, too.
    4. Like Silverlight, Loaded is the only RoutedEvent supported in EventTriggers. The error when trying any other event is confusing. In the end, it means most of your animation will be handled through VisualStates more than animating the style.
    5. At least in the Release Candidate, the editor reports a WindowsUIXamlBindingWrapper exception when attempting to bind anything to a control’s DataContext. This is only a design-time issue; You can continue developing – but with lots of blue underlines.
    6. It is not possible to bind the ColumnSpan or RowSpan of a DataGridViewItem to any value inside the DataGrid’s ItemTemplate or DataContext for to support VariableSizedWrapGrid. Instead, you must inherit from GridView, overriding PrepareContainerForItemOverride(). Note: I will blog about this one soon because it is complicated.
    7. To animate properties that cannot be hardware accelerated, you must set EnableDependentAnimation which explicitly allows this, and acknowledges the resulting animation is CPU-based. Otherwise, your animations are ignored (no error).
    8. There is a new method argument property called CallerMemberNameAttribute (you might not have even known that arguments could have their own attributes) which sniffs out the calling method or property’s name. This is useful to implement INotifyPropertyChanged. Cool.
    9. To implement a Flyout you need to use the Popup control
    10. To implement a Flyout/Popup you need to write the “placement” logic
    11. RequestedTheme in App.xaml cannot be set per-page
    12. Search for Callisto if you are looking for a date picker
    13. You cannot debug bindings like in SL5 (commonly asked)
    14. Color Picker is not available with the default controls provided in Windows Store Apps project.

    Windows8 Desktop Keyboard Shortcuts

    Keyboard Shortcut

    Details

    Windows + I

    Window Restart, Shutdown, Sleep, Taskbar Notification Icons like Network, Sound Control, Brightness, Notifications, Keyboard.

     

     

    Windows + X

    Menu for frequent Administrator Tasks

    Windows + 0

    Opens 10th application on taskbar with  Normal Privileges. You can use the following values for applications on Taskbar.

    1. 1st Application on taskbar of Classic Desktop View
    2. 2nd Application on taskbar of Classic Desktop View
    3. 3rd  Application on taskbar of Classic Desktop View
    4. 4th  Application on taskbar of Classic Desktop View
    5. 5th  Application on taskbar of Classic Desktop View
    6. 6th  Application on taskbar of Classic Desktop View
    7. 7th  Application on taskbar of Classic Desktop View
    8. 8th Application on taskbar of Classic Desktop View
    9. 9th  Application on taskbar of Classic Desktop View

    You can rearrange your applications on taskbar  according your choice and priority to take advantage of this shortcut.

    Windows + Ctrl + Shift + 0

    Opens 10th application on taskbar with  Elevated Privileges. You can use the following values for applications on Taskbar.

    1. 1st Application on taskbar of Classic Desktop View
    2. 2nd Application on taskbar of Classic Desktop View
    3. 3rd  Application on taskbar of Classic Desktop View
    4. 4th  Application on taskbar of Classic Desktop View
    5. 5th  Application on taskbar of Classic Desktop View
    6. 6th  Application on taskbar of Classic Desktop View
    7. 7th  Application on taskbar of Classic Desktop View
    8. 8th Application on taskbar of Classic Desktop View
    9. 9th  Application on taskbar of Classic Desktop View

    You can rearrange your applications on taskbar  according your choice and priority to take advantage of this shortcut.

    Windows + C

    This shortcut gives you view the Settings, Devices, Start, Share & Search. This is the same option that comes when you move the mouse to the extreme bottom right corner.

    Ctrl + Shift + Esc

    Task Manager

    Windows  

    Toggle between Modern Desktop & Legacy Desktop

    Windows + D

    Takes you to Legacy Windows Desktop.

    If you press this key from the Modern Desktop, this takes you to the currently active application on the Legacy Desktop.

    If you press this key from the Legacy Desktop, this displays the Desktop.

    Pressing the same key combination, will Toggle Between the Legacy Desktop and Active Application on the Legacy Desktop

    Only Legacy Desktop shown when all applications are in a minimized state

    Windows + B

    From the Modern Desktop, this takes you to the currently active application on the Legacy Desktop.

    If all application are in minimized state on Legacy Desktop, this command will take you to the Legacy Desktop.

    No effect when used from a Legacy Desktop.

    Windows + M

    From the Modern Desktop, this takes you to the Legacy Desktop and minimizes all applications on the  Legacy Desktop

    When used from a Legacy Desktop, minimizes all applications.

    If all application are in minimized state on Legacy Desktop, this command will take you to the Legacy  Desktop.

     

    Windows + Q

    Displays Apps windows with all apps and Search Bar

    Windows + W

    Displays Search Settings.

    Windows + E

    Windows Explorer displaying Computer Folder. Same as clicking on My Computer.

    Windows + R

    Display Run window.

    Windows + T

    Displays the Window Group Thumbnails on your taskbar. This is equivalent of hovering the mouse over the Taskbar Icons.

    Each time you press the Windows + T combination, the next application group is  displayed

    Windows + U

    Displays Ease of Access Center

    Windows + P

    Option to Extend the display.

    Windows + +

    Zoom Windows

    Windows + F

    Search Files

    Windows + H

    Display Share options

    Windows + K

    Display Devices to Share with.

    Windows + <

    Preview Legacy Desktop

    Windows + L

    Lock the Computer

    What is Portable Class Library project in Visual Studio 2012– .NET 4.5

    You can download from Windows Store at
    http://apps.microsoft.com/webpdp/en-US/app/emergency-help-me/477b898a-6781-4b75-a439-44dee5904f14

    I recently installed Visual Studio 2012 Ultimate edition on Windows 8 RC and noticed Portable Class Library project in the New Project Dialog, which immediately made me to research on what PCL is about. Following is my findings about PCL from the web.

    The need for portable .NET Framework code

    Developers have seen a diversification of computing platforms over the last few years – PCs, phones, cloud, Xbox, and tablets. It often makes sense to target more than one of these platforms from your app. For example, most client apps and games that are built today call into a server component to retrieve and save data (for example, a set of high scores, a list of friends, a grocery list, or a new expense report). .NET developers often create rich object models that describe that data, and expect to code to that object model on both the client and the server. Wouldn’t it be even better if you could write, compile, and test that common code just once? That’s exactly what portable class libraries enable you to do.

    Many of you have asked for the option to reuse assemblies (binaries), not just source code, across projects. Sharing code across projects creates more commonality across those projects, which makes you and your team more efficient. I would guess, however, that many of you share code today by either creating copies of common code for each project, with slight modifications, or maintain a common copy that contains a significant number of conditional compilation directives. These approaches to source code reuse are relatively easy to employ initially, especially in small code bases. As your product codebase grows, you may find that these source-sharing strategies start to scale poorly. You’ll start to wonder what you need to do to share binaries instead. The APIs across the .NET Framework platforms are generally the same, so binary reuse should just work, and that’s what many of you expect.

    Portable class libraries enable you to create and compile code that can run on multiple .NET Framework platforms. You can build a library that is usable across all your projects. Whatever that library does, it will do that same thing in all the apps or websites/services that you build. You avoid having multiple copies of the code or managing a set of conditional compiler directives in a common copy. For app developers who have a few common dependent libraries across a suite of apps, this feature is a pretty significant win. It is also a huge step forward for library developers who make their assemblies available to a large audience of developers who build apps for a variety of Microsoft platforms. We’ve seen library developers creating several variants of their work, one for each .NET Framework platform. Portable class libraries either remove that need completely or scope the degree of differences that needs to be supported to something smaller and more manageable.

    There are different kinds of .NET frameworks available. There is the .NET Framework, but .NET is also in Silverlight, the Windows Phone, the Xbox, Metro (Windows 8) etc. If you create a regular Class Library it has a single Target Framework. However, if you are doing a multi-platform application and you want to maximize your code reuse, you can run into trouble as you may not have all libraries available on the smaller platforms.

    Thus, Portable Class Libraries were created. These Portable Class Libraries (PCLs) will generate a managed assembly that can be referenced by Windows Phone 8, Windows 8 Metro, Silverlight 5, the Microsoft .NET Framework (Client profile) and Xbox 360 platforms. This can really help to maximize reuse of your code and reduce the number of required projects, particularly in multi-targeted applications solutions that share the same codebase

    Prior to PCL projects, solution projects could only reference assemblies of the same platform. Silverlight projects referenced other Silverlight assemblies, .NET projects other .NET assemblies and so on. To code effectively, we could accumulate an unmanageable number of projects; when creating shared codebases (code that can be used across all platforms), we’d have to create a project for each platform.

    Once you reference another project, your project can become tightly coupled, forcing you to drag not only it, but also any dependencies it has, to the other projects. If you only have a few projects, it makes it increasingly more difficult to reuse the code in other solutions.

    A PCL can significantly reduce the number of projects you have to manage, particularly if you want to have a clear separation of concerns permitting you to easily reuse your projects in other modules or solutions. The key is to keep your projects loosely coupled by programming against interfaces. This will permit you to use DI frameworks, such as the Managed Extensibility Framework (MEF) and Unity, which allow you to easily configure the implementation for the interfaces. That is, the DAL implementation for interfaces could be SQL Server, the cloud or SQLite classes.

    Some of the key point to using PCL are as follows:

    Write once, use everywhere : Portable Class Library is a new project in Visual Studio from Microsoft that enables you to create C# and Visual Basic libraries that run on a variety of .NET-based platforms without recompilation.

    Simplify code sharing : No more complicated build scripts or #defines, and stop copying and pasting code for different platforms; portable libraries enable you to easily share code between apps that target different platforms.

    Share between platforms : Create a Portable Library project and reference it from any .NET Framework, Silverlight, Windows Phone or XNA project as shown in Fig 1.

     

    image

    Fig 1: Example of using PCL in different apps that target different platforms

    The Portable Class Library project enables you to write and build managed assemblies that work on more than one .NET Framework platform. You can create classes that contain code you wish to share across many projects, such as shared business logic, and then reference those classes from different types of projects.

    Using the Portable Class Library project, you can build portable assemblies that work without modification on the .NET Framework, Silverlight, Windows Phone 7, or Xbox 360 platforms. Without the Portable Class Library project, you must target a single platform and then manually rework the class library for other platforms. The Portable Class Library project supports a subset of assemblies from these platforms, and provides a Visual Studio template that makes it possible to build assemblies that run without modification on these platforms. [Source =
    http://msdn.microsoft.com/en-us/library/gg597391(v=vs.110).aspx
    ]

    Target Platforms Determine Available APIs

    Within a Portable Class Library project, you can specify which .NET platforms the library is intended to run on.  Although there is a ‘core’ set APIs that are available on all platforms, there are also some APIs that are only available on certain platforms.  An example of an API that exists on some platforms but not others is MEF.  Windows Phone and Xbox 360 do not currently have built-in support for MEF, but .NET and Silverlight do.  If you want to use MEF within a portable library, the library will currently only run on .NET and Silverlight.

    When you specify the platforms you want to target in a Portable Class Library project, only the supported assemblies for those platforms are referenced in your project. If you try to reference an assembly that is not supported for the platforms you have targeted, Visual Studio warns you of the incompatibility. The core assemblies (mscorlib.dll, System.dll, System.Core.dll, System.Xml.dll, and System.Xml.Serialization.dll) are supported on all versions of all platforms.

    If you target only the .NET Framework 4.5 RC and .NET for Metro style apps, you have access to a much larger set of assemblies than is available in other platform combinations. This larger set of assemblies is almost identical to the .NET APIs for Metro style apps, but doesn’t include the classes in the Windows.UI.Xaml namespaces. For more information, see .NET for Metro style apps in the Windows Dev Center.

    Thus, the project’s selected target platforms determine which APIs can be used within the project.  The APIs that are shown in intellisense and available to the compiler are automatically filtered based on the selected target platforms, so you don’t need to have any special knowledge about each platform or worry about inadvertently using an API that doesn’t exist on a platform that you’re targeting.  The project system takes care of this for you.

    In the future, as the underlying platforms evolve to support more APIs that could be portable, MS will update the API surface available to portable libraries as appropriate.

    Supported scenarios : We used the following main scenarios to define the scope and direction of portable class libraries:

    • Call BCL APIs
    • Use the latest language features, such as dynamic programming, async and LINQ
    • Read and write XML
    • Call HTTP URIs, specifically for REST-style end-points
    • Call WCF services
    • Build Model-View-View Model (MVVM) patterns
    Supported platforms : It’s easy to support the scenarios listed above for one or two .NET Framework platforms, but MS needed to reach farther and support a broader set of platforms. In Visual Studio Professional 2012 RC, the Portable Class Library project supports the following .NET Framework platforms:
    • .NET Framework 4, Update 4.0.3 for the .NET Framework 4, and .NET Framework 4.5
    • .NET for Metro style apps
    • Windows Phone 7.x and higher
    • Silverlight 4 and 5
    • Xbox 360

    The following table summarizes the high-level functionality currently available on each platform:

    image

    Fig 2. Supported portable class library features and scenarios

    Following is some of the important features and the respective assemblies.

    Core :mscorlib.dll, System.dll, System.Core.dll, System.Xml.dll, System.Xml.Serialization.dll

    Managed Extensibility Framework(MEF):System.ComponentModel.Composition.dll

    Network Class Library (NCL) : System.Net.dll

    Serialization : System.Runtime.Serialization.dll

    Windows Communication Foundation (WCF) : System.ServiceModel.dll, System.ServiceModel.Web.dll

    Model-View-View Model (MVVM) : System.Windows.dll

    Data annotations : System.ComponentModel.DataAnnotations.dll

    LINQ to XML : System.Xml.Linq.dll

    Constraints of PCL: The only constraint is that the PCL can’t reference platform-specific projects; it can only reference other PCL projects. On the surface this can appear limiting, especially for applications that utilize Prism and dependency injection (DI). But with careful planning, you can work around this constraint and create efficient PCL projects that will help enforce good development practices.

    Getting Started With Windows 8 Release Preview & Development Using Visual Studio 2012

    I upgraded my machine from Windows 8 Developer preview to Release preview and here is my experience.

    Downloaded the Windows 8 Release Preview from
    http://windows.microsoft.com/en-US/windows-8/release-preview
    .

    (You can find ISO files at
    http://windows.microsoft.com/en-US/windows-8/iso
    .)

    Once you downloaded the file, run it and windows 8 installation will kick in. The setup installed Windows 8 release preview preview on top of Windows 8 developer preview and I ended up having two OS on my system. During startup, I now have two OS to choose from, which is not what I wanted. So I used the Reset feature in Windows 8 and it cleaned all the drives and removed all the old Operating systems. I now have just one Windows 8 release preview on my machine. I really loved the Reset feature in Windows 8.

    photo

    Fig 1: Screenshot of Upgrade agent

    photo

    Fig 2: Personalize option during Windows 8 installation

    Once I had the Windows 8 Release Preview installed and working, downloaded the VS 2012 to start development using the new OS. This will install the VS 2012 along with the Blend for Visual Studio.

    Download the Visual Studio 2012 RC:


    http://www.microsoft.com/visualstudio/11/en-us/downloads#professional

    Once you install VS 2012 RC, get a  developer license for Windows 8 by opening the visual studio. The following figure shows the developer license dialog.

    developer license

    Next, downloaded the tools & sdk needed for the development.

    Download the Tools & SDK:


    http://msdn.microsoft.com/en-us/windows/apps/br229516

    Hands-on-labs, presentations, samples and resources from the Windows 8 camps at  Windows 8 Camp in a box.

     

    Following are some of the useful links to get started with the Windows 8 development.

    Internals (Deep dive) of Metro Application calling WinRT Component DLL

    We have created a C++ XAML application that consumes the WinRT C++ DLL in part 1

    we have seen the compiler generated components when we compile a WinRT Component DLL.  Part2  discusses how the C# application interacts with the C++ WinRT component.

    We have seen the packaging and installation process that happens in the background during building and deploying of the applications here Under the hood Part 3 : WinRT, Windows 8, C++, C#.NET, Metro, WinRT Component DLL

    We have seen the C++ XAML application calling the C++ WinRT Component DLL here Under the hood Part 4 : C++ WinRT Component DLL & C++ XAML application – WinRT, Windows 8, C++, Metro

    Part5 discusses developing JavaScript application that consumes WinRT Component DLL

    Lets dig deeper into how the C++ Application makes  a call across the WinRT Application Binary Interface to access the class methods inside the WinRT DLL. The slide in fig 1 is taken from the build conference which shows the internals of the method calls. We will examine the ABI and how C++ compiler extensions help reference that ABI without exposing the internal details of dealing with COM interfaces and COM activation.

    Download the source code from here.

    image

    Fig 1: Slide showing the flow of the method calls across the boundaries.

    A WinRT component implements the IInspectable interface, which is derived from IUnknown. IInspectable is used by the dynamic language bindings from JavaScript. Given a reference to a WinRT component, the JavaScript interpreter can call the IInspectable::GetRuntimeClassName method and obtain the fully-qualified class name of the WinRT component. Using the namespace name the interpreter can ask Windows to load the metadata file (.winmd) describing the component, and from the metadata determine how to use the interfaces implemented by the component.

    When WinRT components are accessed from C++ or from .NET languages, there is no need for the IInspectable interface – IUnknown::QueryInterface suffices for all intents and purposes. In fact, .NET “interop” with WinRT relies on simple COM interop – an RCW created by the CLR manages the lifetime of the underlying WinRT component. For C++ language bindings, the story is somewhat more complicated, and the language extensions come into play.

    The left side in Fig 1 is the C++ client application code which calls the method in right side WinRT DLL. So here if the method in C++ DLL throws an exception, it should be caught by the C++ application. But it’s not a good practice throw exceptions directly across boundaries.

    The left side call (C++ Client App: Consumer) to Add() method causes the compiler to create an inline native to COM wrapper method. Also, on the left hand side, COM HRESULTs are converted to exceptions and COM “retval” arguments are converted to return values. The Add() method makes a call to this wrapper method. This inline methods generated will be something like a COM method that we write in COM components. We can see the source code generated by the compiler using some compiler switch options. we have seen the compiler generated components for making the C# application access the C++ WinRT component here Under the hood Part 2 : C++ WinRT Component DLL & C#.NET Metro application.

    From the WinMD file, the C++ application knows the WinRT API signature(shown at the top of the slide) and makes the appropriate call across the WinRT ABI.

    HRESULT __stdcall Add(Calculator* this, int i, int j, int * result)

    //On the LHS Application, the native to COM Wrapper is as follows (Consumer-side stub pseudo-code) . See the last section of this post to see the compiler generated code. 
    inline int Add(int i, int j) {
    int res;
    HRESULT hr = __cli_Add(this, i, j, &res);
    if (hr != 0) {

    __throw_hr_as_exception(hr); }
    return res;
    }

    On the right hand side too (C++ Component DLL), C++ compiler generates inline functions. Also, WinRT and C++ exceptions are converted to HRESULTs and return values are converted to “retval” arguments. Note that the only HRESULT, which does not represent an exceptional condition, is S_OK (numeric value 0). No more positive HRESULTs (such as S_FALSE) that need to be checked explicitly by the caller.

    //On the RHS C++ Component, COM to Native Wrapper stub pseudo-code is as follows:
    HRESULT __stdcall ___cli_Add(Calculator* calc,
    int i, int j, int* result) {
    try { *result = calc->Add(i, j); }
    catch(Platform::Exception^ e) { return e->HResult; }
    return S_OK;
    }

    See the last section of this post to see the compiler generated code.

    By the way, the inline wrappers can be called directly, bypassing the C++ language extensions.

    image

    The C++ language extensions (enabled by the /ZW switch) map WinRT to standard C++ patterns like constructors, destructors, class methods, and exceptions. For example, the language extensions hide the COM-style activation (RoActivateInstance) behind a constructor call (albeit with the ref new keyword), and hide reference counting (IUnknown::AddRef and Release) by automatically managing references. The syntax of these extensions is very similar to C++/CLI

    Code Snippet
        CalculatorSample^ calcobj = ref new  CalculatorSample();
        txtAddResult->Text = calcobj->Add(10,20).ToString();

    In the above code snippet, you can see we created the object of CalculatorSample class which is present in WinRT C++ Component using ref new. If you know COM, this is something like cocreateinstance() but its more than that. For now, use ref new to create objects of WinRT classes.

    Let us see how to skip to exception wrapper and directly calling the Add() method present in WinRT Component. Every function in the class has a low level equivalent inside the class and currently it is prefixed with __cli_ and it takes the output as last parameter. So using ToString() on an integer. So this is another way of calling the methods inside the WinRT components. If we need HResult, we need reference to windows.h. For that include Windows.h in pch.h file as shown below.

    Code Snippet
    //
    // pch.h
    // Header for standard system include files.
    //

    #pragma once

    #include <Windows.h>
    #include "App.xaml.h"

    The complete code to call the WinRT component method is as follows.

    Code Snippet
    MainPage::MainPage()
    {
        InitializeComponent();

        CalculatorSample^ calcobj = ref new  CalculatorSample();
        //txtAddResult->Text = calcobj->Add(10,20).ToString();

        // declare a stack variable to hold the value of the result
        int result;
        //call into  calc object low level __cli_Add() but no intellisense in this preview
        HRESULT hr = calcobj->__cli_Add(10,20,&result);

        //typedef HRESULT (__std

        txtAddResult->Text = result.ToString();
    }

     

    Another (3rd) way is to use function pointers and call the methods using pointers. Basically, we we can take the calculator^ object, which is a pointer to a pointer to a vtable and reinterpret cast it so that it has a pointer to virtual function, which are vtables. Then we can find out the location of the method we need to call using some compiler switches which I will show below. For the Add function, we are going to specifically pick the sixth function of that and call into it. In the class layout mentioned below, I highlighted the member at 6th location. reinterpret_cast takes the calcobj ^ and cast it to a pointer to a pointer, that’s it. This is how the functions inside the components are called internally at a low level.

    Code Snippet
    MainPage::MainPage()
    {
        InitializeComponent();

        CalculatorSample^ calcobj = ref new  CalculatorSample();
        //txtAddResult->Text = calcobj->Add(10,20).ToString();

        // declare a stack variable to hold the value of the result
        int result;
        //call into  calc object low level __cli_Add() but no intellisense in this preview
        //HRESULT hr = calcobj->__cli_Add(10,20,&result);

        //create a c function that actually represent an ABI call we will be making
        //to add function which takes this pointer, 2 input parameters and an out parameter.
        typedef HRESULT (__stdcall* AddFunc_t) (CalculatorSample^ calc, int i, int j, int * result);
        //now we can take the calculator^ object, which is a pointer to a pointer to a vtable
        //and reinterpret cast it so that it can say ok now i have a pointer of  virtual function
        //which are vtables and i am going to specifically pick the sixth function of that and call into it.
        //reinterpret_cast takes the calcobj ^ and cast it to a pointer to a pointer
        AddFunc_t* addFunc = *reinterpret_cast<AddFunc_t**>(calcobj);
        addFunc[6](calcobj,10,20, &result);

        txtAddResult->Text = result.ToString();
    }

    Basically a hat is a pointer to a pointer to an array of function pointers, which is Pointer to vptr to vtable. Hat (^) provides automatic reference counting.

    To find out the class layout, use the /d1reportSingleClassLayout<class name> compiler switch option. Right click on the WinRTComponent.cpp file in C++ WinRT Component DLL project and select Command Line which is under C/C++. In the Additional Options, mention /d1reportSingleClassLayoutCalculatorSample, click ok and compile the project. See the output window for the magic. There is also another option to see all classes layout by using the option /d1reportAllClassLayout.

    image

     

    1>—— Rebuild All started: Project: CppWinRTComponentDll, Configuration: Debug Win32 ——
    pch.cpp
    WinRTComponent.cpp
    class __ICalculatorSamplePublicNonVirtuals    size(4):
        +—
        | +— (base class Object)
    0    | | {vfptr}
        | +—
        +—

    __ICalculatorSamplePublicNonVirtuals::$vftable@:
        | &__ICalculatorSamplePublicNonVirtuals_meta
        |  0
    0    | &Object::__cli_QueryInterface
    1    | &Object::__cli_AddRef
    2    | &Object::__cli_Release
    3    | &Object::__cli_GetIids
    4    | &Object::__cli_GetRuntimeClassName
    5    | &Object::__cli_GetTrustLevel
    6    | &__ICalculatorSamplePublicNonVirtuals::__cli_Add
    7    | &__ICalculatorSamplePublicNonVirtuals::Add

    __ICalculatorSamplePublicNonVirtuals::Add this adjustor: 0
    __ICalculatorSamplePublicNonVirtuals::__cli_Add this adjustor: 0

    class __CalculatorSampleActivationFactory    size(12):
        +—
        | +— (base class IActivationFactory)
        | | +— (base class Object)
    0    | | | {vfptr}
        | | +—
        | +—
        | +— (base class Object)
    4    | | {vfptr}
        | +—
    8    | __cli_MultiThreadedRefCount __cli_refcount
        +—

    __CalculatorSampleActivationFactory::$vftable@Object@:
        | -4
    0    | &thunk: this-=4; goto __CalculatorSampleActivationFactory::__cli_QueryInterface
    1    | &thunk: this-=4; goto __CalculatorSampleActivationFactory::__cli_AddRef
    2    | &thunk: this-=4; goto __CalculatorSampleActivationFactory::__cli_Release
    3    | &thunk: this-=4; goto __CalculatorSampleActivationFactory::__cli_GetIids
    4    | &thunk: this-=4; goto __CalculatorSampleActivationFactory::__cli_GetRuntimeClassName
    5    | &thunk: this-=4; goto __CalculatorSampleActivationFactory::__cli_GetTrustLevel

    __CalculatorSampleActivationFactory::$vftable@IActivationFactory@:
        | &__CalculatorSampleActivationFactory_meta
        |  0
    0    | &__CalculatorSampleActivationFactory::__cli_QueryInterface
    1    | &__CalculatorSampleActivationFactory::__cli_AddRef
    2    | &__CalculatorSampleActivationFactory::__cli_Release
    3    | &__CalculatorSampleActivationFactory::__cli_GetIids
    4    | &__CalculatorSampleActivationFactory::__cli_GetRuntimeClassName
    5    | &__CalculatorSampleActivationFactory::__cli_GetTrustLevel
    6    | &__CalculatorSampleActivationFactory::__cli_Platform_IActivationFactory____cli_ActivateInstance
    7    | &__CalculatorSampleActivationFactory::ActivateInstance

    __CalculatorSampleActivationFactory::ActivateInstance this adjustor: 0
    __CalculatorSampleActivationFactory::__cli_QueryInterface this adjustor: 0
    __CalculatorSampleActivationFactory::__cli_AddRef this adjustor: 0
    __CalculatorSampleActivationFactory::__cli_Release this adjustor: 0
    __CalculatorSampleActivationFactory::__cli_GetIids this adjustor: 0
    __CalculatorSampleActivationFactory::__cli_GetRuntimeClassName this adjustor: 0
    __CalculatorSampleActivationFactory::__cli_GetTrustLevel this adjustor: 0
    __CalculatorSampleActivationFactory::__cli_Platform_IActivationFactory____cli_ActivateInstance this adjustor: 0

    class CalculatorSample    size(12):
        +—
        | +— (base class __ICalculatorSamplePublicNonVirtuals)
        | | +— (base class Object)
    0    | | | {vfptr}
        | | +—
        | +—
        | +— (base class Object)
    4    | | {vfptr}
        | +—
    8    | __cli_MultiThreadedRefCount __cli_refcount
        +—

    CalculatorSample::$vftable@__ICalculatorSamplePublicNonVirtuals@:
        | &CalculatorSample_meta
        |  0
    0    | &CalculatorSample::__cli_QueryInterface
    1    | &CalculatorSample::__cli_AddRef
    2    | &CalculatorSample::__cli_Release
    3    | &CalculatorSample::__cli_GetIids
    4    | &CalculatorSample::__cli_GetRuntimeClassName
    5    | &CalculatorSample::__cli_GetTrustLevel
    6    | &CalculatorSample::

    __cli_CppWinRTComponentDll___ICalculatorSamplePublicNonVirtuals____cli_Add
    7    | &CalculatorSample::Add

    CalculatorSample::$vftable@Object@:
        | -4
    0    | &thunk: this-=4; goto CalculatorSample::__cli_QueryInterface
    1    | &thunk: this-=4; goto CalculatorSample::__cli_AddRef
    2    | &thunk: this-=4; goto CalculatorSample::__cli_Release
    3    | &thunk: this-=4; goto CalculatorSample::__cli_GetIids
    4    | &thunk: this-=4; goto CalculatorSample::__cli_GetRuntimeClassName
    5    | &thunk: this-=4; goto CalculatorSample::__cli_GetTrustLevel

    CalculatorSample::Add this adjustor: 0
    CalculatorSample::__cli_QueryInterface this adjustor: 0
    CalculatorSample::__cli_AddRef this adjustor: 0
    CalculatorSample::__cli_Release this adjustor: 0
    CalculatorSample::__cli_GetIids this adjustor: 0
    CalculatorSample::__cli_GetRuntimeClassName this adjustor: 0
    CalculatorSample::__cli_GetTrustLevel this adjustor: 0
    CalculatorSample::__cli_CppWinRTComponentDll___ICalculatorSamplePublicNonVirtuals____cli_Add this adjustor: 0

    Analyzing the layout:

    Every WinRT object is laid out in the following way. The first 3 methods in the Vtable are from IUnknown and the next 3 interfaces methods are there for dynamic languages. The important one is GetRuntimeClassName and it allows JavaScript to call into .net  obtain the fully-qualified class name of the WinRT component. When JavaScript calls GetRuntimeClassName, it returns  CppWinRTComponentDll. CalculatorSample. JavaScript then goes and finds out which WinMD file in the system has the classname CppWinRTComponentDll.CalculatorSample. so Windows 8 will inform that it is inside CppWinRTComponentDll.DLL. It then loads the WinMD file of CppWinRTComponentDll.DLL and calls the Add function inside it. In C++, we don’t use these methods as we can directly interact with the class. It doesn’t do dynamic dispatch.

    0 | &CalculatorSample::__cli_QueryInterface
    1 | &CalculatorSample::__cli_AddRef
    2 | &CalculatorSample::__cli_Release

    3 | &CalculatorSample::__cli_GetIids
    4 | &CalculatorSample::__cli_GetRuntimeClassName
    5 | &CalculatorSample::__cli_GetTrustLevel

    6 | &CalculatorSample::

    __cli_CppWinRTComponentDll___ICalculatorSamplePublicNonVirtuals____cli_Add

     

    Coming to the calculator class, you notice CalculatorSample is of size 12. The first vprt we have is ICalculatorSamplePublicNonVirtuals and then we have vprt to Object and then the ref count.

    class CalculatorSample size(12):
    +—
    | +— (base class __ICalculatorSamplePublicNonVirtuals)
    | | +— (base class Object)
    0 | | | {vfptr}
    | | +—
    | +—
    | +— (base class Object)
    4 | | {vfptr}
    | +—
    8 | __cli_MultiThreadedRefCount __cli_refcount
    +—

    If we analyze the first vptr, it points to ICalculatorSamplePublicNonVirtuals. The layout of the interface is as follows. The first 3 methods are for IUnknown and the other 3 are IInspectable. Notice 6 and 7 are referencing the Add method we wrote in the DLL. There are here for a reason. No 7 is to support compile time inheritance. The C++ can directly call into C++.

    CalculatorSample::$vftable@__ICalculatorSamplePublicNonVirtuals@:
    | &CalculatorSample_meta
    | 0
    0 | &CalculatorSample::__cli_QueryInterface
    1 | &CalculatorSample::__cli_AddRef
    2 | &CalculatorSample::__cli_Release
    3 | &CalculatorSample::__cli_GetIids
    4 | &CalculatorSample::__cli_GetRuntimeClassName
    5 | &CalculatorSample::__cli_GetTrustLevel
    6 | &CalculatorSample::__cli_CppWinRTComponentDll___ICalculatorSamplePublicNonVirtuals____cli_Add
    7 | &CalculatorSample::Add

    To understand more, let us use the compiler option. right click on WinRTComponent.cpp and add /d1ZWtokens as shown below and compile the WinRTComponent.cpp class.

    image

    In the output window, search for __cli_CppWinRTComponentDll___ICalculatorSamplePublicNonVirtuals____cli_Add and see the inline code generated by the compiler. This gives us a better understanding of the inner workings of calling the WinRT components.

     

    1>—— Build started: Project: CppWinRTComponentDll, Configuration: Debug Win32 ——
    1>  WinRTComponent.cpp
    1>  Declaring Member 2: __ICalculatorSamplePublicNonVirtuals::Add (int __cdecl CppWinRTComponentDll::__ICalculatorSamplePublicNonVirtuals::Add(int,int)). [isVirtual=1 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: __ICalculatorSamplePublicNonVirtuals::__cli_Add (long __stdcall CppWinRTComponentDll::__ICalculatorSamplePublicNonVirtuals::__cli_Add(int,int,int *)). [isVirtual=1 isPure=1 isStatic=0]
    1> 
    1>  Declaring Member 4a: CalculatorSample::__cli_refcount
    1> 
    1>  Declaring Member 2: CalculatorSample::__cli_QueryInterface (long __stdcall CppWinRTComponentDll::CalculatorSample::__cli_QueryInterface(class Platform::Guid %,void **)). [isVirtual=0 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: CalculatorSample::__cli_AddRef (unsigned long __stdcall CppWinRTComponentDll::CalculatorSample::__cli_AddRef(void)). [isVirtual=0 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: CalculatorSample::__cli_Release (unsigned long __stdcall CppWinRTComponentDll::CalculatorSample::__cli_Release(void)). [isVirtual=0 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: CalculatorSample::__cli_GetIids (long __stdcall CppWinRTComponentDll::CalculatorSample::__cli_GetIids(unsigned long *,class Platform::Guid **)). [isVirtual=0 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: CalculatorSample::__cli_GetRuntimeClassName (long __stdcall CppWinRTComponentDll::CalculatorSample::__cli_GetRuntimeClassName(struct __cli_HSTRING__ **)). [isVirtual=0 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: CalculatorSample::__cli_GetTrustLevel (long __stdcall CppWinRTComponentDll::CalculatorSample::__cli_GetTrustLevel(enum __cli_TrustLevel *)). [isVirtual=0 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: CalculatorSample::__cli_CppWinRTComponentDll___ICalculatorSamplePublicNonVirtuals____cli_Add (long __stdcall CppWinRTComponentDll::CalculatorSample::__cli_CppWinRTComponentDll___ICalculatorSamplePublicNonVirtuals____cli_Add(int,int,int *)=long __stdcall CppWinRTComponentDll::__ICalculatorSamplePublicNonVirtuals::__cli_Add(int,int,int *)). [isVirtual=1 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: IActivationFactory::__cli_ActivateInstance (long __stdcall Platform::IActivationFactory::__cli_ActivateInstance(class Platform::Object ^*)). [isVirtual=1 isPure=1 isStatic=0]
    1> 
    1>  Declaring Member 2: __CalculatorSampleActivationFactory::ActivateInstance (class Platform::Object ^__thiscall CppWinRTComponentDll::__CalculatorSampleActivationFactory::ActivateInstance(void)). [isVirtual=1 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: __CalculatorSampleActivationFactory::CreateFactory (long __stdcall CppWinRTComponentDll::__CalculatorSampleActivationFactory::CreateFactory(unsigned int *,struct __cli___classObjectEntry *,class Platform::Guid %,struct __cli_IUnknown **)). [isVirtual=0 isPure=0 isStatic=1]
    1> 
    1>  Declaring Member 2: __CalculatorSampleActivationFactory::GetTargetClassName (const wchar_t *__stdcall CppWinRTComponentDll::__CalculatorSampleActivationFactory::GetTargetClassName(void)). [isVirtual=0 isPure=0 isStatic=1]
    1> 
    1>  Declaring Member 4a: __CalculatorSampleActivationFactory::__cli_refcount
    1> 
    1>  Declaring Member 2: __CalculatorSampleActivationFactory::__cli_QueryInterface (long __stdcall CppWinRTComponentDll::__CalculatorSampleActivationFactory::__cli_QueryInterface(class Platform::Guid %,void **)). [isVirtual=0 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: __CalculatorSampleActivationFactory::__cli_AddRef (unsigned long __stdcall CppWinRTComponentDll::__CalculatorSampleActivationFactory::__cli_AddRef(void)). [isVirtual=0 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: __CalculatorSampleActivationFactory::__cli_Release (unsigned long __stdcall CppWinRTComponentDll::__CalculatorSampleActivationFactory::__cli_Release(void)). [isVirtual=0 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: __CalculatorSampleActivationFactory::__cli_GetIids (long __stdcall CppWinRTComponentDll::__CalculatorSampleActivationFactory::__cli_GetIids(unsigned long *,class Platform::Guid **)). [isVirtual=0 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: __CalculatorSampleActivationFactory::__cli_GetRuntimeClassName (long __stdcall CppWinRTComponentDll::__CalculatorSampleActivationFactory::__cli_GetRuntimeClassName(struct __cli_HSTRING__ **)). [isVirtual=0 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: __CalculatorSampleActivationFactory::__cli_GetTrustLevel (long __stdcall CppWinRTComponentDll::__CalculatorSampleActivationFactory::__cli_GetTrustLevel(enum __cli_TrustLevel *)). [isVirtual=0 isPure=0 isStatic=0]
    1> 
    1>  Declaring Member 2: __CalculatorSampleActivationFactory::__cli_Platform_IActivationFactory____cli_ActivateInstance (long __stdcall CppWinRTComponentDll::__CalculatorSampleActivationFactory::__cli_Platform_IActivationFactory____cli_ActivateInstance(class Platform::Object ^*)=long __stdcall Platform::IActivationFactory::__cli_ActivateInstance(class Platform::Object ^*)). [isVirtual=1 isPure=0 isStatic=0]
    1> 
    1>  inline function header symbol: {ctor}
    1> 
    1>  {
    1> 
    1>   
    1> 
    1>  }
    1> 
    1>  inline function header symbol: {ctor}
    1> 
    1>  {
    1> 
    1>   
    1> 
    1>  }
    1>  <TokenStream>
    1> 
    1>  namespace CppWinRTComponentDll
    1> 
    1>  {
    1> 
    1>   inline int :: CppWinRTComponentDll :: __ICalculatorSamplePublicNonVirtuals :: Add ( int x , int y )
    1> 
    1>    {
    1> 
    1>      int __cli_returnValue ;
    1> 
    1>      long __hr = __cli_Add ( x , y , & __cli_returnValue ) ;
    1> 
    1>      __cli_WinRTThrowError ( __hr ) ;
    1> 
    1>      return __cli_returnValue ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>   
    1> 
    1>  }
    1>  </TokenStream>
    1> 
    1>  <TokenStream>
    1> 
    1>  namespace CppWinRTComponentDll
    1> 
    1>  {
    1> 
    1>    inline long __stdcall :: CppWinRTComponentDll :: CalculatorSample :: __cli_CppWinRTComponentDll___ICalculatorSamplePublicNonVirtuals____cli_Add ( int x , int y , int * __cli_returnValue )
    1> 
    1>    {
    1> 
    1>      long __hr = 0 ;
    1> 
    1>      * __cli_returnValue = 0 ;
    1> 
    1>      try
    1> 
    1>      {
    1> 
    1>        auto __tempValue = Add ( x , y ) ;
    1> 
    1>        * __cli_returnValue = __tempValue ;
    1> 
    1>       
    1> 
    1>      }
    1> 
    1>      catch ( :: Platform :: Exception ^ __param0 )
    1> 
    1>      {
    1> 
    1>        __hr = __param0 -> HResult ;
    1> 
    1>       
    1> 
    1>      }
    1> 
    1>      catch ( … )
    1> 
    1>      {
    1> 
    1>        __hr = -2147467259 ;
    1> 
    1>       
    1> 
    1>      }
    1> 
    1>      return __hr ;
    1> 
    1>     
    1> 
    1>    }
    1>
     
    1>   
    1> 
    1>  }
    1>  </TokenStream>
    1> 
    1>  <TokenStream>
    1> 
    1>  namespace CppWinRTComponentDll
    1> 
    1>  {
    1> 
    1>    long :: CppWinRTComponentDll :: CalculatorSample :: __cli_QueryInterface ( class Platform::Guid % __param0 , void ** __param1 )
    1> 
    1>    {
    1> 
    1>      if ( __param0 . Equals ( __uuidof ( __cli_IUnknown ) ) || __param0 . Equals ( __uuidof ( __cli_IInspectable ) ) || __param0 . Equals ( __uuidof ( struct CppWinRTComponentDll::__ICalculatorSamplePublicNonVirtuals ^ ) ) )
    1> 
    1>      {
    1> 
    1>        * __param1 = reinterpret_cast < void * > ( static_cast < struct CppWinRTComponentDll::__ICalculatorSamplePublicNonVirtuals ^ > ( this ) ) ;
    1> 
    1>        __cli_refcount . Increment ( ) ;
    1> 
    1>        return 0 ;
    1> 
    1>       
    1> 
    1>      }
    1> 
    1>      return -2147467262 ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>    unsigned long :: CppWinRTComponentDll :: CalculatorSample :: __cli_AddRef ( )
    1> 
    1>    {
    1> 
    1>      long __cli_returnValue = __cli_refcount . Increment ( ) ;
    1> 
    1>      return ( unsigned long ) __cli_returnValue ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>    unsigned long :: CppWinRTComponentDll :: CalculatorSample :: __cli_Release ( )
    1> 
    1>    {
    1> 
    1>      long __cli_returnValue = __cli_refcount . Decrement ( ) ;
    1> 
    1>      if ( ! __cli_returnValue )
    1> 
    1>      {
    1> 
    1>        delete this ;
    1> 
    1>        :: Platform :: Heap :: Free ( reinterpret_cast < void * > ( this ) ) ;
    1> 
    1>       
    1> 
    1>      }
    1> 
    1>      return ( unsigned long ) __cli_returnValue ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>    long :: CppWinRTComponentDll :: CalculatorSample :: __cli_GetIids ( unsigned long * __param0 , class Platform::Guid ** __param1 )
    1> 
    1>    {
    1> 
    1>      struct __s_GUID __interfaceList [ ] =
    1> 
    1>      {
    1> 
    1>       
    1> 
    1>        {
    1> 
    1>          -1302793136 , 5274 , 13110 , 160 , 43 , 249 , 241 , 108 , 73 , 159 , 212
    1> 
    1>        }
    1> 
    1>       
    1> 
    1>      } ;
    1> 
    1>     
    1> 
    1>      return __winRT :: __winRTRuntime . __getIids ( 1 , __param0 , __interfaceList , __param1 ) ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>    long :: CppWinRTComponentDll :: CalculatorSample :: __cli_GetRuntimeClassName ( struct __cli_HSTRING__ ** __param0 )
    1> 
    1>    {
    1> 
    1>      return __winRT :: __winRTRuntime . __windowsCreateString ( ( const wchar_t * ) L"CppWinRTComponentDll.CalculatorSample" , 37 , __param0 ) ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>    long :: CppWinRTComponentDll :: CalculatorSample :: __cli_GetTrustLevel ( enum __cli_TrustLevel * __param0 )
    1> 
    1>    {
    1> 
    1>      * __param0 = __cli_FullTrust ;
    1> 
    1>      return 0 ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>   
    1> 
    1>  }
    1>  </TokenStream>
    1> 
    1>  <TokenStream>
    1> 
    1>  namespace Platform
    1> 
    1>  {
    1> 
    1>    inline class Platform::Object ^ :: Platform :: IActivationFactory :: ActivateInstance ( )
    1> 
    1>    {
    1> 
    1>      class Platform::Object ^ __cli_returnValue ;
    1> 
    1>      long __hr = __cli_ActivateInstance ( & __cli_returnValue ) ;
    1> 
    1>      __cli_WinRTThrowError ( __hr ) ;
    1> 
    1>      return __cli_returnValue ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>   
    1> 
    1>  }
    1>  </TokenStream>
    1> 
    1>  <TokenStream>
    1> 
    1>  namespace CppWinRTComponentDll
    1> 
    1>  {
    1> 
    1>    inline long __stdcall :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory :: __cli_Platform_IActivationFactory____cli_ActivateInstance ( class Platform::Object ^* __cli_returnValue )
    1> 
    1>    {
    1> 
    1>      long __hr = 0 ;
    1> 
    1>      * __cli_returnValue = nullptr ;
    1> 
    1>      try
    1> 
    1>      {
    1> 
    1>        auto __tempValue = ActivateInstance ( ) ;
    1> 
    1>        * __cli_returnValue = __tempValue ;
    1> 
    1>       
    1> 
    1>      }
    1> 
    1>      catch ( :: Platform :: Exception ^ __param0 )
    1> 
    1>      {
    1> 
    1>        __hr = __param0 -> HResult ;
    1> 
    1>       
    1> 
    1>      }
    1> 
    1>      catch ( … )
    1> 
    1>      {
    1> 
    1>        __hr = -2147467259 ;
    1> 
    1>       
    1> 
    1>      }
    1> 
    1>      return __hr ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>   
    1> 
    1>  }
    1>  </TokenStream>
    1> 
    1>  <TokenStream>
    1> 
    1>  namespace CppWinRTComponentDll
    1> 
    1>  {
    1> 
    1>    long :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory :: __cli_QueryInterface ( class Platform::Guid % __param0 , void ** __param1 )
    1> 
    1>    {
    1> 
    1>      if ( __param0 . Equals ( __uuidof ( __cli_IUnknown ) ) || __param0 . Equals ( __uuidof ( __cli_IInspectable ) ) || __param0 . Equals ( __uuidof ( struct Platform::IActivationFactory ^ ) ) )
    1> 
    1>      {
    1> 
    1>        * __param1 = reinterpret_cast < void * > ( static_cast < struct Platform::IActivationFactory ^ > ( this ) ) ;
    1> 
    1>        __cli_refcount . Increment ( ) ;
    1> 
    1>        return 0 ;
    1> 
    1>       
    1> 
    1>      }
    1> 
    1>      return -2147467262 ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>    unsigned long :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory :: __cli_AddRef ( )
    1> 
    1>    {
    1> 
    1>      long __cli_returnValue = __cli_refcount . Increment ( ) ;
    1> 
    1>      return ( unsigned long ) __cli_returnValue ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>    unsigned long :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory :: __cli_Release ( )
    1> 
    1>    {
    1> 
    1>      long __cli_returnValue = __cli_refcount . Decrement ( ) ;
    1> 
    1>      if ( ! __cli_returnValue )
    1> 
    1>      {
    1> 
    1>        delete this ;
    1> 
    1>        :: Platform :: Heap :: Free ( reinterpret_cast < void * > ( this ) ) ;
    1> 
    1>       
    1> 
    1>      }
    1> 
    1>      return ( unsigned long ) __cli_returnValue ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>    long :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory :: __cli_GetIids ( unsigned long * __param0 , class Platform::Guid ** __param1 )
    1> 
    1>    {
    1> 
    1>      struct __s_GUID __interfaceList [ ] =
    1> 
    1>      {
    1> 
    1>       
    1> 
    1>        {
    1> 
    1>          53 , 0 , 0 , 192 , 0 , 0 , 0 , 0 , 0 , 0 , 70
    1> 
    1>        }
    1> 
    1>       
    1> 
    1>      } ;
    1> 
    1>     
    1> 
    1>      return __winRT :: __winRTRuntime . __getIids ( 1 , __param0 , __interfaceList , __param1 ) ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>    long :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory :: __cli_GetRuntimeClassName ( struct __cli_HSTRING__ ** __param0 )
    1> 
    1>    {
    1> 
    1>      return __winRT :: __winRTRuntime . __windowsCreateString ( ( const wchar_t * ) L"CppWinRTComponentDll.__CalculatorSampleActivationFactory" , 56 , __param0 ) ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>    long :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory :: __cli_GetTrustLevel ( enum __cli_TrustLevel * __param0 )
    1> 
    1>    {
    1> 
    1>      * __param0 = __cli_FullTrust ;
    1> 
    1>      return 0 ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>   
    1> 
    1>  }
    1>  </TokenStream>
    1> 
    1>  <TokenStream>
    1> 
    1>  namespace CppWinRTComponentDll
    1> 
    1>  {
    1> 
    1>    class Platform::Object ^ :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory :: ActivateInstance ( )
    1> 
    1>    {
    1> 
    1>      return gcnew class CppWinRTComponentDll::CalculatorSample ( ) ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>   
    1> 
    1>  }
    1>  </TokenStream>
    1> 
    1>  <TokenStream>
    1> 
    1>  namespace CppWinRTComponentDll
    1> 
    1>  {
    1> 
    1>    long __stdcall :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory :: CreateFactory ( unsigned int * , struct __cli___classObjectEntry * , class Platform::Guid % __param2 , struct __cli_IUnknown ** __param3 )
    1> 
    1>    {
    1> 
    1>      class CppWinRTComponentDll::__CalculatorSampleActivationFactory ^ __pActivationFactory = gcnew :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory ( ) ;
    1> 
    1>      return __pActivationFactory -> __cli_QueryInterface ( __param2 , reinterpret_cast < void ** > ( __param3 ) ) ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>    const wchar_t * __stdcall :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory :: GetTargetClassName ( )
    1> 
    1>    {
    1> 
    1>      return L"CppWinRTComponentDll.CalculatorSample" ;
    1> 
    1>     
    1> 
    1>    }
    1> 
    1>   
    1> 
    1>  }
    1>  </TokenStream>
    1> 
    1>  <TokenStream>
    1> 
    1>  namespace CppWinRTComponentDll
    1> 
    1>  {
    1> 
    1>    const struct __cli___classObjectEntry __CalculatorSampleActivationFactory_Registration =
    1> 
    1>    {
    1> 
    1>      :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory :: CreateFactory , :: CppWinRTComponentDll :: __CalculatorSampleActivationFactory :: GetTargetClassName , nullptr , & __cli_no_factory_cache , nullptr
    1> 
    1>    } ;
    1> 
    1>   
    1> 
    1>    extern "C" __declspec ( allocate ( "minATL$__r" ) ) __declspec ( selectany ) const :: __cli___classObjectEntry * const CppWinRTComponentDll___CalculatorSampleActivationFactory__Entry = & __CalculatorSampleActivationFactory_Registration ;
    1> 
    1>   
    1> 
    1>  }
    1>  </TokenStream>
    1> 
    ========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

     

    The complete code of MainPage.xaml.cpp is as follows.

    Code Snippet
    //
    // MainPage.xaml.cpp
    // Implementation of the MainPage.xaml class.
    //

    #include "pch.h"
    #include "MainPage.xaml.h"

    using namespace Windows::UI::Xaml;
    using namespace Windows::UI::Xaml::Controls;
    using namespace Windows::UI::Xaml::Data;
    using namespace CPPApplication1;

    using namespace CppWinRTComponentDll;

    MainPage::MainPage()
    {
        InitializeComponent();

        CalculatorSample^ calcobj = ref new  CalculatorSample();
        //txtAddResult->Text = calcobj->Add(10,20).ToString();

        //// declare a stack variable to hold the value of the result
        int result;
        //call into  calc object low level __cli_Add() but no intellisense in this preview
        //HRESULT hr = calcobj->__cli_Add(10,20,&result);

        //create a c function that actually represent an ABI call we will be making
        //to add function which takes this pointer, 2 input parameters and an out parameter.
        typedef HRESULT (__stdcall* AddFunc_t) (CalculatorSample^ calc, int i, int j, int * result);
        //now we can take the calculator^ object, which is a pointer to a pointer to a vtable
        //and reinterpret cast it so that it can say ok now i have a pointer of  virtual function
        //which are vtables and i am going to specifically pick the sixth function of that and call into it.
        //reinterpret_cast takes the calcobj ^ and cast it to a pointer to a pointer
        AddFunc_t* addFunc = *reinterpret_cast<AddFunc_t**>(calcobj);
        addFunc[6](calcobj,10,20, &result);

        ////CalculatorSample^ calcobj = ref new CalculatorSample();
        ////int* vtable_array = (int*)calcobj;
        ////int* icalc_vtable = (int*)vtable_array[0];
        ////int* compute_will_be_fptr = (int*)icalc_vtable[6];
        ////typedef HRESULT (__stdcall *compute_fptr_t)(CalculatorSample^, int, int, int*);
        ////compute_fptr_t compute_fptr = (compute_fptr_t)compute_will_be_fptr;
        ////compute_fptr(calcobj,10,20, &result);

        txtAddResult->Text = result.ToString();
    }

    MainPage::~MainPage()
    {
    }

     

    Download the source code from here.

    "If you limit your choices only to what seems possible or reasonable, you disconnect yourself from what you truly want, and all that is left is a compromise."

    Under the hood Part 5 : JavaScript application & C++ WinRT Component DLL – WinRT, Windows 8, C++, Metro

    JavaScript application calling WinRT Component DLL

    In this part, we will create a C++ WinRT Component DLL and access it from a JavaScript application.

    We have developed a C++ WinRT Component DLL & C#.NET application in the post here Under the hood Part 1 : C++ WinRT Component DLL & C#.NET Metro application

    we have seen the compiler generated components for making the C# application access the C++ WinRT component here Under the hood Part 2 : C++ WinRT Component DLL & C#.NET Metro application

    We have seen the packaging and installation process that happens in the background during building and deploying of the applications here Under the hood Part 3 : WinRT, Windows 8, C++, C#.NET, Metro, WinRT Component DLL

    We have seen the C++ XAML application calling the C++ WinRT Component DLL here Under the hood Part 4 : C++ WinRT Component DLL & C++ XAML application – WinRT, Windows 8, C++, Metro

    Generally, in a LOB application, we might have to build a C++ Component DLL to take advantage of the performance of C++ in complex or computationally-intensive operations. The C++ component can access Windows operating system services that are not accessible through the Windows Runtime in the current version. Mostly, to reuse existing code that is already written and tested.

    Download the source code here.

    Step 1:

    Create a Windows Runtime C++ Component DLL:

    Open Visual Studio 2011 –> File –> New Project –> Go to Installed Templates section –> Visual C++ –>Select WinRT Component DLL and name it as CPPWinRTComponentDll as shown in the following figure.

    image

    Fig 1: CPPWinRTComponentDll project

    Open WinRTComponent.h file and create an Employee class as shown in the following code snippet. The Platform namespace is where C++ defines its classes that are specific Windows Runtime types.

    Create a private variables address_ and employeeid_. These are used as backing store to hold the values. We will use get() & set() properties to set or get these values.

        private:
                // Backing store for property address_ & employeeid_.
                Platform::String^ address_;
                int employeeid_;

     

    In the public section, add the following code which are properties for the above backing store.

            property Platform::String^ Address
            {
                Platform::String^ get()
                {
                    return  (address_);
                }
            }

            // Property with custom setter/getter
            property int EmployeeId
            {
                int get()
                {
                    return employeeid_;
                }

                //    ‘set’ accessor is missing its value parameter
                void set(int value)
                {
                    if(value <= 0)
                    {
                        throw ref new Platform::InvalidArgumentException();
                        employeeid_ = value;
                    }
                }
            }

     

    We can also add some trivial get/set property with the compiler generating the backing store.

        public:
            // Trivial get/set property with compiler-generated backing store.
            property Platform::String^ Name;

     

    Following is the complete code of the Employee class.

    Code Snippet
    public ref class Employee sealed
        {
        private:
                Platform::String^ address_;
                int employeeid_;
               
                //If i use a stack syntax, i get compilation error
                //Platform::String address2_;
                //Error    1    error C3149: ‘Platform::String’ : cannot use this type here without a top-level ‘^’   
                //c:\projects\cppwinrtcomponentdll with cpp app string\cppwinrtcomponentdll\winrtcomponent.h   

        public:

            property Platform::String^ Name;
            property Platform::String^ Address
            {
                Platform::String^ get()
                {
                    return  (address_);
                }
            }

            property int EmployeeId
            {
                int get()
                {
                    return employeeid_;
                }

                //    ‘set’ accessor is missing its value parameter
                void set(int value)
                {
                    if(value <= 0)
                    {
                        throw ref new Platform::InvalidArgumentException();
                        employeeid_ = value;
                    }
                }
            }

        public:
            Platform::String^ SayHello()
            {
                return "Hello World";
            }

        public:
            int Add(int x, int y)
            {
                return x+y;
            }

        };

     

    When you code your C++ component, if needed, you can use the regular C++ library and built-in types inside the class code except at the abstract binary interface (ABI) boundary where you are passing data to and from JavaScript. There, use Windows Runtime types and the special syntax that Visual C++ supports for creating and manipulating those types.

    You have to make the Employee class as activatable class so that it can instantiated from another language such as JavaScript. To be consumable from another language such as JavaScript, a component must contain at least one activatable class. If needed, a Windows Runtime component can contain multiple activatable classes as well as additional classes known only internally to the component. Client code creates an instance of the component by using the new keyword just as for any class.

    The Employee class must be declared as public ref class sealed. The ref class keywords tell the compiler to create the class as a Windows Runtime compatible type, and the sealed keyword specifies that the class cannot be inherited. A class must be sealed to be consumed by JavaScript.

    In the Platform::String^ address_, the ^ operator signifies a handle to a Windows Runtime string type that under the covers is reference-counted and deleted when the count reaches zero. Instances of these types are created by using the ref new keywords. Do not explicitly call delete on these instances.

    Types must be passed to and from the public methods as Windows Runtime types. If you use the C++ built-in types such as int, double and so on, the compiler will automatically convert them to the appropriate Windows Runtime type. No such conversion occurs unless you are passing the type across the ABI. Complex types such as Platform::String^ must be specified explicitly.

    Step 2:

    Creating a JavaScript Windows Metro style Application project:

    To create a project in this solution, right-click the solution node in Solution Explorer. and select Add Project > Blank Application. Name it as WinWebApp1.

    image

    Fig 2: creating the JavaScript project
    Add a reference to the component project

    After you have compiled the C++ project for the first time, you can add it as a project reference in the JavaScript project. Right-click the References node in the JavaScript project, and select Add. When the Add References Manager dialog box appears, click “Solution” to display the available references in the solution. Select  “CPPWinRTComponentDll ” in this solution and click on Add button as shown in figure 3; The namespace and all public types and methods are now available to your JavaScript code. You can verify this by experimenting with the Member List or Statement Completion feature in the JavaScript file.

    image

    Fig 3: Adding reference to the C++ WinRT Component DLL.
    Add the HTML markup that invokes JavaScript.

    Add the following HTML into the <body> node of the default.html page

    <body>
        <button id="callwinrt" onclick="CallWinRT()">Call WinRT</button>
    <p></p>
        <label id ="Label1" style="background-color: grey;">Activation Object Result ->  </label><label id ="loaded" style="background-color: #51B65A;"></label>
        <p></p>
         <label id ="Label2" style="background-color: grey;">Calling Employee::SayHello() method     </label><label id ="callmethod" style="background-color: #51B65A;"></label>
        <p></p>
         <label id ="Label3" style="background-color: grey;" >Getting  Employee.Name Property value    </label><label id ="retrievedproperty" style="background-color: #51B65A;"></label>
        <p></p>

    </body>

     

    The default.html page appears as following.

    Code Snippet
    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="utf-8" />
        <title>WinWebApp1</title>
        <!– WinJS references –>
        <link rel="stylesheet" href="/winjs/css/ui-dark.css" />
        <script src="/winjs/js/base.js"></script>
        <script src="/winjs/js/wwaapp.js"></script>
        <!– WinWebApp1 references –>
        <link rel="stylesheet" href="/css/default.css" />
        <script src="/js/default.js"></script>
    </head>
    <body>
        <button id="callwinrt" onclick="CallWinRT()">Call WinRT</button>
    <p></p>
        <label id ="Label1" style="background-color: grey;">Activation Object Result ->  </label><label id ="loaded" style="background-color: #51B65A;"></label>
        <p></p>
         <label id ="Label2" style="background-color: grey;">Calling Employee::SayHello() method     </label><label id ="callmethod" style="background-color: #51B65A;"></label>
        <p></p>
         <label id ="Label3" style="background-color: grey;" >Getting  Employee.Name Property value    </label><label id ="retrievedproperty" style="background-color: #51B65A;"></label>
        <p></p>

    </body>
    </html>

     

    Add the JavaScript event handlers that call into the component DLL

    Add the following function CallWinRT() at the end of the default.js file. This function is called when you click the button “Call WinRT” on the main page. Notice how JavaScript activates the C++ class, and then calls its methods and populates the HTML labels with the return values.

    function CallWinRT() {
        // activate the native Windows Runtime component
        var nativeObject = new CppWinRTComponentDll.Employee();
        document.getElementById(‘loaded’).innerHTML = nativeObject;

        //call a method
        var num = nativeObject.sayHello();
        document.getElementById(‘callmethod’).innerHTML = num;

        nativeObject.name = "Kishore Babu";

        // get the value of the string property
        var propValue = nativeObject.name;
        document.getElementById(‘retrievedproperty’).innerHTML = propValue;
    }

     

    The complete code of default.js file is as follows.

    Code Snippet
    (function () {
        ‘use strict’;
        // Uncomment the following line to enable first chance exceptions.
        // Debug.enableFirstChanceException(true);

        WinJS.Application.onmainwindowactivated = function (e) {
            if (e.detail.kind === Windows.ApplicationModel.Activation.ActivationKind.launch) {
                // TODO: startup code here
            }
        }

        WinJS.Application.start();
    })();

    function CallWinRT() {
        // activate the native Windows Runtime component
        var nativeObject = new CppWinRTComponentDll.Employee();
        document.getElementById(‘loaded’).innerHTML = nativeObject;

        //call a method
        var num = nativeObject.sayHello();
        document.getElementById(‘callmethod’).innerHTML = num;

        nativeObject.name = "Kishore Babu";

        // get the value of the string property
        var propValue = nativeObject.name;
        document.getElementById(‘retrievedproperty’).innerHTML = propValue;
    }

     

    Build the solution & deploy the application. If you go to start window, you will find an application WinWebApp1. Click on it.

    image

    Click on call WinRT button. The values from the C++ DLL are returned and set in the JavaScript application as shown in the following figure.

    image

    When you build a solution that contains a JavaScript project and a Windows Runtime Component DLL project, the JavaScript project files and the compiled DLL are merged into one package, which you can then deploy locally or remotely for testing or submit to the Windows Store. You can also distribute just the component project as an Extension SDK.

    Debugging: When you debug a JavaScript solution that has a component DLL, you can set the debugger to enable either stepping through script, or stepping through native code in the component, but not both at the same time. To change the setting, right-click the JavaScript project node in Solution Explorer, then select Properties > Debugging > Debugger Type.

    Be sure to select appropriate capabilities in the package designer. For example, if you are attempting to open a file using the Windows Runtime APIs, be sure to select the Document Library Access checkbox in the Capabilities pane of the package designer.

    Download the source code here.

    As a C++ developer, I find this useful. If you are a C++ developer and new to JavaScript, you sometimes make the mistake of not using the camel-casing in JS. If your JavaScript code does not seem to be recognizing the public properties or methods in the component, make sure that in JavaScript you are using camel-casing. For example, the Platform::String^ SayHello() C++ method must be referenced as sayHello() in JavaScript.

    "The task of the leader is to get his people from where they are to where they have not been." — Henry Kissinger

    Under the hood Part 4 : C++ WinRT Component DLL & C++ XAML application – WinRT, Windows 8, C++, Metro

    Calling WinRT Component from C++

    We have developed a C++ WinRT Component DLL & C#.NET application in the post here Under the hood Part 1 : C++ WinRT Component DLL & C#.NET Metro application

    we have seen the compiler generated components for making the C# application access the C++ WinRT component here Under the hood Part 2 : C++ WinRT Component DLL & C#.NET Metro application

    We have seen the packaging and installation process that happens in the background during building and deploying of the applications here Under the hood Part 3 : WinRT, Windows 8, C++, C#.NET, Metro, WinRT Component DLL

    Going further, I created a C++ Metro application and accessed the C++ WinRT Component DLL from this application. The interesting part here is that C++ applications is XAML based. No more .RC and resource.h files in C++ (for metro). In the previous post, we created a WinRT C++ DLL that contains a class calculatorSample. Now let us create  a C++ application to consume the C++ WinRT DLL.

    To get started with creating a C++ XAML application, go to Visual Studio 2011 –> Solution Explorer–> New Project –> Go to Installed Templates section –> Visual C++ –>Select Application and name it as CPPApplication1 as shown in the following fig 1.

    image

    Fig 1: Creating a C++ XAML application.

    Right click on the project, click on Add References and the following dialog shown in figure 2 comes up.

    image

    Fig 2: Reference manager dialog to add references to another components.

    Click on Solution section –> Projects and Select  CppWinRTComponentDLL –> click on Add button and click on Close as shown in figure 3.

    image

    Fig 3: Selecting WinRT CppWinRTComponentDLL.

    The CppWinRTComponentDLL reference appears in the References section as shown in the following figure 4.

    image

    Fig 4: CppWinRTComponentDLL dll appears in the References section.

    Goto MainPage.xaml.cpp and include the namespace for CppWinRTComponentDLL

    Code Snippet
    using namespace CppWinRTComponentDll;

     

    Then create an object of calculatorSample on the heap using ref new. In this scenario, ref new  is like cocreateinstance of COM. It’s a smart allocator. we also use ref class to indicate the authoring of a Windows Runtime class . using ^ to represent a “refcounted” pointer in ZW fits quite well

    The following code shows how to use the ref new expression to create a new reference-counted Windows Runtime object. Note that you use the ^ (“hat”) symbol instead of the pointer dereference operator (*) when declaring the variable, but that you use the familiar -> operator to access the objects instance members. Note also that you do not call delete explicitly on the object. The object will be destroyed deterministically when the last remaining copy of it goes out of scope. At the lowest level, the object is basically a COM object owned by a smart pointer.

    Code Snippet
    CalculatorSample^ calcobj = ref new  CalculatorSample();
    txtAddResult->Text = calcobj->Add(10,20).ToString();

     

    So from the C++ application, we are calling the C++ Windows Runtime Component DLL. This is all native code. C++ calling C++ and everything is ref counted.

    Compiler options: /ZW enable WinRT language extensions /AI<dir> add to assembly search path <dir> is the folder where the compiler searches the winmd files /FU<file> forced using assembly/module force the inclusion of the specified winmd file /D "WINAPI_FAMILY=2" set this define to compile against the ModernSDK subset of Win32

    Linker options: /APPCONTAINER[:NO] marks the executable as runnable in the appcontainer (only) /WINMD[:{NO|ONLY}] emits a winmd; if “ONLY” is specified, does not emit the executable, but just the winmd /WINMDFILE:filename name of the winmd file to emit /WINMDDELAYSIGN[:NO] /WINMDKEYCONTAINER:name /WINMDKEYFILE:filename used to sign the winmd file

    However, in a Metro style app or Windows Runtime component, all the C++ code is native. The /ZW compiler option causes the Component Extensions to be compiled for Windows Runtime. The /cli compiler option causes them to be compiled for C++/CLI. Currently, C++/CLI is not supported for Metro style apps

    Code snippet of the complete MainPage class.

    Code Snippet
    //
    // MainPage.xaml.cpp
    // Implementation of the MainPage.xaml class.
    //

    #include "pch.h"
    #include "MainPage.xaml.h"

    using namespace Windows::UI::Xaml;
    using namespace Windows::UI::Xaml::Controls;
    using namespace Windows::UI::Xaml::Data;
    using namespace CPPApplication1;

    using namespace CppWinRTComponentDll;

    MainPage::MainPage()
    {
        InitializeComponent();

          CalculatorSample^ calcobj = ref newCalculatorSample();
        txtAddResult->Text = calcobj->Add(10,20).ToString();

        int result;
        HRESULT hr = calcobj->__cli_Add(20,30,&result);
        txtAddResult->Text = result.ToString();
    }

    MainPage::~MainPage()
    {
    }

    All Windows Runtime types derive from the universal base class Platform::Object. There is therefore an implicit conversion from any Windows Runtime object to Platform::Object.

    Code snippet of the XAML page.

    Code Snippet
    <UserControl x:Class="CPPApplication1.MainPage"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml&quot;
        xmlns:d="http://schemas.microsoft.com/expression/blend/2008&quot;
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006&quot;
        mc:Ignorable="d"
        d:DesignHeight="768" d:DesignWidth="1366">
        
        <Grid x:Name="LayoutRoot" Background="#FF0C0C0C">
            <TextBox x:Name="txtAddResult" HorizontalAlignment="Left" Text="TextBox" VerticalAlignment="Top" Margin="343,90,0,0" Width="212"/>
            <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" Text="Calling C++ component Add method from C++ XAML Application" VerticalAlignment="Top" Margin="81,90,0,0" Height="45" Width="258" FontSize="14" FontWeight="Bold"/>

        </Grid>
        
    </UserControl>

     

    Build the solution and deploy the application. The application output is as follows.image

    Configuration settings:

    Enable Windows Runtime Extensions enables the runtime extensions throughout the type system which includes the ability to do Boxing. I.e. Boxing to WinRT type system. Every fundamental types and WinRT types are derived from Platform.Object.image

    heap-allocated objects with heap semantics:

    Calculator^ calc = ref new Calculator(); // Calculator is a ref class from a custom WinRT component

    txtResult->Text = calc->Add(10, 20).ToString();

    The ^syntax will fire a destructor when the refcount on the object drops to 0, or if you explicitly call delete. (So if you handed the object out it’s not necessarily at the end of your scope)

    heap-allocated objects with Stack semantics:

    Calculator calc;

    txtResult->Text = calc.Add(10, 20).ToString();

    Both of those create heap-allocated objects behind the scenes, but the difference is whether you logically have heap semantics vs. stack semantics.

    The stack syntax will fire a destructor when the object goes out of scope (or on an exception etc.). This is important when you e.g. handed of the object to another thread or async callback, so there may still be a refcount on it, but you need to get rid of it right away. (E.g. a file handle that needs to be closed otherwise the file is locked). The main advantage is exception-safe deterministic destruction.

    PS: Because of the nature of refcounting, it’s a little bit less important with WinRT to have deterministic destruction than with e.g. the /clr and a garbage collected heap (where the point of destruction is virtually random). However, you will find that with async patterns it is common to get into a situation where you’re transfer the ownership of an object from one thread to another (e.g. via a lambda). There is then a race condition between the two threads for releasing the object. This is generally still ok, but if the object represents a file or other exclusive resource it might be critical to perform the destruction at a specific time, rather than relying on the timing between the two threads.

    value classes & Ref classes

    Int32 x(15); // Compiles and x is initialized and works as expected.

    String str("test1"); // Doesn’t compile and compiler complains C3149: ‘Platform::String’ : cannot use this type here without a top-level ‘^’

    Int32 is a value class, and String or the custom winRT component are all ref class. They are different.

    Differences between C++/CLI and WinRT C++

    In terms of the differences like flags are as follows.

    Basic types:
    /clr: From mscorlib.dll (System::* types)
    /ZW: From vccorlib.dll (Platform::* types)

    Lifetime management:
    /clr: Garbage collected
    /ZW: Refcounted

    Cycles Broken:
    /clr: By garbage collector
    /ZW: Broken by user (weak references or explicit delete)

    Code generation:
    /clr: MSIL + native code. Can create a cross-platform binary if MSIL-only.
    /ZW: Native code only. Binaries target a specific platform.

    Object Creation:
    /clr: gcnew
    /ZW: ref new

    interior_ptr:
    /clr: Supported
    /ZW: Not supported

    pin_ptr:
    /clr: Supported
    /ZW: Not supported

    V% (% when it refers to a byref (kind’a like an "interior_ref") ):
    /clr: Supported
    /ZW: Not supported

    R% (% when it refers to an implicitly dereferenced ref type):
    /clr: Supported
    /ZW: Supported

    Ref to ^:
    /clr: R^%
    /ZW: R^&

    Boxing:
    /clr: syntax V^
    /ZW: IReference<V>^

    Dereferenced box type:
    /clr: V%
    /ZW: const V

    Generics:
    /clr: Generics classes, interfaces & delegates allowed.
    /ZW: Generic interfaces & delegates only.

    Static constructors:
    /clr: Supported
    /ZW: Not supported

    Address of member of ref class:
    /clr: Returns an interior_ptr
    /ZW: Returns a type*

    friends:
    /clr: Not supported
    /ZW: Supported

    C++ class embedded in ref class:
    /clr: Not supported
    /ZW: Supported

    ref class embedded in C++ class:
    /clr: Not supported
    /ZW: Supported (R-on-stack)

    ^ embedded in C++ class:
    /clr: Not supported (Needs GCHandle)
    /ZW: Supported

    ^ embedded in value class with value class on native heap:
    /clr: Not supported
    /ZW: Supported (for String^)

    Global ^:
    /clr: Not supported
    /ZW: Supported

    Global R-on-stack:
    /clr: Not supported
    /ZW: Supported

    Finalizer:
    /clr: Supported
    /ZW: Not supported

    Destructor:
    /ZW: Runs on IDisposable::Dispose (delete / stack unwind) only
    /clr: Runs on IDisposable::Dispose (delete / stack unwind) -or- last release (never both)

    T::typeid:
    /clr: Supported
    /ZW: Not supported

    R-on-stack (ref class on stack) syntax is supported on C++/cli and C++/CX, but you’ll notice that unfortunately the /CX implementation in the developer preview release has a code generation bug that will make it impractical to test this right now. (R^ and R% should be fine though). The most important reason for R-on-stack is exception-safe destruction (Like ‘using’ gives you in C#) – other than that it is purely compiler syntactic sugar.

    Download the source code here.

    "If one advances confidently in the direction of his dreams, and endeavors to live the life which he has imagined, he will meet with success unexpected in common hours." — Henry David Thoreau