Monday, 2 May 2011

Windows Embedded Compact 7: Silverlight for Windows Embedded Tutorial Part 2

Hi folks,

in my first tutorial I showed you how to create a Silverlight for Windows Embedded (SWE) application for Windows Embedded Compact 7 using Expression Blend 3, PlatformBuilder and the Windows Embedded Silverlight Tools (WEST) to create a PlatformBuilder subproject.

Today I want to show you how you can use WEST to create a SWE application stand-alone from Visual Studio 2008 (VS2008) WITHOUT PlatformBuilder.

For this tutorial you need to have VS2008 SP1 installed on your machine.

1. Download and install WEST.

NOTE: For this tutorial we will use the WEST sample project that can be found under C:\Program Files\Windows Embedded Silverlight Tools\WindowsEmbeddedSilverlightClock. Of course you can simply reuse the SWE project we created for the first tutorial.

2. Export/install a Windows Embedded Compact 7 SDK that supports SWE.

3. Open VS2008, go to File New Project… Select Visual C++ Smart Device as the project type and use the WEST template Silverlight for Windows Embedded Application. Choose an appropriate project name and location.


Click the OK button.

4. Click the Next button in the appearing Silverlight for Windows Embedded Project Wizard.


5. Select your Platform SDK with SWE support that we installed in step 2. Click Next.


6. Select the above mentioned Expression Blend project.


7. Click Next to generate the C++ code for our SWE project.


NOTE: If the path to the Expression Blend project contains spaces the validation will return errors. Since we are not creating a PlatformBuilder subproject, these errors will not concern us.

8. We can now build and deploy our SWE application.


Congratulation and have fun!

22 comments:

Anonymous said...

how do I deploy this app? My visual studio tries to find active sync and it doesn't work
Thank you.

garzanti said...

@Anonymous If you are using a Virtual PC follow this white-paper tutorial: http://www.microsoft.com/windowsembedded/en-us/develop/Getting-Started-with-Virtual-CEPC.aspx

and here you have the pdf also: http://download.microsoft.com/download/2/4/A/24A36661-A629-4CE6-A615-6B2910A1367A/Getting%20Started%20with%20Virtual%20CEPC.pdf

Joachen can you post a tutorial where you display an image? I am trying to use the Image control from Blend but it doesn't seems to work.

Jochen Dieckfoß [MVP] said...

@ Anonymous:
Generally you need an ActiveSync connection to deploy a Windows Embedded Compact 7 application from a separate instance of Visual Studio (as we use in this tutorial) to a Windows Embedded Compact 7 device.

However, if you do have control over the Windows Embedded Compact 7 image (i.e. the BSP and the OSDesign) you can also use an existing KITL connection to deploy your Application: http://msdn.microsoft.com/en-us/library/ms228708(v=VS.90).aspx

CAUTION:
Do not include this workaround in an production image as this poses a great security risk!

There are several other methods to deploy an application “manually”:

1.You have a KITL connection though PlatformBuilder: copy the .exe (and .pdb file if you want to debug the application) to your Release Directory and run the application (i.e. from PlatformBuilder choose Target | Run Programs…)

2.Copy the .exe to a USB Stick, SD Card, accessible network folder, …; attach the media to your running device; start the .exe in any convenient way.

Hope this helps
-Jochen

Anonymous said...

Hi,
Thank you for reply. Here are the questions. I use VPC from visual studio so I do have control over Compact 7 image. I include Actyve sync in the image but I cannot connect from another intance of visual studio. To debug my application I need to include it as subproject and then I can debug it but I would like to have it as separate project as it is in seconds sample but it doesn't work. Any other suggestions?
One more question. If I create new hard drive (option a in your example) I cannot obtain IP address(DHCP doesn't work) so I am working with sample hard drive (your option b). I hope that's ok.

Jochen Dieckfoß [MVP] said...

@Anonymous:
Thanks for your question.

Using vCEPC as a target is a little bit different: it seems you can’t use ActiveSync to deploy and debug an application; instead you should use an existing network connection. This is basically the same procedure as described in the MSDN article I posted in my comment yesterday: Some files responsible for the communication with PlatformBuilder need to be made available on your target (i.e. Clientshutdown.exe, ConmanClient2.exe, CMaccept.exe, eDbgTL.dll and TcpConnectionA.dll).

The paper suggested by garzanti (http://www.microsoft.com/windowsembedded/en-us/develop/windows-embedded-compact-7-white-papers.aspx the paper you are looking for is the 4th from the top “Advanced Virtual CEPC”, simply click on the pdf icon to download that paper) describes how accomplish that task for vCEPC:
Find the description of how to add the afore mentioned files at the bottom of page 25. However, I would suggest you start with “Creating a Stand-Alone Virtual Hard Disk” (starting at the bottom of page 19), this should also answer your second question about creating a new hard drive.

@garzanti:
Thanks for your helpful input!

Have fun
-Jochen

garzanti said...

@Jochen Don't mention it. Forget about my request for the image display tutorial, I've cleaned up and reimported again the project and all worked fine. It was quite frustrating.

Anyway... do they have a tutorial about how you can navigate from screen to screen in Silverlight?

Anonymous said...

I couldn't find any navigation documents. The method I am using for now is to call SetContent on main page and load screens into it. May be it will help to you. Any better way?

Anonymous said...

Hi,
Thank you for replies. I have CMaccept.exe in many folders. Which one should I use for my virtual Compact 7 PC?

Jochen Dieckfoß [MVP] said...

@Anonymous:
The „Advanced Virtual CEPC“ white paper I recomended in yesterdays comment stats that you should use the files (including CMaccept.exe) from "%ProgramFiles%\Common Files\ Microsoft Shared\CoreCon\1.0\Target\wce400\x86"

Have fun
-Jochen

Anonymous said...

Hi,
I tried. It is not runnig. It just doesn't do anything or after I rebuild OS it tells in debugger that it cannot load symbols because timestamp doesn't match. What can be wrong?

garzanti said...

@Anonymous Well there isn't nothing about navigation in their white-papers. The solution I arrive is the same as yours: to load UserControls in the same form. But I am not using SetContent, I wrote a blog-post so maybe I can help others too: http://garzanti.blogspot.com/2011/09/silverlgith-for-embedded-2-loading.html

garzanti said...

@Anonymous Forget about ActiveSync you should use TCP connectivity, if you follow the steps from Getting Started with VCEPC it will work for sure (at least for me it did). Remember that you need a DHCP server (it can be your router), or if not you must set the loopback addess as described in Advanced VCEPC document.

Anonymous said...

@garzanti Thank you for your post. I have one problem though. It seems that FindName works only up to level of loaded controls. If I need to find let say a button with the control it doesn't work. Any suggestion? Thank you.

garzanti said...

@anonymous Well, it is curious what you are saying, it should search the entire tree - http://msdn.microsoft.com/en-us/library/ee504264.aspx

Are you shour that your element has set a name, also the name in FindName is typed correctly?

Anonymous said...

Yes, I am sure. Can you please try and let me know if you have a solution. I am writing recursive function but the problem that FindName is looking also in "up" direction, so as soon as I traverse down if I use FindName it throws me back on the top of the tree.

garzanti said...

@Anonymous I've just tested today and you are right. I think is a Microsoft bug, I will write them.

Anonymous said...

anything from Microsoft? workaround?

Anonymous said...

BTW, it doesn't work even for static controls. If you create a user control 1 with button "btn1" and then use it inside another user contol 2 if you call FindName("btn1") from user control 2 it will not be found.

garzanti said...

@Anonymous I will write at Microsoft, I am curious what they say.

Anonymous said...

They say in doc that FindName is looking with "current xml scope" and within that scope in your example the last level is grid where you add child controls. FindName will not find them.

I found another problem - radio buttons in popup menu. Nightmare... Let me know if you curious about that.

garzanti said...

@anonymous Hope you're not going to kill Facebook in November :)

I will look for the radio buttons in pop-up menu. Anyway it's amusing because I've found another bug, if you launch a MessageBox from a Silverlight app and you pass the HWND of the app (which is normal, because the app is the owner of the modal), after you close the message box, no event will be triggered no more :) it's like all the controls lost the handlers.

casino online said...

wonderful blogskin http://realCasinoonline.blogspot.com online casino games