ActiveX license

This forum is meant for questions and discussions about the X# language and tools
Post Reply
User avatar
wriedmann
Posts: 3650
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

ActiveX license

Post by wriedmann »

Hi Robert, hi Chris,

I have a ActiveX control that is used with a license key in VO, with

Code: Select all

<oOLEControl>:CreateEmbedding(<cProgID>, [<cLicKey>]) ---> lSuccess
When moving that control to X# I have followed the recipes from the samples, but this one needs the license key passed as second parameter to CreateEmbedding in VO.
How can I pass that license string to my control object in X#?
Thank you very much!
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4243
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

ActiveX license

Post by robert »

Wolfgang,
Usually if you add an activeX to a windows form then a file Licenses.Licx will be added to your project. This will be included as resource in your project. And the ActiveX control will also persist its state including the license information in the form.resx file.
So you don't have to specify the key..
If that does not work then this is the code (in C#) that retrieves the private property of the AxHost (the host of the ActiveX control) and sets the key:

System.Reflection.FieldInfo f =
typeof(AxHost).GetField("licenseKey",
System.Reflection.BindingFlags.NonPublic |
System.Reflection.BindingFlags.Instance);
f.SetValue(oActiveXControl, "license-here");


Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3650
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

ActiveX license

Post by wriedmann »

Hi Robert,

thank you very much!

Now I have encountered another issue, I need to put all things together and let you know.

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
wriedmann
Posts: 3650
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

ActiveX license

Post by wriedmann »

Hi Robert,
we were able to make this OCX work in a C# application, and it used a lot of code to make the OCX work:

Code: Select all

System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Form1));
this.axEasyView1 = new AxEasyViewLib.AxEasyView();
((System.ComponentModel.ISupportInitialize)(this.axEasyView1)).BeginInit();
this.axEasyView1.Enabled = true;
this.axEasyView1.Location = new System.Drawing.Point(0, 0);
this.axEasyView1.Name = "axEasyView1";
this.axEasyView1.OcxState = ((System.Windows.Forms.AxHost.State)(resources.GetObject("axEasyView1.OcxState")));
this.axEasyView1.Size = new System.Drawing.Size(796, 455);
this.axEasyView1.TabIndex = 0;
this.Controls.Add(this.axEasyView1);
((System.ComponentModel.ISupportInitialize)(this.axEasyView1)).EndInit();
Unfortunately, copying this code to my (written) class it throws an exception of type

Code: Select all

System.Windows.Forms.AxHost+InvalidActiveXStateException
Do you have any idea where I can search? Is this in any manner combined to the license issue?

Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
User avatar
robert
Posts: 4243
Joined: Fri Aug 21, 2015 10:57 am
Location: Netherlands

ActiveX license

Post by robert »

Wolfgang,
You're most likely missing the axEasyView1.OcxState in the Resx file from the form.
Robert
XSharp Development Team
The Netherlands
robert@xsharp.eu
User avatar
wriedmann
Posts: 3650
Joined: Mon Nov 02, 2015 5:07 pm
Location: Italy

ActiveX license

Post by wriedmann »

Hi Robert,
yes, I think so. But hopefully I have a chance to do without it because in the migrated VO application there is no painted WinForms form.
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Post Reply