Initializing license key from a modular applicatio

We’re using the GoXam diagram components from a WPF module (Prism IModule). It makes no sense for us to have the shell application reference the GoXam components, since not all users will be using the module that loads the diagram. Since we have to initialize the license in the application’s entry point, this poses a problem. To further complicate things, this module can also be hosted by a WinForms application.

What strategies have others employed to prevent the shell application from knowing anything about GoXam?

When a GoXam WPF control is hosted in a Windows Forms application, there isn’t any natural System.Windows.Application object. But you can create it yourself by subclassing System.Windows.Application and making sure the Diagram.LicenseKey statement is in its constructor. You can just copy the code from MinimalApp’s App.xaml.cs:

public class App : System.Windows.Application { public App() { // To deploy an application, purchase a development license. // Run the GoXam License Manager and install the development license. // Then run the GoXam License Manager and: // - click on "Deploy an Application" // - choose "Northwoods.GoWPF" // - enter the name of your application; this sample is named "GoWpfMinimal" // - paste from the clipboard right here: //Northwoods.GoXam.Diagram.LicenseKey = "... substitute the app-specific run-time license key here ..."; } }

Then when your GoXam-using module is loaded, you can see if Application.Current exists. If it’s null, just construct a new App. This will automatically set Application.Current.

if (System.Windows.Application.Current == null) new App();
I haven’t tested this recently, so pardon me if I have some typos here. I know that this basic scheme will work. You might be able to find other posts in this forum about it too.

I should have searched first:
Initializing LicenseKey in a WinForms app

Thanks…that definitely solves the WinForms host issue.

What about not having the main application know about GoXam? Only the module loading the diagram should have a reference to it in a modular application.

A Windows Forms application doesn’t need to have a reference to GoXam for the code in this forum topic to work.

Whoever makes the call to Northwoods.GoXam.Diagram.LicenseKey = “” needs a reference to GoXam. In the case of WinForms, I guess it wouldnt. The project hosting the custom Application class does. But what about in a WPF app, where you’re making this call in App.xaml.cs? That project will definitely have to have a reference to GoXam, or it can’t set the license key.

Oh, I see, you are talking about two different situations. I thought you were just talking about add-ins to your WinForms app.

Do you build that WPF shell app? It doesn’t do any harm to have that reference to GoXam, since Northwoods.GoXam.dll doesn’t depend on anything that every WPF app would depend on anyway. And which version of GoWPF are you using?

Yeah, sorry…this module gets deployed into both a WinForms app and a WPF composite app. I would rather not have the main shell reference GoXam, since not all customers will be using (purchasing) the module that contains the diagram. I’ve thought about having the shell use reflection to find and manipulate the GoXam Diagram license property, but upon startup, the diagram module is not yet loaded so that won’t work either.

The GoXam version we’re using is: 1.3.2.4

Thanks for your quick replies!

Any ideas on this, or is the answer to have the shell application reference GoXam and have it deployed with the shell, regardless of whether or not the diagram module is needed for that deployment?

That will work. There might be other possibilities that we can discuss by e-mail.