View previous topic :: View next topic |
Author |
Message |
hypehuman
Joined: 18 Sep 2013 Posts: 25
|
Posted: Mon Oct 21, 2013 8:29 pm Post subject: Inheriting AuthenticatedLicenseInstallForm |
|
|
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 |
|
|
hypehuman
Joined: 18 Sep 2013 Posts: 25
|
Posted: Mon Oct 21, 2013 9:29 pm Post subject: |
|
|
This appears to only happen when the Derived class is defined in a separate project from the AuthenticatedLicenseInstallForm project. |
|
Back to top |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Tue Oct 22, 2013 6:41 am Post subject: |
|
|
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 |
|
|
hypehuman
Joined: 18 Sep 2013 Posts: 25
|
Posted: Fri Oct 25, 2013 1:45 pm Post subject: |
|
|
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 |
|
|
Infralution
Joined: 28 Feb 2005 Posts: 5027
|
Posted: Fri Oct 25, 2013 11:39 pm Post subject: |
|
|
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 |
|
|
|