Project: GraphLib for mobile

The GraphLib for mobile is a library to draw some chart on a mobile. 

You can see more about this project in the section Project of this blog or by cliking here.


Sample of a bar chart Playing with the text

Posted by: franky
Posted on: 7/31/2008 at 11:07 AM
Tags: , , ,
Categories: .Net | Mobile
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Project: DiagramLib

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 read more about it here

Some shapes and the property toolbar

 


Posted by: franky
Posted on: 7/31/2008 at 9:30 AM
Tags: , ,
Categories: .Net | Mobile
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Line of Business Accelerator 2008 – Part 1

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.

Prerequisites

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: [code:c#;ln=on]
      2: private void mnuClose_Click(object sender, EventArgs e)
      3: {
      4: this.close();
      5: }
      6: [/code]
    • 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: [code:c#;ln=on]
2:

3:

"margin-bottom: 0cm">

4: string
5: runAppFolder =
6: System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
7:

8:

"margin-bottom: 0cm">

9: [/code]


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”);
9:  
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]
2:

3:

4: ...
5:

6:

7: SqlCeCommand GetProduct = new
8: SqlCeCommand(StoreProc.ProductGet,oConn);
9:

10:

11: oAdap.SelectCommand =
12: GetProduct;
13:

14:

15: oAdap.Fill(tblProduct);
16:

17:

"margin-bottom: 0cm">

18: ...
19:

20:

"margin-bottom: 0cm">

21: [/code]


Conclusion

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.

Thanks

Franky


Posted by: franky
Posted on: 4/24/2008 at 4:13 PM
Tags: , ,
Categories: .Net | Mobile
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Code Formatter Extension

Permet de formater du code.  Voici un exemple

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

3:

4:  
5:         /// <summary/>
6:         protected CodeFormat()
7:         {
8:             //generate the keyword and preprocessor regexes from the keyword lists
9:             Regex r;
10:             r = new Regex(@"\w+|-\w+|#\w+|@@\w+|#(?:\\(?:s|w)(?:\*|\+)?\w+)+|@\\w\*+");
11:             st
12:

13:

14: [/code]
 

 

Il connait les langage suivant: 

  • C#
  • vb
  • js
  • html
  •  xml
  • tsql
  • msh

Voici un comment le declarer

 [c o d e:c#;ln=on]


Posted by: franky
Posted on: 3/14/2008 at 5:55 AM
Tags: , ,
Categories: .Net | BlogEngine.NET
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

Wow the new Microsoft Expression Blend 2.5 March 2008 Preview is out...

Wow the new Microsoft Expression Blend 2.5 March 2008 Preview is out...
Let try it...

Posted by: franky
Posted on: 3/10/2008 at 12:25 AM
Tags: , ,
Categories: .Net
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

NDoc 2.0

NDoc is a very useful open source project that generates reference documentation from .NET assemblies and the XML documentation files generated by the C# compiler (or an add-on tool for VB.NET).



The tool clip_image001[21]

NDoc generates documentation in several different formats, including:

  • the MSDN-style HTML Help format (.chm)
    clip_image003
  • the Visual Studio .NET Help format (HTML Help 2)
    clip_image005
  • MSDN-online style web pages
    clip_image007

Which is much better than just the XML file we get from the compiler...

Unfortunately, NDoc has not been ported to .NET 2.0 yet. Alpha test versions have been released regularly to a private mailing list, but a final release version was never created due to the sheer complexity of the task, combined with a lack of financial support by the user community, and other unrelated issues intruding upon the development process. But since August 2006 an “unofficial”, product by a single user, a ALPHA version is available.

C# Comment Tags clip_image001[22]

<c> clip_image001[23]

Description:

The text you would like to indicate as code.

Remarks:

The <c> tag gives you a way to indicate that text within a description should be marked as code. Use <code> to indicate multiple lines as code.

Exemple:

 
C# 
    /// DoWork is a method in the TestClass class.
    /// 
    public static void DoWork(int Int1)
    {
    }
 
<para> clip_image001[24]

Description:

The text of the paragraph.

Remarks:

The <para> tag is for use inside a tag, such as <summary>, <remarks>, or <returns>, and lets you add structure to the text.

<see> clip_image001[25]

<see cref="member"/>

Parameter:: cref = " member"

A reference to a member or field that is available to be called from the current compilation environment. The compiler checks that the given code element exists and passes member to the element name in the output XML. Place member within double quotation marks (" ").

Remarks:

The <see> tag lets you specify a link from within text. Use <seealso> to indicate that text should be placed in a See Also section.

Exemple:

 
C#
 
// the following cref shows how to specify the reference, such that,
// the compiler will resolve the reference
/// <summary cref="C{T}">
/// </summary>
class A { }
 
// the following cref shows another way to specify the reference, 
// such that, the compiler will resolve the reference
// <summary cref="C < T >">
 
// the following cref shows how to hard-code the reference
/// <summary cref="T:C`1">
/// </summary>
class B { }
 
/// <summary cref="A">
/// </summary>
/// <typeparam name="T">
class C<T> { } 
 

:

<code> clip_image001[26]

Description:

The text you want marked as code.

Remarks:

The <code> tag gives you a way to indicate multiple lines as code. Use <c> to indicate that text within a description should be marked as code.

<param> clip_image001[27]

<param name='name'>description</param>

Parameters name:

The name of a method parameter. Enclose the name in double quotation marks (" ").

Description:

A description for the parameter.

Remarks:

The <param> tag should be used in the comment for a method declaration to describe one of the parameters for the method. The text for the <param> tag will be displayed in IntelliSense? , the Object Browser, and in the Code Comment Web Report.

Exemple:

 
C#  
/// text for class TestClass 
public class TestClass {     
 
   /// <param name="Int1">Used to indicate status.</param>     
   public static void DoWork(int Int1)     {     }     
 
   /// text for Main     
   static void Main()     {     } 
} 
<seealso> clip_image001[28]

<seealso cref="member"/>

Parameters:

A reference to a member or field that is available to be called from the current compilation environment. The compiler checks that the given code element exists and passes member to the element name in the output XML. must appear within double quotation marks (" ").

Remarks:

The <seealso> tag lets you specify the text that you might want to appear in a See Also section. Use to specify a link from within text.

<example> clip_image001[29]

Description:

A description of the code sample.

Remarks:

The <example> tag lets you specify an example of how to use a method or other library member. This commonly involves using the <code> tag.

Exemple:

 
C#
/// text for class TestClass
public class TestClass
{
    /// <summary>
    /// The GetZero method.
    /// </summary>
    /// <example> This sample shows how to call the GetZero method.
    /// <code>
    /// class TestClass 
    /// {
    ///     static int Main() 
    ///     {
    ///         return GetZero();
    ///     }
    /// }
    /// </code>
    /// </example>
    public static int GetZero()
    {
        return 0;
    }
 
    /// text for Main
    static void Main()
    {
    }
}
<paramref> clip_image001[30]

<paramref name="name"/>

Parameter:

The name of the parameter to refer to. Enclose the name in double quotation marks (" ").

Remarks:

The <paramref> tag gives you a way to indicate that a word in the code comments, for example in a <summary> or <remarks> block refers to a parameter. The XML file can be processed to format this word in some distinct way, such as with a bold or italic font.

<summary> clip_image001[31]

Description:

A summary of the object.

Remarks:

The <summary> tag should be used to describe a type or a type member. Use <remarks> to add supplemental information to a type description. The text for the <summary> tag is the only source of information about the type in IntelliSense? , and is also displayed in the Object Browser.

Exemple:

 
C#  
/// text for class TestClass
public class TestClass
{
    /// <summary>DoWork is a method in the TestClass class.
    /// <para>Here's how you could make a second paragraph in a description. 
    /// <see cref="System.Console.WriteLine(System.String)"/> for information about output statements.</para>
    /// <seealso cref="TestClass.Main"/>
    /// </summary>
    public static void DoWork(int Int1)
    {
    }
 
    /// text for Main
    static void Main()
    {
    }
}     
public static void DoWork(int Int1)     {     }      
 
/// text for Main     static void Main()     {     } 
} 
<exception> * clip_image001[32]

Parameter:

cref = "member"

A reference to an exception that is available from the current compilation environment. The compiler checks that the given exception exists and translates member to the canonical element name in the output XML. member must appear within double quotation marks (" ").

Description:

A description of the exception.

Remarks:

The <exception> tag lets you specify which exceptions can be thrown. This tag can be applied to definitions for methods, properties, events, and indexers.

<permission> * clip_image001[33]

Parameter:

cref = "member"

A reference to a member or field that is available to be called from the current compilation environment. The compiler checks that the given code element exists and translates member to the canonical element name in the output XML. member must appear within double quotation marks (" ").

Description:

A description of the access to the member.

Remarks:

The <permission> tag lets you document the access of a member. The PermissionSet? class lets you specify access to a member.

<typeparam> * clip_image001[34]

Description:

A description for the type parameter.

Remarks:

The <typeparam> tag should be used in the comment for a generic type or method declaration to describe a type parameter. Add a tag for each type parameter of the generic type or method.

<include> * clip_image001[35]

Parameter:

filename

The name of the file containing the documentation. The file name can be qualified with a path. Enclose filename in single quotation marks (' ').

tagpath

The path of the tags in filename that leads to the tag name. Enclose the path in single quotation marks (' ').

name

The name specifier in the tag that precedes the comments; name will have an id.

id

The ID for the tag that precedes the comments. Enclose the ID in double quotation marks (" ").

Remarks:

The <include> tag lets you refer to comments in another file that describe the types and members in your source code. This is an alternative to placing documentation comments directly in your source code file.

The <include> tag uses the XML XPath syntax. Refer to XPath documentation for ways to customize your <include> use.

Exemple:

This is a multifile example. The first file, which uses &ltinclude>, is listed below:

 
C#
///  &ltinclude file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test"]/*' />
class Test
{
    static void Main()
    {
    }
}
 
///  &ltinclude file='xml_include_tag.doc' path='MyDocs/MyMembers[@name="test2"]/*' />
class Test2
{
    public void Test()
    {
    }
}
 

The second file, xml_include_tag.doc, contains the following documentation comments:

 
<MyDocs>
  <MyMembers name="test">
    <summary>
      The summary for this type.
    </summary>
  </MyMembers>
 
  <MyMembers name="test2">
    <summary>
      The summary for this other type.
    </summary>
  </MyMembers>
</MyDocs>

Program Output

 
 
<doc> 
  <assembly> 
    <name>xml_include_tag</name> 
  </assembly> 
  <members> 
    <member name="T:Test"> 
      <summary> 
        The summary for this type. 
      </summary> 
    </member> 
    <member name="T:Test2"> 
      <summary> 
        The summary for this other type. 
      </summary> 
    </member> 
  </members> 
</doc> 
 
<remarks> clip_image001[36]

Description:

A description of the member.

Remarks:

The <remarks> tag is used to add information about a type, supplementing the information specified with <summary>. This information is displayed in the Object Browser.

Exemple:

 
C#
/// 
/// You may have some primary information about this class.
/// 
/// 
/// You may have some additional information about this class.
/// 
public class TestClass
{
    /// text for Main
    static void Main()
    {
    }
}
<typeparamref> clip_image001[37]

Remarks:

For more information on type parameters in generic types and methods, see Generics. Use this tag to enable consumers of the documentation file to format the word in some distinct way, for example in italics.

<list> clip_image001[38]
  <list type="bullet" | "number" | "table">
      <listheader>
          <term>term</term>
          <description>description</description>
      </listheader>
      <item>
          <term>term</term>
          <description>description</description>
      </item>
  </list>

Parameters

term

A term to define, which will be defined in description.

description

Either an item in a bullet or numbered list or the definition of a term.

Remarks:

The <listheader> block is used to define the heading row of either a table or definition list. When defining a table, you only need to supply an entry for term in the heading.

Each item in the list is specified with an <item> block. When creating a definition list, you will need to specify both term and description. However, for a table, bulleted list, or numbered list, you only need to supply an entry for description.

Exemple:

 
C#
/// text for class TestClass
public class TestClass
{
    ///  <summary>Here is an example of a bulleted list:
    ///  <list type="bullet">
    ///  <item>
    ///  <description>Item 1. </description>
    ///  </item>
    ///  <item>
    ///  <description>Item 2. </description>
    ///  </item>
    ///  </list>
    ///  </summary>
    static void Main()
    {
    }
}
<returns> clip_image001[39]

Description:

A description of the return value.

Remarks:

The tag should be used in the comment for a method declaration to describe the return value.

<value> clip_image001[40]

Remarks:

The <value> tag lets you describe the value that a property represents. Note that when you add a property via code wizard in the Visual Studio .NET development environment, it will add a <summary> tag for the new property. You should then manually add a <value> tag to describe the value that the property represents.


* denotes that the compiler verifies syntax.

External Links clip_image001[41]

NDoc Code Documentation Generator for .NET

You can find more details about the project on the official website.

NDoc 2.0 Alpha

The web site of the developer how create the alpha version. You can also found other developer tools on that site.

XML Documentation Comments (C# Programming Guide)

MSDN Labrary the C# Programming Guide.


-- FrancoisBoucher - 10 May 2007

 


Posted by: franky
Posted on: 5/10/2007 at 7:15 AM
Tags: , ,
Categories: .Net
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed

ClickOnce: The easy way to deploy the .Net applications

ClickOnce

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

Introduction

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.

clip_image002

 

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].

clip_image004

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.

clip_image006

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/.

clip_image008

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) clip_image010

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.

clip_image012

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.(http://www.gotdotnet.com/workspaces/workspace.aspx?id=ddb4f08c-7d7c-4f44-a009-ea19fc812545)

  • 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.

clip_image014

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).

 

clip_image016

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.

clip_image018

Again you can specify the location of the publication…

clip_image020

… the installation mode ( online or offline)…

clip_image022

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)

clip_image024

Installation

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:

clip_image026

clip_image028

Now you’re application is available in the Start menu.

clip_image030

Update

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.

clip_image032

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.

clip_image034


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).

 clip_image037

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.

clip_image040

Security

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]

clip_image042

Visual Studio then will analyze each line of your code in order to detect (according to your methods) the authorizations needed.

clip_image044

Faqs

 

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.

Extra

A lot of functionality are available by the System.Deployment.Application reference.

Let present some of those. First see the interface.

clip_image046

Current Version

In the Form_load of the form let retrieve the information about the current version.

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

3:

4: private void Form1_Load( object sender, EventArgs e){
5:

6:

7:     ApplicationDeployment oDeploy;
8:

9:

10:     // Check if the application is deploy by the ClickOnce chkClickDeploy.Checked = ApplicationDeployment.IsNetworkDeployed;
11:

12:

13:     if (ApplicationDeployment.IsNetworkDeployed) {
14:

15:

16:         // Because the application is a CLickOnce deployement there are some information
17:

18:

19:         // there are available lke the current version, the Location of this version update.
20:

21:

22:         oDeploy = ApplicationDeployment.CurrentDeployment;
23:

24:

25:         txtCurrentVersion.Text = oDeploy.CurrentVersion.ToString();
26:

27:

28:         txtCurrentServer.Text = oDeploy.UpdateLocation.ToString();
29:

30:

31:     }
32:

33:

34:     this.txtinstallFolder.Text = Environment.CurrentDirectory;
35:

36:

37: }[/code]

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.

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

3:

4: private void btnCheck_Click(object sender, EventArgs e)
5:

6:
7:

8: {
9:

10:
11:

12: ApplicationDeployment oDeploy;
13:

14:
15:

16: if (ApplicationDeployment.IsNetworkDeployed)
17:

18:
19:

20: {
21:

22:
23:

24: oDeploy = ApplicationDeployment.CurrentDeployment;
25:

26:
27:

28: // Check if a newest version is available.
29:

30:
31:

32: UpdateCheckInfo oInfoChecker = oDeploy.CheckForDetailedUpdate();
33:

34:
35:

36: if (oInfoChecker.UpdateAvailable)
37:

38:
39:

40: {
41:

42:
43:

44: // If yes then retreive the latest version available
45:

46:
47:

48: // (because you can jump a version). check if the version
49:

50:
51:

52: // in mandatory and the size.
53:

54:
55:

56: chkUpdateAvailable.Checked = oInfoChecker.UpdateAvailable;
57:

58:
59:

60: txtLastVersion.Text = oInfoChecker.AvailableVersion.ToString();
61:

62:
63:

64: chkUpdateMandatory.Checked = oInfoChecker.IsUpdateRequired;
65:

66:
67:

68: txtLastVersionServer.Text = oDeploy.UpdateLocation.ToString();
69:

70:
71:

72: txtUpdateSize.Text = oInfoChecker.UpdateSizeBytes.ToString();
73:

74:
75:

76: }
77:

78:
79:

80: else {
81:

82:
83:

84: MessageBox.Show("No update available...");
85:

86:
87:

88: }
89:

90:
91:

92: }
93:

94:
95:

96: }[/code]

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.

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

3:

4: private void btnUpdate_Click(object sender, EventArgs e)
5:

6:
7:

8: {
9:

10:
11:

12: ApplicationDeployment oDeploy;
13:

14:
15:

16: if (ApplicationDeployment.IsNetworkDeployed)
17:

18:
19:

20: {
21:

22:
23:

24: oDeploy = ApplicationDeployment.CurrentDeployment;
25:

26:
27:

28: UpdateCheckInfo oInfoChecker = oDeploy.CheckForDetailedUpdate();
29:

30:
31:

32: if (oInfoChecker.UpdateAvailable)
33:

34:
35:

36: {
37:

38:
39:

40: if (optSynch.Checked){
41:

42:
43:

44: oDeploy.Update();
45:

46:
47:

48: MessageBox.Show("Update done successfully...");
49:

50:
51:

52: }
53:

54:
55:

56: else {
57:

58:
59:

60: oDeploy.UpdateCompleted += new AsyncCompletedEventHandler(oDeploy_UpdateCompleted);
61:

62:
63:

64: oDeploy.UpdateProgressChanged += new DeploymentProgressChangedEventHandler(oDeploy_UpdateProgressChanged);
65:

66:
67:

68: oDeploy.UpdateAsync();
69:

70:
71:

72: }
73:

74:
75:

76: }
77:

78:
79:

80: }
81:

82:
83:

84: }
85:

86:
87:

88: void oDeploy_UpdateProgressChanged(object sender, DeploymentProgressChangedEventArgs e)
89:

90:
91:

92: {
93:

94:
95:

96: this.toolStripProgressBar1.Value = e.ProgressPercentage;
97:

98:
99:

100: }
101:

102:
103:

104: void oDeploy_UpdateCompleted(object sender, AsyncCompletedEventArgs e)
105:

106:
107:

108: {
109:

110:
111:

112: MessageBox.Show("Update done successfully...");
113:

114:
115:

116: }
117:

118:
119:

120: private void btnReStart_Click(object sender, EventArgs e)
121:

122:
123:

124: {
125:

126:
127:

128: Application.Restart();
129:

130:
131:

132: }
133:

134:

135: [/code]
 

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.

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

3:

4: private void button1_Click(object sender, EventArgs e)
5:

6:
7:

8: {
9:

10:
11:

12: ApplicationDeployment oDeploy;
13:

14:
15:

16: // Check if the application is deploy by the ClickOnce
17:

18:
19:

20: if(ApplicationDeployment.IsNetworkDeployed){
21:

22:
23:

24: oDeploy = ApplicationDeployment.CurrentDeployment;
25:

26:
27:

28: // Add a handler for the asynchrone process and download the file(s)
29:

30:
31:

32: // in the group “Help”
33:

34:
35:

36: oDeploy.DownloadFileGroupCompleted += new
37:

38:
39:

40: DownloadFileGroupCompletedEventHandler(
41:

42:
43:

44: oDeploy_DownloadFileGroupCompleted);
45:

46:
47:

48: oDeploy.DownloadFileGroupAsync("Help");
49:

50:
51:

52: }
53:

54:
55:

56: }
57:

58:
59:

60: void oDeploy_DownloadFileGroupCompleted(object sender,
61:

62:
63:

64: DownloadFileGroupCompletedEventArgs e){
65:

66:
67:

68: // If the Group is Help display the content of the file.
69:

70:
71:

72: if(e.Group.Equals("Help")){
73:

74:
75:

76: MessageBox.Show(File.ReadAllText("ClickHelp.txt"));
77:

78:
79:

80: }
81:

82:
83:

84: }
85:

86:

87: [/code]
 

References

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

Posted by: franky
Posted on: 3/20/2007 at 6:05 AM
Tags: , ,
Categories: .Net
Actions: E-mail | Kick it! | DZone it! | del.icio.us
Post Information: Permalink | Comments (0) | Post RSSRSS comment feed