Infralution Support Forum Index Infralution Support
Support groups for Infralution products
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Inheriting AuthenticatedLicenseInstallForm

 
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support
View previous topic :: View next topic  
Author Message
hypehuman



Joined: 18 Sep 2013
Posts: 25

PostPosted: Mon Oct 21, 2013 8:29 pm    Post subject: Inheriting AuthenticatedLicenseInstallForm Reply with quote

I want this form to close immediately when a valid license is installed. I managed to produce this behavior by modifying the UpdateLicenseInfo method.

However, it has been advised that we use child classes and override methods instead of modifying the ILS source code, as this will make it easier to update to new versions of ILS. I have done this for AuthenticatedLicense and AuthenticatedLicenseProvider, and everything works fine for those to classes.

When I derive from AuthenticatedLicenseInstallForm, the derived class does not properly instantiate. This code works fine:
Code:
...
    License = new AuthenticatedLicenseInstallForm().ShowDialog(sLicenseProvider, sLicense);
...

This code does not:
Code:
...
    License = new Derived().ShowDialog(sLicenseProvider, sLicense);
...
    public class Derived : AuthenticatedLicenseInstallForm
    {
    }
...

The second block hangs in AuthenticatedLicenseInstallForm's constructor. AuthenticatedLicenseInstallForm.InitializeComponent() never returns control.
Back to top
View user's profile Send private message
hypehuman



Joined: 18 Sep 2013
Posts: 25

PostPosted: Mon Oct 21, 2013 9:29 pm    Post subject: Reply with quote

This appears to only happen when the Derived class is defined in a separate project from the AuthenticatedLicenseInstallForm project.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Tue Oct 22, 2013 6:41 am    Post subject: Reply with quote

I just tried this in VS2012 and could not replicate any issue. I created a separate file for the derived form and added the following code:

Code:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Infralution.Licensing.Forms;
namespace AuthenticatedApp_CS
{
    class Derived : AuthenticatedLicenseInstallForm
    {
        private void InitializeComponent()
        {
            this.buttonPanel.SuspendLayout();
            this.SuspendLayout();
            //
            // Derived
            //
            this.ClientSize = new System.Drawing.Size(605, 197);
            this.Name = "Derived";
            this.buttonPanel.ResumeLayout(false);
            this.ResumeLayout(false);
            this.PerformLayout();

        }

        public Derived()
        {
            InitializeComponent();
        }
    }
}


I assume you are using Windows Forms not WPF?

If you can replicate the issue in a small sample project and send it to support@infralution.com then I will take a look.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
hypehuman



Joined: 18 Sep 2013
Posts: 25

PostPosted: Fri Oct 25, 2013 1:45 pm    Post subject: Reply with quote

I am using WPF in VS 2010. I am sending the sample project. In the sample project, the derived constructor crashes instead of hanging.
Back to top
View user's profile Send private message
Infralution



Joined: 28 Feb 2005
Posts: 5027

PostPosted: Fri Oct 25, 2013 11:39 pm    Post subject: Reply with quote

Unlike Windows Forms, WPF was not designed to really support extension of user interface components by inheritance. In particular controls/forms that use XAML cannot be inherited in another assembly because of a limitation in the way that InitializeComponent is implemented by Microsoft. See the following thread on this issue:

http://stackoverflow.com/questions/7646331/the-component-does-not-have-a-resource-identified-by-the-uri

If you want to modify the visual appearance of a WPF XAML control/window then you have to basically copy the form XAML and code to a new window. If you just want to modify a small amount of behaviour by overriding some of the methods of the form then an alternative would be to copy the AuthenticatedLicenseInstallForm into your own project and the derive from it in the same project. That way if the base class is updated it is easy to replace the copy in your project while still retaining your distinct behaviour.
_________________
Infralution Support
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    Infralution Support Forum Index -> Licensing Support All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group