Spring 2006 Connections Conference Template

Download Report

Transcript Spring 2006 Connections Conference Template

VWV301
From Design to Deployment: What
You Need to Know to Optimize
Your Applications for Microsoft
Windows Vista
Tim Huckaby
InterKnowlogy, CEO
Microsoft RD & MVP
About…
• InterKnowlogy (www.InterKnowlogy.com)
●
●
●
●
●
Tim Huckaby, CEO - ([email protected])
Custom App Dev / Consulting / Software & Systems Engineering
Firm headquartered in Carlsbad, CA
Microsoft Gold Partner managed in SoCal and Redmond
Design, Architect, Build and Deploy enterprise class applications
Industry Experts:
•
•
•
•
•
•
90% of the company is published
Microsoft .NET Application development for 5+ years!
Microsoft .NET Smart Client pioneers / industry leaders
Information Worker Solutions
Integration / Messaging, B2B / B2C, Wireless / Mobility
Microsoft BizTalk Web Services, Microsoft Active Directory, Security, SSO,
Authorization, Authentication
• Solutions on the emerging Microsoft servers
• Largest Client: Microsoft
A Lot to Cover in One Hour…
Windows Presentation Foundation
User Experience – Sidebar Gadgets, not controls or search/thumbnails
Interoperability and Migration
Reliability
Connected Systems – WCF, but not RSS
Call to Action
Sidebar Gadget Development
Sidebar Gadget Development
• Gadgets pre-installed with windows sidebar
• Windows sidebar and gadgets architecture
•
•
•
An application which allows users to displays gadgets on the sidebar itself and on
the Windows desktop.
Supports for a number of user configuration options, including remaining behind
other windows and being hidden completely.
The sidebar is also the method by which users manage gadgets through a Gadget
gallery.
• Installed Locally
•
•
•
All gadgets for Windows Sidebar reside on a users’ computer.
Acquired by downloads, emails, or when an application installs a gadget, etc.
.gadget file: double-click to “install” the gadget
Sidebar Gadget Development
• Multiple Instances
•
•
•
the ability to be started multiple times
possible because the gadget platform provides methods for developers to store
settings, and associates settings with the correct instance of each gadget
automatically.
gadgets also run automatically and with the same settings when the user logs out
or restarts their computer.
• User Interaction
•
•
Each gadget has the ability to respond to user interaction.
Developers can respond to these events through script by changing the gadget’s
appearance as necessary.
How Gadgets Work
• Each gadget is developed using HTML and script
• Gadgets also have access to extra information about itself and
Windows when the HTML is run as a gadget.
•
•
•
This allows a gadget to interact with Windows files and folders
Displaying settings dialogs and storing those settings is also possible by using
script.
Very complex and rich gadgets are possibly using only script without using other
binary objects.
How Gadgets Work – Gadget Files
Gadget files - A gadget contains the following files:
Type
Description
Gadget Manifest
An XML file defining the gadget properties, including name, icon and
description
HTML file
Defines the core code for the gadget
HTML settings file
Exposes gadget settings for the user to change
Images, Script and Style
Sheets
For use in the HTML
Icon
For use in the gadget picker
Creating a Gadget
•
•
•
•
•
•
Create a directory to contain the gadget files.
Create an HTML page that does something interesting
Create the XML file for the gadget manifest
Zip it all up and Rename it *.gadget
Right Click and install the Gadget
Test the newly-created gadget from sidebar.
• Your Gadgets Folder:
• “%userprofile%\AppData\Local\Microsoft\Windows Sidebar\Gadgets”
• C:\Users\timh.IK\AppData\Local\Microsoft\Windows Sidebar\Gadgets
Resources
Microsoft Windows Sidebar: Latest news and product information
http://www.microsoftgadgets.com/
Microsoft Developer’s Network (MSDN): For announcements of new Microsoft technology.
http://msdn.microsoft.com
HTML and Script development
http://msdn.microsoft.com/library/en-us/dnanchor/html/anch_webdev.asp
Gadget Development Overview
http://microsoftgadgets.com/Sidebar/DevelopmentOverview.aspx#introduction
Objectives And Agenda
Restart and Recovery APIs in Windows Vista
Automatic Restart after a Crash
Recovering Auto saved Information after a Crash
Application Crashes are a Drag…
Leveraging the R&R APIs in
Windows Vista
• To create an application that autosaves
while crashing, and autorestarts after
crash, you need to do three things:
1. Register with the operating system for autorestart and
autorecover
2. Write code to save volatile data during a crash
3. Write code to read and use saved data when restarting
after a crash
Registering with the Operating
System
• Good Practice: Prevent Unhandled Exceptions from being
seen by the user
Add a line very early in the Application to set the unhandled exception mode to
“throw exception”.
In Program.cs, before the form is constructed, is a good place for this:
Application.SetUnhandledExceptionMode(
UnhandledExceptionMode.ThrowException);
Registering with the Operating
System
• The restart and recovery APIs are unmanaged code
• Access them through P/Invoke using the DllImport
keyword
The declarations of the APIs go at the top of the form class:
[DllImport("kernel32.dll")]
static extern uint RegisterApplicationRecoveryCallback(IntPtr
pRecoveryCallback, IntPtr pvParameter, int dwPingInterval, int dwFlags);
[DllImport("kernel32.dll")]
static extern uint ApplicationRecoveryInProgress(out bool pbCancelled);
[DllImport("kernel32.dll")]
static extern uint ApplicationRecoveryFinished(bool bSuccess);
delegate int ApplicationRecoveryCallback(IntPtr pvParameter);
[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
static extern uint RegisterApplicationRestart(string pszCommandline, int
dwFlags);
Registering with the Operating
System
• Good Practice: Register for Restart Early
private void RestartDemo_Load(object sender, EventArgs e)
{
SetupApplicationRestart();
}
Add a member variable to the class to hold a delegate that
will be used for callbacks:
private ApplicationRecoveryCallback mCallback;
Registering with the Operating
System
• The SetupApplicationRestart() helper function:
●
●
Calls into the APIs to ensure that you will get a callback to autosave
during a crash
Ensures that your application will restart itself after a crash.
• There are two independent registrations:
private void SetupApplicationRestart()
{
mCallback = new ApplicationRecoveryCallback(this.SaveForRecover);
IntPtr del = Marshal.GetFunctionPointerForDelegate(mCallback);
// delegate, parameter, ping interval, flags (reserved)
RegisterApplicationRecoveryCallback(del, IntPtr.Zero, 5000, 0);
string recoverypath = System.IO.Path.Combine(
Environment.GetFolderPath(
Environment.SpecialFolder.ApplicationData),
"AppRecov.txt");
RegisterApplicationRestart (recoverypath, 0);
}
Testing and Debugging
• To test restart and recovery code, you need to be able to trigger a
problem.
• The sample application, in addition to the Fatal Error button that
divides by zero, has a hang button whose handler goes into an infinite
loop:
•
private void Hang_Click(object sender, EventArgs e)
{
for (; ; ) ;
Testing and Debugging
• Debugging the code that registers your application for restarts is
trivial,
• Debugging the callback function to ensure it is called back is not so
straightforward. Here are some things that don’t work:
•
• If you debug your application by pressing F5, and trigger the error, the
debugger gets in the way and catches the exception:
Testing and Debugging
• Instead of pressing F5, you can launch the application by doubleclicking it, then attach to it from inside Visual Studio:
Testing and Debugging
•
•
By waiting too long after attaching before pressing Cancel, you can
sometimes end up debugging the restart code.
There is a much easier way: run the application under the debugger with a
command line parameter that matches the hint you know is used on a restart:
Summary
• Restart and recovery is powerful & simple
• Debugging takes a great deal of patience.
• You will have to add dummy code, like
delays to give you a chance to attach the
debugger, or buttons to trigger
problems….and then remove it
What is WCF?
• Windows Communication Foundation

Part of the .NET Framework 3.0


Installed with Windows Vista, Windows “Longhorn” Server
Available on Windows XP/SP2, Windows Server 2003
• Microsoft’s SOA platform
●
For building distributed and interoperable applications
• Unifies ASMX, .NET Remoting, and Enterprise
Services stacks
●
●
A single programming model for all
Binding configuration drives protocol choices,
message encoding, etc.
What is WCF?
• Service-Oriented
●
●
Built for service-oriented system design
Simplifies how you approach SOA
• Loosely Coupled
●
●
Not bound to a particular protocol, encoding
format or hosting environment
Everything is configurable
What is WCF?
• Interoperable
●
Supports core Web Services standards
• Ratified and not-yet-ratified
• Extensible to quickly adapt to new protocols and
updates
●
XML message representation at the core
• Integration
●
Integrates with earlier stacks
• COM, Enterprise Services, MSMQ
Clients and Services
Client
Proxy
Endpoint
ServiceHost
Endpoint
Service
Endpoint
©2005-2006 Michele Leroux Bustamante, IDesign Inc. All rights reserved
Resources
• Learning WCF (O’Reilly, 2007)
●
By Michele Leroux Bustamante
• Michele’s Book Blog:
www.thatindigogirl.com
• Michele’s Main Blog:
http://www.dasblonde.net
WPF
What the heck is XAML?
• Separates the front-end from the back-end
• Simple declarative programming language
suitable for constructing and
initializing .NET Objects
• Usually the most concise way to represent
user interfaces (or other hierarchies of
objects)
• Doesn’t need a compile to render
• The language that almost all WPF related
tools emit
WPF – how does it work?
• Built on Top of Direct 3D
●
●
●
●
Converted to 3D triangles, textures and other
Direct3D objects & then rendered by hardware
Benefits of hardware acceleration & perf due to
work being off-loaded to GPUs (unlike GDI
based systems)
Ensures the maximum benefit of new hardware
and drivers
Software rendering pipeline as fallback
http://www.codeplex.com/3DTools
Why WPF?
• The GDI & USER subsystems were
introduced in Windows 1.0 in 1985
• OpenGL – Early 90s
• DirectX – 1995
• Goal: Overcome the limits of GDI+ &
USER with the productivity of Windows
Forms
WPF Vision
• Unified approach to UI,
Documents, and Media
●
Integration as part of development
and experience
• Integrated, vector-based
composition engine
●
Utilizing the power of the PC
throughout the graphics stack
• Declarative programming
●
Bringing designers directly into
application development
• Ease of deployment
●
Allowing administrators to deploy
and manage applications securely
Where to go next
• Windows Presentation Foundation
Unleashed (WPF)
• by Adam Nathan, Daniel Lehenbauer
• Essential Windows Presentation
Foundation (WPF)
• by Chris Anderson
Tim Huckaby, InterKnowlogy
• More info on InterKnowlogy:
●
www.InterKnowlogy.com
• Contact me: Tim Huckaby
● E-mail: [email protected]
or [email protected]
● Phone: 760-930-0075 x201
● Blog: http://blogs.InterKnowlogy.com/TimHuckaby
• About Tim Huckaby
●
●
●
●
●
●
●
●
●
●
Microsoft® Regional Director – Southern California
Microsoft® .NET Partner Advisory Council Founder / Member
Microsoft® MVP - .NET
Microsoft® Prescriptive Architecture Group Advisory Council
Microsoft Office® Developer Advisory Council
Microsoft® MSF advisory board member
INETA Speaker – International .NET Users Group Association
Windows and .NET Magazine Advisory Board Member
.NET Developers Journal Magazine Advisory Board Member
Author / Speaker
Your Feedback is Important
Please fill out a session evaluation form and
either put them in the basket near the exit
or drop them off at the conference
registration desk.
Thank you!