代码改变世界

Windows Phone 7 Series Developer General FAQ

2011-03-02 21:09 by 王克伟, ... 阅读, ... 评论, 收藏, 编辑

今天查找WP7对TCP/UDP的支持时顺手把其它FAQ也转过来方便查找,原文:Windows Phone 7 Series Developer General FAQ (Updated 5/19/2010)

Getting Started

First, get the tools:
• For Windows Phone Developer Tools CTP, you can download the complete (and free) toolset from here .
• If you wish to use Expression Blend 4, visit this page for download links and details. (Note if you already have the Windows Phone Developer Tools installed, you only need items 1, 3, and 4.)

Learn about the technologies:
• Silverlight: Visit The Official Microsoft Silverlight Site for samples, tutorials, and general information about learning Silverlight.
• XNA: Visit the XNA Creators Club Online for information about XNA. Also check out the XNA Creators Club Forums .

Get Samples and Libraries and play!
The Forum's live list of samples for Windows Phone 7 (new!)
Code Samples for Windows Phone
Windows Phone 7 Series Development Training Kit
OData client Library for Windows Phone 7 Series

 

Tools Issues

My installation failed
Before posting the issue in the forum, please check the event logs on your system for any errors that may provide clues.

My installation completed, but I am unable to start Visual Studio 2010 Express for Windows Phone. What should I do?

A common problem appears to be related to the user privileges during and after installation. To work around these issues, make sure you are logged in as Administrator, both during installation and when using the tools. Here is an installation checklist:
1. Check the Release Notes. Make sure your system and already-installed software have the prerequisite requirements, and that issue(s) you may be encountering are not already addressed there. (http://download.microsoft.com/download/D/9/2/D926FB38-BB43-4D87-AE5A-1A3391279FAC/ReleaseNotes.htm )
2. The CTP release does not currently support running from within a virtual machine.
3. Ensure that you are logged in as Administrator before launching the installer. Otherwise you may encounter registry or file permission issues during installation or when using the tools.
4. After installation completes, reboot the system. This clears up miscellaneous problems for some users.
5. Log in as Administrator before launching Visual Studio.

I am getting the error "The application cannot start"
Please see this blog note: http://blogs.msdn.com/visualstudio/archive/2009/10/29/how-to-fix-the-application-cannot-start-error.aspx

Deploying to the emulator is failing
If deploying to the emulator is failing with an error like "Connection failed because of invalid command-line arguments", try the following workarounds in the order indicated:
1. If you have just installed the Tools but have not rebooted yet, try rebooting first to see if that fixes the problem.
2. Try setting VS2010 to launch as Administrator. Here is the procedure. Make sure you are logged in as Administrator. Right click on Microsoft Visual Studio 2010 Express for Windows Phone, choose Properties, click on the Compatibility tab and turn on the check box for "Run this program as an Administrator". Make sure you are logged in as Administrator and then re-launch Visual Studio.
3. If the above does not work, close the solution and then delete the solution .suo file and/or the project .user file. Reopen and see if the deployment works.

The emulator seems slow
1. Use a computer that has “hardware virtualization technology” indicated in its BIOS setup screen (this is the technology used to enable Virtual PC etc.). And then you must ensure that the feature is turned on in the BIOS.
2. As indicated in the Release Notes, use a high performance DirectX 10 capable card with a WDDM 1.1 driver that can take advantage of GPU acceleration on Windows Phone Emulator. Ensure that you are using the very latest driver from the video card manufacturer.

 

Application Process in Foreground / Background

Can my app run in the background / circumvent the foreground requirement?
No, the application model in Windows Phone 7 Series is foreground only execution. If any other application (3rd party or built-in) is started while your application is running, you will get an event notifying you that your application is about to be terminated.

What happens when my application loses the foreground?
Your application will receive a notification that it is being closed. The time allotted your application after the foreground is lost has not yet been determined. If state persistence is desired, you will need to include the logic in your application to handle this.

What happens when my application is brought back after losing the foreground?
Your application will be started from the initial entry point. If state persistence is required, your application should have logic to determine if a state was previously saved and work to restore that state.

Does this means it is impossible to write apps that require background updates to be effective?

No! We have provided a Push Notification service that your application can utilize. Concepts such as Chat Programs, Turn-Based games, and other types of applications that rely on external events are perfect candidates for using Push Notifications. You can read more information about Push Notifications from MSDN: http://msdn.microsoft.com/en-us/library/ff402558%28VS.92%29.aspx

Can I use Push Notifications to start my application if it is not running?

Not directly: A cloud service can send a push notification to a device to update your application's tile, or to display a toast notification. The application will launch only if the user clicks either the tile or the toast notification.

Can I set a timer that will start my application?
No, the decision to start your application is solely up to the user.

Can my application be started based on system events?
This is unlikely, but this is still an open question. Most likely, you will be unable to start your application due to a system event, but you may be able to get a notification cached for when the user starts your application. More information on this will be posted as we learn more about it.

Can I write a Service DLL that can stay resident in the OS if I don't have a UI?
No, you will not be able to write service DLL's. All assemblies will run in their own sandbox, apart from the OS and each other.

 

Application Installation

How do I install applications on my device?
Applications will automatically be installed when downloaded from Marketplace.

Can I manually install applications without using the Marketplace?
No, "side-loading" applications is not permitted. The only way to get released applications on your device is through Marketplace.

How can I test my application on a device if I can't install it?
As a registered developer with Marketplace, you will be able to register a number of devices that you can directly deploy your application to for testing. It is not necessary to publish your application to Marketplace just to test it.

My application is for my company / specific group of people only, how do I distribute the app only to them on Marketplace?
The Marketplace does not currently have the ability to provide locked-off areas for private applications. Other than a few key exceptions for Mobile Operators, there is no way to gate your application to a specific group of people or devices at this time.

 

Marketplace Questions (new!)

How do I register as a developer for Marketplace?
Visit this site and follow the directions to register as a developer for Windows Phone.

How much does it cost to register and what do I get with the subscription?
There is currently a $99 annual subscription. For details about this and many other common questions, please see The Windows Marketplace FAQ .

This price and site indicates development for Windows Phone 6.x; will my account work for Windows Phone 7 as well?
Details concerning how Windows Phone 7 development will be handled with existing subscriptions and future pricing have not yet been announced. This point will be updated once this information is announced.

Where can I get support for Marketplace?
For general Windows Marketplace for Mobile questions, please visit their forum . (Note that there are not many details available for Marketplace's role with Windows Phone 7 yet.)

 

Device Connectivity

Is ActiveSync still used to connect the device to the PC?
No, synchronization is automatic similar to the way the Zune HD connects to the PC.

How should I transfer information over the Internet?

Web technologies such as HTTPGET and WebServices are supported as methods of communicating on the Internet. You can also use Push Notifications for communication when your application is not running.

Can I use Sockets for peer to peer communication?
Windows Phone 7 Series currently does not expose the Socket classes. While the version of Silverlight on the phone follows closely the feature list for Silverlight 3 on the desktop, it is a subset of those features and will not contain all classes. (It also holds a superset of classes not available in Silverlight 3.)

How can I connect with another client in real-time?
Peer-to-peer communication is not supported with this initial release of Windows Phone 7 Series. We are always evaluating the needs of our developers and users though and it may be determined that this feature be added in the future.

 

Hub/Pivot/Tab and other missing controls in Silverlight

Where is that hub control I’ve seen in several demos?
The “Hub” and “Pivot” controls that were seen in several demos at MIX are a work in progress and are not part of the current set of tools.

When will they be available?
There is no set schedule for these controls however the product group is closely watching the developer community to understand the kinds of controls that would be most useful. If there is a control you would like to see that is currently missing, please post a comment in the forum!

Can I make my own?
You can absolutely make your own controls. Note that the Pivot / Hub control is a popular request, chances are good that this is something that will be provided at some point as part of the official tools.

 

Device Storage

What is "Isolated Storage"
Isolated Storage refers to the space in the device file system your application occupies. You are not permitted to make file system calls outside of this space (including other application spaces or OS space.) This provides your application with its own "safe" sandbox, and prevents other applications from inadvertently (or maliciously) affecting your application's space.

Is there a local database available on Windows Phone 7 Series devices?

No, for this initial release of Windows Phone 7 Series, there are no local database API’s available.

How should I store information for my application?
You can store information in your own store space. If you have need of a large database there are other options as well: Windows Phone 7 Series has support for WebServices, which enable you to easily access information that you store on the Internet. With a database that is accessible to a webservice, your application can get data in real time while connected to the Internet.

How should I handle disconnected scenarios?
Without a connection to the Internet, you will not be able to access cloud based services for data. In cases like this it is recommended that your application gracefully handle this in some way (be it to store a cache of data in a custom format on the device, or advise the user of the lack of connectivity.)

My application is intended to run in an off-line scenario, What do I do if I can’t access the cloud?
There are two options for this scenario:
• Build your own data storage scheme on the device to be stored within device memory
• Continue developing for Windows Phone 6.5 or previous versions, which continue to be supported and do support local databases.

Will there be support for local databases in the future?
There are no currently announced plans to add this functionality; however we are closely monitoring the needs of the developers and users to identify features that would benefit everyone.

 

Development Technologies

What technologies and tools can I use to program for Windows Phone 7 Series?
You can currently use the managed language C# using Silverlight and XNA based on Compact Framework.

Can I use Windows Forms?
No, Windows Forms are not supported in the version of Compact Framework included with Windows Phone 7 Series.

How do I upgrade my existing Windows Forms applications to Silverlight?
First, become familiar with Silverlight. (You can learn more about Silverlight at The Official Microsoft Silverlight Site .) This will help you properly convert the UI aspects of your application from Windows Forms to Silverlight. The next step is to convert your business logic. Most of this should work without change, however there are some major changes in class support that you may need to seriously consider such as socket support.

Can I write my application in C++?
No, only managed code written in C# is supported for developing on the Windows Phone 7 Series platform. Unmanaged code and other languages (including Managed C++) are not supported.

Can I write my application in VB?
Not at this time, however this is being strongly considered for a future release of the developer tools.

Can I P/Invoke into System API’s?
No, as an ISV there is no access to the system API’s using P/Invoke. Any application that attempts to use P/Invoke will be rejected from being published to the Marketplace.

Can I P/Invoke my own native DLL?
No, native code may not be run as any part of your application. P/Invokes are not permitted.

What are the main benefits of using Expression Blend or Expression Studio?
These are very effective productivity optimization tools, used to easily adjust the program’s appearance and elements ( Fit and Finish) such as gradients, shapes, vector paths using a very inuitive designer UI. You can run these tools at the same time as Visual Studio, against the same Project.

 

Silverlight, XNA, and Compact Framework

What version of Silverlight does the Phone use?
The version of Silverlight on the phone is a very close subset of Silverlight 3 on the desktop. There are some features available beyond Silverlight 3 that provide phone specific functionality, but many applications that work well in Silverlight 3 on the desktop should work well on the phone.

Can I use XNA library calls in Silverlight?
Silverlight and XNA share a common code base in the Compact Framework. If a call is not GUI based, in most cases it can be shared between Silverlight and XNA.