Showing posts with label .Net. Show all posts
Showing posts with label .Net. Show all posts

Le nouveau guide d'architecture Mobile de poche

Le 14 janvier dernier, le guide d'architecture Mobile de poche (traduction libre de:The Mobile Architecture Pocket Guide) a été redistribuer dans sa nouvelle version 1.1.

Le guide d'architecture Mobile de poche  fournit une vue d'ensemble et des conseils normatifs pour concevoir des applications Mobiles sur la plate-forme de .NET.  

Ce guide fait parti  des Microsoft Best patterns & practices et  est maintenu dans le projet p&p: Application Architecture Guide 2.0 Knowledge Base.

Vous pouvez télécharger ce guide ici

Les changements principaux de cette mise à jour sont:

  • Mieux adapter le guide pour la réalité du Mobile.
  • Amélioré la figure de l'application Mobile canonique.
  • Élaboré sur le "pourquoi" et raisonnement de certaines décisions.
  • Élaboration sur manipuler les connections.

~ Franky


Revu des MSDN Webcast sur Windows Mobile pour l’année 2008

image L’année 2008 a été fructueuse pour la technologie mobile.  Le nombre d’article et de vidéo disponible sur internet ont grandement augmenté.  Entre autres, Constanze Roman (Windows Mobile Community PM), Maarten Struys (MVP) et Jim Wilson ont fait de très belles et instructives vidéos qui sont toujours disponibles sur demande. 

Voici donc la liste (en espérant que je n’en oublie pas):

Windows Mobile Webcast Series – Getting Ready for Tech Ed

24 Hours of Windows Mobile Application Development

À ne pas manquer en janvier 2009

Bon visionnement et à l’année prochaine!

~ Franky




DiagramLib is a library that give the opportunity to draw some schema like Visio.  I did this librairy doing a addon to Microsoft Visual Studio.  The goal was simple use the drag&drop to quickly build a schema.



  • You can draw many different shapes like: oval, rectangle, rounded rectangle, diamond and the special class shape.
  • Each shape is completely manageable by the UI.  You just need to right-click on a shape to get the Property windows, exactly like Microsoft Visual Studio.
  • You can draw connection between shapes.  Those connections will automatically be re-draw to optimize the path as you moving a shape.  Also the connections have the same customization feature as all shape.
  • The board will automatically expend if needed.
  • You can save and load the schema.


To be able to use the library you just need to add a reference to it. 

   1: private GraphControl oBoard;


   3: this.oBoard = new Compuware.DiagramLib.GraphControl();


   5: this.oBoard.Dock = System.Windows.Forms.DockStyle.Fill;

   6: this.oBoard.Location = new System.Drawing.Point(0, 0);

   7: this.oBoard.Name = "oBoard";

   8: this.oBoard.ShowLoadSaveOption = true;

   9: this.oBoard.Size = new System.Drawing.Size(605, 372);

  10: this.oBoard.Tracking = false;


I did a quick test application to play with the class that you can download here:

If you prefer doing a Test application by you're self here is the DLL: Boucheros.DiagramLib.rar




For any Question or comment feel free to live a comment.

Line of Business Accelerator 2008 – Part 1


Manage store procedure with SQL Compact 3.5

This article is the first of a series were I will explain in small chunk the best practices use in Microsoft Line of Business Accelerator 2008.


To be able to do it you will need:

  • Visual studio 2008 – with SQL compact 3.5

  • Line of Business Accelerator 2008

  • SDK Mobile 6.0 Standard (smartphone, no touch screen)

  • Microsoft Active Sync 4.5

Create the Project

Open Visual studio and create a new Mobile 6 project. You can pick any platform for this demo but a select the framework 3.5 standard.

  1. On the main Form Add a DataGrid and name it grdProduct.

  2. In the Main Menu:  

    • Add a Menu Item Close (mnuClose). Double-click and add the following code to close the application.
         1: private void mnuClose_Click(object sender, EventArgs e)

         2: {

         3:     this.close();

         4: }

    • Add a menuItem Fill mnuFill and double click on it to add the handler.

Now you should have something like this.

Add the Database

Now we need a database. I use the Northwind database. You will found it in the SDK folder (\Program Files\Microsoft Visual Studio 8\SmartDevices\SDK\SQL Server\Mobile - Northwind.sdf). Right-click on the project and add existing item.

When the dataset dialogue will prompt select the in the Product table the column: [Product ID], [Product Name] and [Unit Price].

Fill the datagrid with the “normal” method

Before we add the code in the mnuTest click Handler we need to know the connectionstrng of our database. In NetCF this is the full path and name of the database. The relative path seem not be supported. So in our case we put the database in the same folder that the application, so we could hard coded or use something more generic (and reusable like:

   1: "margin-bottom: 0cm">


   3: string runAppFolder = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);


   5: "margin-bottom: 0cm">


So now we can use it in the click function. Everything else now is like any “regular” .Net application. But instead of using SQL object were using SqlCe.

1: [code:c#;ln=on]

2: private void mnuTest1_Click(object sender, EventArgs e)

3: {

4: try

5:     {

6:         SqlCeDataAdapter oAdap = new SqlCeDataAdapter();

7:         SqlCeConnection oConn = new SqlCeConnection(@"Data Source = " + runAppFolder + @"\Northwind.sdf");

8:         SqlCeCommand GetProduct = new SqlCeCommand(“SELECT [Product ID], [ProductName], [Unit Price] FROM Products”);


10:         oAdap.SelectCommand= GetProduct;

11:         oAdap.Fill(tblProduct);

12:         grdProduct.DataSource= tblProduct;

13:      }

14: catch(Exception ex)

15:     {

16:         MessageBox.Show(ex.Message);

17:     }

18: }

19: [/code]

Now everything is in place the application should works. So Select youre emulator and run it.

Use the manage store procedure

Now it's time to use the “new” that the NetCF Team call:Manage Store Procedure. In fact this is not realty a new, because it was available in VS2005.

Add a Resource call StoreProc to the project.

Add a file to the project ProductGet.sql.

From the resource add an existing text file... select the ProductGet.sql. You should have something like this:

Double-click on the ProductGet icon, the file will open with the SQL syntax hi-lighter. So now we will move the SQL query there in the file you should have:

To use this we will get back in the code where we were building the sqlcqcommand and replace the string by the ProguctGet. So the new code will be

1: [code:c#;ln=on]



4: ...



7: SqlCeCommand GetProduct = new

8: SqlCeCommand(StoreProc.ProductGet,oConn);



11: oAdap.SelectCommand =

12: GetProduct;



15: oAdap.Fill(tblProduct);



"margin-bottom: 0cm">

18: ...



"margin-bottom: 0cm">

21: [/code]


Now you can test again the application. It's works like before but this time you can edit the sql code without re-compiling.

To add some parameter just add some ? in you re query and add the parameter(s) to the SqlCeCommand, like usual.

I hope this simple tutorial help you, feel free to ask any question or let me know you're comment.



ClickOnce: The easy way to deploy the .Net applications


The easy way to deploy the .Net applications

  1. Introduction
  2. The Application
  3. Deployment of an application
    • First deployment
  4. Installation
  5. Update
  6. Uninstalling the Application
  7. Examining the Application and Deployment Manifests
    • The Application Manifest
    • The Deployment Manifest
  8. Security
    • Sign the ClickOnce manifest
    • Security permissions
  9. Faqs
  10. Extra
    • Current Version
    • Update Detail
    • Updating manually
    • Downloading Files on Demand
  11. References


ClickOnce is a new application deployment technology that makes deploying a Windows Forms based application as easy as deploying a web application.
ClickOnce applications can be deployed via web servers, file servers or CDs. A ClickOnce application can choose to be installed, meaning it gets start menu & add/remove program entries, or an app can simply be run and cached. ClickOnce can be configured in several ways to check automatically for application updates. Alternatively, applications can use the ClickOnce APIs (System.Deployment), to control when updates should happen.
Using ClickOnce requires that the target client already have the .NET Framework 2.0 installed. Visual Studio has made packaging and deploying the .NET Framework simpler than ever. Simply select what pre-requisites your application may have (e.g., the .NET Framework 2.0 and MDAC 9.0) and Visual Studio will generate a bootstrapper file that will automatically install all of the specified prerequisites when run. On the server side, ClickOnce needs only an HTTP 1.1 server or alternatively a file server.
So let’s start and build a simple application…

The Application

Create a simple windows base application named MyClickTest. Just put a label on the Form1 and set the text property equal to: “Version 1”. That all for the first version of our application.



Deployment of an application

First deployment

To start the publishing configuration you must go in the property of the project. You can right-click on the Project name [MyClickTest] in the Solution Explorer at the top right of the screen or in Menu | Project | MyClickTest Properties. Than in the tab Signing check the [Sign the ClickOnce manifest].
We must now define the Security level. For the moment, check the box which indicates that our application is "Full trust". By safety measure, it will be necessary to better avoid choosing this option; we will thus see a little later in this tutorial how to define these options of safety as well as possible.
Let go now to the greatest part: publication. In the Publish tab you can define the location of you’re publication. This location will specify if the application will by publish from a web site, a ftp site or by a share folder of a network.
In some scenarios, it may be important to first publish the application to a staging server before moving it to another server for deployment. While the Publishing Location text box specifies the location to which you'll publish the application, the Installation URL text box allows you to specify where the users should install your application. As an example, consider the following scenario:
When you publish the application using the above settings, the application will deploy to http://server1/ MyClickTest/. However, you will need to manually copy all of the files located in the folder mapped to http://server1/MyApp/ into the folder mapped to http://server2/MyClickTest/.
Users will then install the application from http://server2/MyClickTest/ (that is, through http://server2/ MyClickTest/index.htm). More importantly, the application will check for updates from http://server2/MyClickTest/ and not http://server1/MyClickTest/.
Also you define the installation mode. Does the application will be available online only (download every time) or the application can by available online and in offline mode, so install locally and available in the Start menu. Other configurations are available:
· Application Files: Here are listed all files associated with the projects. (Figure 1) image
Figure 1
· Prerequisites: Here you can specify the list of the applications must by install to run you’re application (Figure 2). The bootstrapper is very extensible and can be used to install 3rd party and custom pre-requisites.
Figure 2
To add our own prerequisite you need to have bootstrapper package. Once created boot strapper package then it will automatically included into prerequisite list. To generate bootstrapper can use “Bootstrapper Manifest Generator” tool. Follow the steps given below to add own bootstrapper using “Bootstrapper Manifest Generator” tool.(
  • Updates: Here you specify if the application will check for update on the server, when it will do (before or after the application start). (Figure 3). If you check for updates after the application has started, you can specify how often to check. The most frequent check you can perform is once per day.
Figure 3
To prevent users from running an older version of your application, you can specify the minimum version required. This option is useful if you have just discovered a major bug in your application; to prevent users from rolling back to the previous version after the update, you can set the current version number as the minimum required version.
By default, your application will check for updates from locations in the following order:
1. Update location (if specified in this window).
2. Installation URL (if specified in the Publish tab of the project properties).
3. Publish location.
  • Options: You can specify various information (Figure 4).
Figure 4
Once all information is completed click the button "Publish Wizard" (also available in menu [Build] or, in the [Solution Explorer], by right clicking) that will start the Installation Wizard to configure the ClickOnce installation.

The Publish Wizard enables you to configure all the options necessary to the deployment of the application.
Again you can specify the location of the publication…
… the installation mode ( online or offline)…
Because all the information is already specified in the previous screen press the [Finish] button will be the same.
By clicking the button a new web page is automatically create to publish the application. You can see the page by tipping the web address specified previously (http://localhost/MyClickTest/index.htm)


To install the application just click the [Install] button. That will launch the installation of the application on the station and one sees well the checking of the presence of update, right before launching:
Now you’re application is available in the Start menu.
Now get back to Visual Studio and charge the label to Version 2. In the Build menu (or, in the [Solution Explorer], by right clicking) re-publish the application. From the Start menu launch the application. A popup should be display asking you to update the version on you is local machine.
Now you should see Version 2 in the label.

Uninstalling the Application

To uninstall a ClickOnce application, users can go to the Control Panel and launch the "Add or Remove Programs" application. In the "Change or Remove Programs" section, users then select the application to uninstall and click the Change/Remove button.
If the application has been updated at least once, users will see the option "Restore the application to its previous state," which allows users to roll back the application to its previous version. Users then select the option "Remove the application from this computer" to uninstall the application.

Examining the Application and Deployment Manifests

When you use the Publish Wizard in ClickOnce, Visual Studio will publish your application to the URL you have indicated. For example, if you indicated http://localhost/MyClickTest/ as the publishing directory and you mapped the virtual directory MyClickTest to the local path C:\Inetpub\wwwroot\MyClickTest, two types of files will be created under the C:\Inetpub\wwwroot\MyClickTest directory:
· The application manifest
· The deployment manifest
The Application Manifest
When you publish your application, a folder and four files are automatically generated in the publishing directory. They are:
· A folder containing the deployment files (MyClickTest_1_0_0_0; see next section).
· An application manifest MyClickTest.application. The index.htm file points to this application (by default is publish.htm).
· A version-specific application manifest; for example, MyClickTest_1_0_0_0.application.
· A index.htm (publish.htm) web page containing instructions on how to install the application.
· A setup application (setup.exe).
The application manifest MyClickTest.application is an XML file that contains detailed information about the current application as well as its version number. It lets users know if they need to update application.
When you re-publish your application, the contents of MyClickTest.application, publish.htm, and setup.exe will be modified, while one new version-specific application manifest (for example, MyClickTest_1_0_0_1.application) and a new folder (for example, MyClickTest_1_0_0_1) containing the new versions of deployment files will be created.
The Deployment Manifest
Locate the deployment manifest, MyClickTest.exe.manifest, in the C:\Inetpub\wwwroot\MyClickTest\MyClickTest _1_0_0_0 directory. It contains information about the application (such as dependencies and attached files). The MyClickTest.exe.deploy file is your application's executable. The other files and databases in the directory are used by your application. During installation, these files will be downloaded onto your users' machines.
Sign the ClickOnce manifests
You have the possibility of signing the manifest your ClickOnce application, like signing your assembly NET.
With Visual Studio 2005, you don’t need anymore to use command prompt tool. In the tab [Signing] (of the page of properties of your project) just check the box [Sign the assembly] and via the drop-down menu, pick a option to create a new file “snk”.
You also have the possibility of signing the manifest your ClickOnce application, by using a certificate of safety. Use a certificate already installed (button [Select from Blind]), or import your certificate (button [Select from File]).
Security permissions
A good safety is that which gives less possible freedoms, more precisely, that which gives simply the rights necessary. You can do it manually by choosing rights which you grant to your application or then, you can let Visual Studio do that for you.
Click on [Calculating the permissions]
Visual Studio then will analyze each line of your code in order to detect (according to your methods) the authorizations needed.
Does "ClickOnce" download the entire application every-time I update it? 
No. “ClickOnce” only downloads the files and assemblies that have changed.
I want my application to be installed to a specific hard drive location, how can I achieve this?
The install location of "ClickOnce" application cannot be managed by the application. This is an important part of making "ClickOnce" applications safe, reversible, and easy to administer.
Can I use compression to make my application download faster? 
Yes, “ClickOnce” supports HTTP 1.1 compression. Simply enable this on your web server & the files “ClickOnce” downloads will be compressed.
Can I install a "ClickOnce" application per-machine?
No. All “ClickOnce” applications are installed per-user. Each user is totally isolated from one another and must install their own copy. If your application needs to be installed per-machine, you should use MSI.
A lot of functionality are available by the System.Deployment.Application reference.
Let present some of those. First see the interface.
Current Version
In the Form_load of the form let retrieve the information about the current version.
private void Form1_Load( object sender, EventArgs e){
    ApplicationDeployment oDeploy;
    // Check if the application is deploy by the ClickOnce chkClickDeploy.Checked = ApplicationDeployment.IsNetworkDeployed;
    if (ApplicationDeployment.IsNetworkDeployed) {
        // Because the application is a CLickOnce deployement there are some information
        // there are available lke the current version, the Location of this version update.
        oDeploy = ApplicationDeployment.CurrentDeployment;
        txtCurrentVersion.Text = oDeploy.CurrentVersion.ToString();
        txtCurrentServer.Text = oDeploy.UpdateLocation.ToString();
    this.txtinstallFolder.Text = Environment.CurrentDirectory;
Update Detail
By clicking the button [Check Now] let check if a new release is available, and if yes then retrieve the information about that one.
private void btnCheck_Click(object sender, EventArgs e)
ApplicationDeployment oDeploy;
if (ApplicationDeployment.IsNetworkDeployed)
oDeploy = ApplicationDeployment.CurrentDeployment;
// Check if a newest version is available.
UpdateCheckInfo oInfoChecker = oDeploy.CheckForDetailedUpdate();
if (oInfoChecker.UpdateAvailable)
// If yes then retreive the latest version available
// (because you can jump a version). check if the version
// in mandatory and the size.
chkUpdateAvailable.Checked = oInfoChecker.UpdateAvailable;
txtLastVersion.Text = oInfoChecker.AvailableVersion.ToString();
chkUpdateMandatory.Checked = oInfoChecker.IsUpdateRequired;
txtLastVersionServer.Text = oDeploy.UpdateLocation.ToString();
txtUpdateSize.Text = oInfoChecker.UpdateSizeBytes.ToString();
else {
MessageBox.Show("No update available...");
Updating manually
By clicking the button [Update] the application will update to the latest version available. We can do it asynchronally or synchronally. The new version will take effect after to re-start the application.
private void btnUpdate_Click(object sender, EventArgs e)
ApplicationDeployment oDeploy;
if (ApplicationDeployment.IsNetworkDeployed)
oDeploy = ApplicationDeployment.CurrentDeployment;
UpdateCheckInfo oInfoChecker = oDeploy.CheckForDetailedUpdate();
if (oInfoChecker.UpdateAvailable)
if (optSynch.Checked){
MessageBox.Show("Update done successfully...");
else {
oDeploy.UpdateCompleted += new AsyncCompletedEventHandler(oDeploy_UpdateCompleted);
oDeploy.UpdateProgressChanged += new DeploymentProgressChangedEventHandler(oDeploy_UpdateProgressChanged);
void oDeploy_UpdateProgressChanged(object sender, DeploymentProgressChangedEventArgs e)
this.toolStripProgressBar1.Value = e.ProgressPercentage;
void oDeploy_UpdateCompleted(object sender, AsyncCompletedEventArgs e)
MessageBox.Show("Update done successfully...");
private void btnReStart_Click(object sender, EventArgs e)
Downloading Files on Demand
If you have a large-size help file, this adds to the download time for your users. And if you have multiple help files in your application, then the entire application will also take longer to install. A better approach is to selectively download the help files as and when you need them. For example, you can set the help file to download after the application installs, when a user clicks on the Display Help button.
To specify that the help file be loaded as and when needed, you need to perform the following steps:
· In Visual Studio in the [Solution Explorer] add a text File: ClickHelp.txt.
· Get back in the Property of the Project in the tab [Publish]. Click on the button [Application Files]. Change the Publish Status of ClickHelp.txt to Include.
· Click the drop-down menu in the Download Group and select (New).
· Specify a name for the download group, such as: Help.
· Add a new button on the form. Then double-click on it to add this handler code.
private void button1_Click(object sender, EventArgs e)
ApplicationDeployment oDeploy;
// Check if the application is deploy by the ClickOnce
oDeploy = ApplicationDeployment.CurrentDeployment;
// Add a handler for the asynchrone process and download the file(s)
// in the group “Help”
oDeploy.DownloadFileGroupCompleted += new
void oDeploy_DownloadFileGroupCompleted(object sender,
DownloadFileGroupCompletedEventArgs e){
// If the Group is Help display the content of the file.

  • OReilly Use ClickOnce to Deploy Windows Applications (2006).chm