<?xml version="1.0" encoding="UTF-8"?>
<!-- generator="wordpress/2.3.2" -->
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	>

<channel>
	<title>ILOG .NET Visualization Blog &#187; Robert Dupuy</title>
	<link>http://blogs.ilog.com/netvisu</link>
	<description>Postings from the Visualization .NET Development Team</description>
	<pubDate>Tue, 26 Aug 2008 21:22:31 +0000</pubDate>
	<generator>http://wordpress.org/?v=2.3.2</generator>
	<language>en</language>
			<item>
		<title>Creating Default Anchors for custom User Symbols</title>
		<link>http://blogs.ilog.com/netvisu/2008/06/26/creating-default-anchors-for-custom-user-symbols/</link>
		<comments>http://blogs.ilog.com/netvisu/2008/06/26/creating-default-anchors-for-custom-user-symbols/#comments</comments>
		<pubDate>Thu, 26 Jun 2008 12:22:25 +0000</pubDate>
		<dc:creator>Robert Dupuy</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<category><![CDATA[Diagram]]></category>

		<guid isPermaLink="false">http://blogs.ilog.com/netvisu/2008/06/26/creating-default-anchors-for-custom-user-symbols/</guid>
		<description><![CDATA[This article describes how to create default anchors on custom user symbols with <a href="http://www.ilog.com/products/diagrammernet/">ILOG Diagrammer for .NET</a>.

First, we need to make sure that we know what anchors and user symbols are. Let's briefly define these two notions:
<ul>
	<li>A <strong>user&#8230;</strong></li></ul>]]></description>
			<content:encoded><![CDATA[<p>This article describes how to create default anchors on custom user symbols with <a href="http://www.ilog.com/products/diagrammernet/">ILOG Diagrammer for .NET</a>.</p>
<p>First, we need to make sure that we know what anchors and user symbols are. Let&#8217;s briefly define these two notions:</p>
<ul>
<li>A <strong>user symbol</strong> is a graphic object built with the<strong> </strong><span id="nsrTitle"><strong>ILOG Diagrammer for .NET Diagram Designer</strong>. This designer, fully integrated into Visual Studio, is a WYSIWYG editor that produces C# or VB.NET code. Using this editor, you can build complex interactive symbols by assembling available shapes and symbols.</span></li>
<li>An anchor is a point on a graphic object where a link can be connected. Each graphic object has a collection of anchors on which it&#8217;s possible to connect links.</li>
</ul>
<p>Now that we know what we&#8217;re talking about, we can imagine the following scenario: A user has created a custom user symbol using our designer, and he wants to specify the exact location where links could be connected to this symbol. For example, when designing an electrical symbol, one need to specify that wires can be connected to the component terminals. Here is an example of such a symbol:</p>
<p><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/transistor.png" title="Transistor"><img src="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/transistor.png" alt="Transistor" /></a></p>
<p>Let&#8217;s create this symbol in Visual Studio:</p>
<ol>
<li>Launch Visual Studio 2005 or 2008.</li>
<li>Select <strong>File</strong>-&gt;<strong>New</strong>-&gt;<strong>Project</strong>-&gt;<strong>ILOG Diagrammer Symbol Library</strong> and name the project <strong>ElectricalSymbolsLibrary</strong>.</li>
<li>In the solution explorer, right click on the project, and choose <strong>Add New Item</strong>-&gt;<strong>UserSymbol (ILOG Diagrammer) </strong>and name the symbol <strong>Transistor.cs.</strong></li>
<li>Choose <strong>Diagrammer</strong>-&gt;<strong>Import File</strong> and import <strong>transistor.ivn</strong> after extracting it from the following <a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/transistor.zip">archive</a>. Click <strong>Yes</strong> in the dialog asking if you want to import the file as vector graphics.</li>
</ol>
<p>You should now have your transistor symbol visible in the designer:</p>
<p><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical.png" title="ILOG Diagrammer for .NET Diagram Designer"><img src="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical.png" alt="ILOG Diagrammer for .NET Diagram Designer" /></a></p>
<p>Let&#8217;s now use this new symbol in a diagram so that we can try to connect links to it. To add a diagram to the project, right-click in the solution explorer on the project and choose <strong>Add</strong>-&gt;<strong>New Item</strong>-&gt;<strong>Diagram (ILOG Diagrammer). </strong>Compile the project (<strong>Build</strong>-&gt;<strong>Build Solution</strong>) to update the toolbox. Open the toolbox, your new transistor symbol should be available:</p>
<p><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical2.png" title="ILOG Diagrammer for .NET Diagram Designer"><img src="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical2.png" alt="ILOG Diagrammer for .NET Diagram Designer" /></a></p>
<p>Drag a transistor symbol from the toolbox to the design surface. Repeat the operation to have several symbols in the diagram. You should now have something like this:</p>
<p><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical3.png" title="ILOG Diagrammer for .NET Diagram Designer"><img src="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical3.png" alt="ILOG Diagrammer for .NET Diagram Designer" /></a></p>
<p>Let&#8217;s now try to connect the transistors together by creating links between them. Open the toolbox and locate the <strong>Connectors</strong> tab. Click on one of the links available in the tab, then move the mouse over one of the transistors. The anchors where the link can be connected are highlighted:</p>
<p><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical4.png" title="Anchors highlighted"><img src="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical4.png" alt="Anchors highlighted" /></a></p>
<p>We can see that by default a user symbol has four anchors, each one located at the middle of the bounding box sides. Obviously, that&#8217;s not what we want here. One way to get the right anchors is to edit each transistor instance by modifying its anchors collection: After removing the default anchors (set the <strong>UseDefaultAnchors</strong> property to <strong>false</strong>), add three <strong>BoundsAnchor</strong> to the anchors collection (right-click on the transistor, and choose <strong>Edit Anchors&#8230;</strong>). Then, we need to move each anchor at the desired location. To do this, choose the <strong>Edit Anchors</strong> (<a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical5.png" title="Edit Anchors"><img src="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical5.png" alt="Edit Anchors" /></a>) icon from the Diagrammer toolbar and move the mouse over the transistor. It&#8217;s now possible to move the three anchors previously added to their right location by clicking each anchor and dragging it to its desired location. Then, if we go back to the link mode connection by clicking on a link in the toolbox <strong>Connectors</strong> tab, we can see by passing the mouse over it, that our transitor has now its anchors placed at their right location:</p>
<p><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical6.png" title="Electrical"><img src="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical6.png" alt="Electrical" /></a></p>
<p>The main drawbacks of this approach are:</p>
<ul>
<li>The anchors are not part of the symbol itself, since they have been added after the symbol creation. If you create an instance of this symbol by code, your new anchors will not be available.</li>
<li>We&#8217;re not using the default anchors feature of the graphic objects, and thus, anchors are created and added to the component model even though there are no links connected to them. This can be a performance issue if you have many objects with many anchors.</li>
</ul>
<p>An alternative to this approach is to define the default anchors directly when designing the transistor. How can we do this ? Let&#8217;s go back to the designer view of our transistor by double clicking the <strong>Transistor.cs</strong> file in the <strong>Solution Explorer</strong>. The trick is that all the real anchors (not the default ones) defined in the sub objects of our transistor will be exposed as default anchors for our user symbol. Thus, we simply need to add three anchors on the sub objects composing our transistor. Let&#8217;s see how to do it.</p>
<p>If you look at the <strong>Document Outline</strong> view in Visual Studio, you will see that our transistor is composed of several shapes:</p>
<p><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical7.png" title="Electrical7"><img src="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical7.png" alt="Electrical7" /></a></p>
<p>The interesting objects are the <strong>polyline1</strong>, <strong>polyline2</strong> and <strong>line1</strong> objects. On each one, we will add a new <strong>PolyPointsAnchor</strong>, which is a type of anchor whose location is bound to a vertex of a polyline object. Right-click on the <strong>polyline1</strong> object in the designer view, and choose  <strong>Edit Anchors</strong>. Add a <strong>PolyPointsAnchor </strong>and click the <strong>OK</strong> button. Repeat the operation for the <strong>polyline2</strong> and <strong>line1</strong> objects. Note that in our example, the anchors are located on the first vertex of each polyline, which is the default for <strong>PolyPointsAnchor</strong> objects<strong>.</strong></p>
<p>Let&#8217;s compile the project and switch back to our diagram view to test our transistor by double clicking the <strong>Diagram1.cs</strong> file in the <strong>Solution Explorer</strong>. To start with a fresh diagram, remove existing instances of the transistors. Then drag and drop a new transistor from the toolbox and try to connect a link to see that the highlighted anchors are the expected ones:</p>
<p><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical8.png" title="Electrical8"><img src="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/06/electrical8.png" alt="Electrical8" /></a></p>
<p>We&#8217;ve successfully changed the default anchors of our transistor, without having to write a single line of code.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.ilog.com/netvisu/2008/06/26/creating-default-anchors-for-custom-user-symbols/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Licensing in .NET explained - Part 2</title>
		<link>http://blogs.ilog.com/netvisu/2008/05/22/licensing-in-net-explained-part-2/</link>
		<comments>http://blogs.ilog.com/netvisu/2008/05/22/licensing-in-net-explained-part-2/#comments</comments>
		<pubDate>Thu, 22 May 2008 09:21:16 +0000</pubDate>
		<dc:creator>Robert Dupuy</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://blogs.ilog.com/netvisu/2008/05/22/licensing-in-net-explained-part-2/</guid>
		<description><![CDATA[In the <a href="http://blogs.ilog.com/netvisu/2008/05/13/licensing-in-net-explained-part-1/">first part of this article</a>, we've seen how to deal with licensed components from the user point of view. In the second part, I'll try to explain the whole licensing process, that is:
<ol>
	<li>Authoring licensed components.</li>
	<li>Creating licences at&#8230;</li></ol>]]></description>
			<content:encoded><![CDATA[<p>In the <a href="http://blogs.ilog.com/netvisu/2008/05/13/licensing-in-net-explained-part-1/">first part of this article</a>, we&#8217;ve seen how to deal with licensed components from the user point of view. In the second part, I&#8217;ll try to explain the whole licensing process, that is:</p>
<ol>
<li>Authoring licensed components.</li>
<li>Creating licences at design-time.</li>
<li>Creating licences at compile-time.</li>
<li>Creating licences at run-time.</li>
</ol>
<h2>Authoring licensed components</h2>
<p>I&#8217;ll not spend too much time on that topic, as it&#8217;s widely documented on the web (see for example <a href="http://msdn.microsoft.com/en-us/library/fe8b1eh9.aspx">this article</a>).</p>
<p>The process is simple. After creating your component, you have to:</p>
<ol>
<li>Apply a <a href="http://msdn2.microsoft.com/en-us/library/system.componentmodel.licenseproviderattribute(VS.71).aspx" onclick="javascript:Track('ctl00_rs1_mainContentContainer_ctl00|ctl00_rs1_mainContentContainer_ctl02',this);" id="ctl00_rs1_mainContentContainer_ctl02">LicenseProviderAttribute</a> to the class.</li>
<li>Call <a href="http://msdn2.microsoft.com/en-us/library/system.componentmodel.licensemanager.validate(VS.80).aspx">LicenseManager.Validate</a> from the class constructor to get a licence.</li>
<li>Dispose the licence in the component finalizer.</li>
</ol>
<p>The licence provider specified by the <strong>LicenseProviderAttribute</strong> attribute in step 1 is used during step 2: Calling <strong>LicenseManager.Validate</strong> in your component constructor will create an instance of this license provider, and will call its <a href="http://msdn2.microsoft.com/en-us/library/system.componentmodel.licenseprovider.getlicense(VS.80).aspx">GetLicense</a> method to get a licence. If no licence can be found, <strong>LicenseManager.Validate</strong> will throw an exception, making your component unusable.</p>
<p>Specifying the licence provider has also another usage: It&#8217;s used by Visual Studio to know whether a component is licensed or not. Indeed, as we&#8217;ve seen in the first part of this article, Visual Studio manages a <strong>licenses.licx</strong> file containing all the licensed components used in a project.</p>
<p>Microsoft provides the <a href="http://msdn2.microsoft.com/en-us/library/system.componentmodel.licfilelicenseprovider(VS.80).aspx"><span class="linkTerms">LicFileLicenseProvider</span></a> class, a ready-to-use licence provider. But if you need to implement your own logic, you have to create a new licence provider by subclassing the <strong>LicenseProvider</strong> class. That&#8217;s what we&#8217;ve done here at ILOG for our .NET products (<a href="http://www.ilog.com/products/ganttnet/">ILOG Gantt for .NET</a> and <a href="http://www.ilog.com/products/diagrammernet/">ILOG Diagrammer for .NET</a>) because we wanted to implement ILM (ILOG License Manager). Subclassing the <strong>LicenseProvider</strong> class is relatively simple, as you just need to override the <a href="http://msdn2.microsoft.com/en-us/library/system.componentmodel.licenseprovider.getlicense(VS.80).aspx">GetLicense</a> method. We&#8217;ll see later how to implement this method.</p>
<p>The <strong>LicenseProvider</strong> will be used in three different contexts:</p>
<ul>
<li>At design-time.</li>
<li>At compile-time.</li>
<li>At run-time.</li>
</ul>
<h2>Creating licences at design-time</h2>
<p>Here we assume that we&#8217;re building an application that contains licensed components using Visual Studio. The typical way to do it is to drag and drop a toolbox item onto the design surface, which results in the instantation of the component. As the licence checking is done in the component constructor, a licence has to be provided at that time. Let&#8217;s see how to handle this case in the <a href="http://msdn2.microsoft.com/en-us/library/system.componentmodel.licenseprovider.getlicense(VS.80).aspx">LicenseProvider.GetLicense</a> method through a partial implementation:</p>
<pre>public override License GetLicense(
    LicenseContext context,
    Type type,
    object instance,
    bool allowExceptions)
{
    //
    // The context parameter indicates the context
    // in which the component is used.
    //
    bool runtime = context.UsageMode == LicenseUsageMode.Runtime;                 

    if (runtime)
    {
        //
        // Will see later what to do here
        //
    }
    else
    {
        //
        // Here we are designing our application, so we need to
        // get a licence that we will store in the context.
        //                 

        //
        // We're calling the GetDesignTimeLicenseKey() method to get a licence.
        // The code for this method is not provided here, but a simple
        // implementation could be to look in the registries or in a specific
        //  file to check that a valid licence has been installed on this computer.
        // The implementation of this method depends on the licensing schema
        // you want to set up.
        //
        string licenseKey = GetDesignTimeLicenseKey(type);                 

        //
        // If no licence was found, error
        //
        if (licenseKey == null)
        {
            if (allowExceptions)
                throw new LicenseException();
            return null;
        }                

        //
        // Save the licenseKey in the context. It will be possible at runtime to
        // retrieve it.
        //
        context.SetSavedLicenseKey(type, licenseKey);                

        //
        // We create and return a new CustomLicence object using
        // the licenseKey. The code for the CustomLicense class is
        // straightforward, as it's a simple implementation of the License
        // class. It's given below.
        //
        return new CustomLicense(licenseKey);
    }
}               

class CustomLicense : License
{
    private string _key;
    public CustomLicense(string Key)
    {
        _key = key;
    }
    public override string LicenseKey
    {
        get
        {
            return _key;
        }
    }
}</pre>
<p>To sum up, the creation of a licence at design time is a 3 steps process:</p>
<ol>
<li>Get the licence key installed on the computer. It can be a licence file, or a registry key&#8230;It depends on the way you want to manage the installation of licence keys on development computers.</li>
<li>Sets the licence key into the licence context. This will make it possible to retrieve the licence key at runtime.</li>
<li>Create a <strong>License</strong> object using this licence key.</li>
</ol>
<p>Note : The <strong>License</strong> class is a .NET class that encapsulates the licence key, which is a simple string.</p>
<p>The <strong>LicenseContext</strong> used by Visual Studio and passed as the first parameter of the <a href="http://msdn2.microsoft.com/en-us/library/system.componentmodel.licenseprovider.getlicense(VS.80).aspx">GetLicense</a> method is said to be a &#8220;design-time&#8221; context, that is, a context whose <strong>UsageMode</strong> property returns <strong>LicenseUsageMode.DesignTime</strong>.</p>
<h2>Creating licences at compile-time</h2>
<p>Once the application has been designed, it needs to get compiled. As we&#8217;ve seen in the <a href="http://blogs.ilog.com/netvisu/2008/04/22/remix-08-in-paris/">first part of this article</a>, Visual Studio invokes the licence compiler to compile the <strong>licenses.licx</strong> file into an assembly resource file.</p>
<p>The licence compiler takes a .<strong>licx</strong> file as input and produces a resource file as output. It parses the .<strong>licx</strong> file and create an instance of each type found in it. The <strong>LicenseContext</strong> used by the licence compiler is a design-time context, an instance of the <a href="http://msdn2.microsoft.com/en-us/library/system.componentmodel.design.designtimelicensecontext(VS.85).aspx">DesignTimeLicenseContext</a> class. For each component created, a corresponding licence is also created and is stored in the licence context in a hash table. This hash table is then dumped it into a resource file.</p>
<p>This resource file will be used differently at run-time depending on the application type your&#8217;re creating, as explained in the <a href="http://blogs.ilog.com/netvisu/2008/04/22/remix-08-in-paris/">first part of this article</a>.</p>
<h2>Creating licences at run-time</h2>
<p>As for design-time and compile-time, licence checking will take place at run-time each time a licensed component gets instantiated. The difference is that the <strong>LicenseContext</strong> used will be a run-time licence context, that is, a context whose <strong>UsageMode</strong> property returns <strong>LicenseUsageMode.RunTime</strong>. This context will be able to retrieve the licences compiled with the licence compiler. Here is the a partial implementation of the <a href="http://msdn2.microsoft.com/en-us/library/system.componentmodel.licenseprovider.getlicense(VS.80).aspx">LicenseProvider.GetLicense</a> method:</p>
<pre>public override License GetLicense(
    LicenseContext context,
    Type type,
    object instance,
    bool allowExceptions)
{
    //
    // The context parameter indicates the context in
    // which the component is used.
    //
    bool runtime = context.UsageMode == LicenseUsageMode.Runtime;                 

    if (runtime)
    {
        //
        // At runtime, look into the context to find the licence.
        // Depending on the application type, the context may look into
        // the application resources (Windows Forms), or the
        // App_Licenses.dll assembly (Web sites)...
        //
        string licenceKey = context.GetSavedLicenseKey(type, null);                

        if (licenceKey != null)
            return new CustomLicense(licenceKey);           

        if (allowExceptions)
            throw new LicenseException();
        else
            return null;
    }
    else
    {
        //
        // Already covered in the "design-time" section
        //
    }
}</pre>
<p>The interesting part here is the call to the <a href="http://msdn.microsoft.com/en-us/library/system.componentmodel.licensecontext.getsavedlicensekey.aspx">LicenseContext.GetSavedLicenseKey</a> method. It will look into the context to see if a licence for the specified type can be found. Depending on the application type (assembly based applications, web sites, windows forms hosted in IE), the context will look in the appropriate location to find the licence.</p>
<h2>Conclusion</h2>
<p>We&#8217;ve seen in this article how the licences were created during the three phases of an application development: design-time, compile-time, run-time. Of course the code given was simpified for the purpose of this article, but you can imagine to enrich it by adding cryptography or anything that can make your licence management more secure.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.ilog.com/netvisu/2008/05/22/licensing-in-net-explained-part-2/feed/</wfw:commentRss>
		</item>
		<item>
		<title>Licensing in .NET explained - Part 1</title>
		<link>http://blogs.ilog.com/netvisu/2008/05/13/licensing-in-net-explained-part-1/</link>
		<comments>http://blogs.ilog.com/netvisu/2008/05/13/licensing-in-net-explained-part-1/#comments</comments>
		<pubDate>Tue, 13 May 2008 11:57:14 +0000</pubDate>
		<dc:creator>Robert Dupuy</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://blogs.ilog.com/netvisu/2008/05/13/licensing-in-net-explained-part-1/</guid>
		<description><![CDATA[<a rel="attachment wp-att-36" href="http://blogs.ilog.com/netvisu/?attachment_id=36" title="licence resource in Reflector"></a>Authoring licensed .NET components is explained in several places over the web. But I was not able to find an article that would cover all the aspects of licensing in .NET. That's why I decided to write this article, and&#8230;]]></description>
			<content:encoded><![CDATA[<p><a rel="attachment wp-att-36" href="http://blogs.ilog.com/netvisu/?attachment_id=36" title="licence resource in Reflector"></a>Authoring licensed .NET components is explained in several places over the web. But I was not able to find an article that would cover all the aspects of licensing in .NET. That&#8217;s why I decided to write this article, and I hope things will be clearer after reading it.</p>
<p>First, what is the purpose of licensing ? It&#8217;s a mechanism that makes sure that only users with a valid licence can use a component. The .NET framework has a built-in licensing mechanism that makes it easy to author licensed components. From the component user point of view, it also has a great support in Visual Studio, which makes the use of licensed components easy. In this first article, we&#8217;ll focus on how to use licensed components.</p>
<h2>Using Licensed Components with Visual Studio</h2>
<p>Using licensed components inside Visual Studio is completely transparent for the user. The usual way to use components in Visual Studio is to drag and drop them from the toolbox onto a design surface: When a toolbox item is dropped onto a design surface, Visual Studio creates an instance of the component represented by the toolbox item and adds it to the designer. If the component created is a licensed component, Visual Studio also adds a <strong>licences.licx</strong> file to the Visual Studio project.</p>
<p>The <strong>licences.licx</strong> file contains the type names of the licensed components used in a Visual Studio project. Here is an example:</p>
<pre>ILOG.Views.Gantt.Windows.Forms.ActivityTable, ILOG.Gantt
ILOG.Views.Gantt.Windows.Forms.ResourceTable, ILOG.Gantt
ILOG.Views.Gantt.Windows.Forms.GanttChart, ILOG.Gantt</pre>
<p>The <strong>licences.licx</strong> file is updated each time a new licensed component is added to the designer. You can also create or edit this file by hand. You must do this for example if you don&#8217;t create the components by dragging them from the toolbox.</p>
<p>The <strong>.licx</strong> files are associated in Visual Studio with the licence compiler tool (<strong><a href="http://msdn.microsoft.com/en-us/library/ha0k3c9f(VS.80).aspx">lc.exe</a></strong>). When building your project, the license compiler is run with the licence file as parameter. Compiling the licences produces a resource file that will be used at runtime by the application. Let&#8217;s see now in details how the compiled licences are used at runtime, depending on the application type you&#8217;re building.</p>
<h3>Assembly-based Applications</h3>
<p>This category of applications regroups all the applications that are assembly based, that is, applications whose ouput produce an assembly. It contains <strong>Windows Forms</strong> applications, <strong>WPF</strong> applications, <strong>Silverlight</strong> applications, as well as class libraries. It also contains Web project applications. For these applications, the compiled licences are automatically embedded in the resources of the application assembly when the project gets compiled. For example, let&#8217;s say I have a Windows Forms application called <strong>GanttEditor.exe</strong> that&#8217;s using licensed components. After compiling the application, we can check that a licence resource has been added to the application resources. To do this, I use Reflector, my favorite .NET disassembler :</p>
<p><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/04/licenseresource.png" title="licence resource in Reflector"></a><a rel="attachment wp-att-36" href="http://blogs.ilog.com/netvisu/?attachment_id=36" title="licence resource in Reflector"></a><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/04/licenseresource.png" title="licence resource in Reflector"></a><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/04/licenseresource.png" title="Licence resource in Reflector"></a><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/04/licenseresource2.png" title="License resource in Reflector"><img src="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/04/licenseresource2.png" alt="License resource in Reflector" /></a><a href="http://blogs.ilog.com/netvisu/wp-content/uploads/2008/04/licenseresource.png" title="licence resource in Reflector"></a></p>
<p>The <strong>licences.licx</strong> file has been compiled into a resource called <strong>GanttEditor.exe.licenses</strong>.</p>
<h3>Web Sites Applications</h3>
<p>In Visual Studio, a Web Site is a special project, as there&#8217;s no real project file. Instead, all the files located under the web site directory are part of the web site. When a licensed component is dropped into a <strong>Web Form</strong> designer, Visual Studio creates a <strong>licenses.licx</strong> file and adds it to the web site directory. This licence file is compiled into an assembly named <strong>App_Licenses.dll</strong>, located in the web site <strong>Bin</strong> directory. This assembly will be loaded at runtime to locate the licences. Note that you can force the generation of the <strong>App_Licenses.dll </strong>assembly by right-clicking the <strong>licenses.licx</strong> file in the solution explorer, and choosing the &#8220;Build Runtime Licenses&#8221; menu item.</p>
<h2>Using Licensed Components without Visual Studio</h2>
<p>For some reasons, you may not use Visual Studio to create your application. In this case, you&#8217;ll have to integrate the licence into your application by yourself. These are the steps to follow:</p>
<ol>
<li>Create and edit you own <strong>licenses.licx</strong> file.</li>
<li>Compile the <strong>licenses.licx</strong> file using the licence compiler (<strong>lc.exe</strong>).</li>
<li>Integrate the compiled licence file into the application.</li>
</ol>
<p>The last step depends on the type of application you&#8217;re building. For example, in a Windows Forms application, you have to put the compiled licence as an emdedded resource of the application (using the /resource option of the c# compiler if it&#8217;s a c# application). When hosting Windows Forms controls in IE, the process is different, and is described in the next section.</p>
<h3>Windows Forms controls hosted in Internet Explorer</h3>
<p>Embedding a Windows Forms control in Internet Explorer can be painful for two reasons:</p>
<ul>
<li><strong>Code Access Security</strong> : When running into Internet Explorer, the hosted control doesn&#8217;t have the same permissions as if it was run as a desktop application. Configuring the CAS is not a simple task, as well as finding the minimum permissions required by a control to work properly inside IE.</li>
<li><strong>Licence Management</strong> : You have to compile the licences by yourself.</li>
</ul>
<p>Let&#8217;s illustrate how to manage licences with a very simple example: You want to embed a <strong>GanttChart</strong> (located in the <strong>ILOG.Gantt.dll</strong> assembly) into the <strong>default.htm</strong> page. As the <strong>GanttChart</strong> is a licensed component, you&#8217;ll have to provide an entry for it in the <strong>licenses.licx</strong> file:</p>
<pre>ILOG.Views.Gantt.Windows.Forms.GanttChart, ILOG.Gantt</pre>
<p>Then, you&#8217;ll have to compile this file using the licence compiler:</p>
<pre>lc.exe /target:default.htm /complist:licenses.licx /i:ILOG.Gantt.dll </pre>
<p>the /<strong>target</strong> parameter must be the page in which the licence will be used,</p>
<p>the /<strong>complist</strong> parameter is the .licx file to compile,</p>
<p>the /<strong>i</strong> parameter indicates the assemblies needed to compile the licence.</p>
<p>The licence compiler will produce a file named <strong>default.htm.licenses</strong>. Now, we need to use this file in the HTML page as shown below: </p>
<pre>&lt;html&gt;
...
&lt;HEAD&gt;
...
&lt;LINK REL="licenses" href="default.htm.licenses" mce_href="default.htm.licenses" /&gt;
...
&lt;/HEAD&gt;
...
&lt;OBJECT id="ganttControl" height="300" width="800" classid="ILOG.Gantt.dll#ILOG.Views.Gantt.Windows.Forms.GanttChart" /&gt;
...
&lt;/html&gt;</pre>
<p>The &lt;<strong>OBJECT</strong>&gt; tag is used to insert the control in the HTML page, and the &lt;<strong>LINK</strong>&gt; tag is used to indicate where the licence can be found.</p>
<h2>Conclusion </h2>
<p>We&#8217;ve seen two different ways to use licensed components in .NET: With or without Visual Studio. When using Visual Studio, it takes care of everything. When not using it, you need to do things by yourself.</p>
<p>Now, from a developper point of view, it would be interesting to understand how the licence compiler works, and how to author licensed components. That will be the subject of a second article.</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.ilog.com/netvisu/2008/05/13/licensing-in-net-explained-part-1/feed/</wfw:commentRss>
		</item>
		<item>
		<title>REMIX 08 in Paris</title>
		<link>http://blogs.ilog.com/netvisu/2008/04/22/remix-08-in-paris/</link>
		<comments>http://blogs.ilog.com/netvisu/2008/04/22/remix-08-in-paris/#comments</comments>
		<pubDate>Tue, 22 Apr 2008 13:52:44 +0000</pubDate>
		<dc:creator>Robert Dupuy</dc:creator>
		
		<category><![CDATA[.NET]]></category>

		<guid isPermaLink="false">http://blogs.ilog.com/netvisu/2008/04/22/remix-08-in-paris/</guid>
		<description><![CDATA[The <strong>REMIX 08</strong> event that took place in Paris on April 17th is the smaller and free edition of the <strong>MIX</strong> conference of Las Vegas. I attented the session named "Be creator of differences". It was the occasion for Microsoft to show how Silverlight and WPF can&#8230;]]></description>
			<content:encoded><![CDATA[<p>The <strong>REMIX 08</strong> event that took place in Paris on April 17th is the smaller and free edition of the <strong>MIX</strong> conference of Las Vegas. I attented the session named &#8221;Be creator of differences&#8221;. It was the occasion for Microsoft to show how Silverlight and WPF can be used to create rich interactive applications. Microsoft also reaffirmed its will to integrate designers in the development cycle of RIAs, by using the Studio Expression products.</p>
<p>In the introduction, the speaker, Dick Lantim, has redefined the <strong>RIA</strong> acronym that usually stands for &#8220;Rich Internet Application&#8221;. For Microsoft, RIA means &#8220;Rich Interactive Application&#8221;. This concept includes both <strong>RDA</strong>s (Rich Desktop Applications) and <strong>RIA</strong>s (Rich Internet Applications). For each of these applications Microsoft has an answer which is WPF for the desktop, and Silverlight for the browser. Using these technologies, the three main platforms of RIAs can be addressed : <strong>PC</strong> (WPF), <strong>Mobile</strong> and <strong>Web</strong> (Silverlight). Note that for the mobiles, Microsoft has announced that Silverlight will be available on Windows Mobile and Symbian.</p>
<p>Some WPF demos were shown, as well as Silverlight 2 demos. For Microsoft, the target is clearly to make Silverlight as visible as possible, and to put it as an alternative to Flash: Several Silverlight demos were based on existing applications developed with Flash, to emphasize on the Silverlight strengths.</p>
<p>As the release date of Silverlight 2 approaches (August 08), the differences between WPF and Silverlight in terms of features are becoming subtle. The big differences are:</p>
<ul>
<li>WPF can access the computer resources (files, &#8230;).</li>
<li>WPF supports 3D.</li>
<li>WPF can only be used on a PC where the .NET Framework is installed.</li>
</ul>
<p> Interesting points that were covered:</p>
<ul>
<li>Deep Zoom : A built-in load on demand technology for huge images on Silverlight. Huge images are tiled using the Deep Zoom Composer tool. Then, the MultiScaleImage object is used to display the tiles.</li>
<li>Pages Indexation : Web sites containing dynamic pages (ASP.NET, AJAX, &#8230;) or Silverlight controls are difficult to index by search engines. Several solutions can be used to solve this problem, such as mirroring the dynamic web site by a static web site containing only HTML. Another solution is to detect that a crawler is indexing the site, and to dynamically create the pages for the crawler.</li>
</ul>
<p> Robert Dupuy</p>
]]></content:encoded>
			<wfw:commentRss>http://blogs.ilog.com/netvisu/2008/04/22/remix-08-in-paris/feed/</wfw:commentRss>
		</item>
	</channel>
</rss>
