xsharp.eu • ActiveX license
Page 1 of 1

ActiveX license

Posted: Fri Oct 04, 2019 2:24 pm
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

ActiveX license

Posted: Fri Oct 04, 2019 2:52 pm
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

ActiveX license

Posted: Fri Oct 04, 2019 3:30 pm
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

ActiveX license

Posted: Fri Oct 04, 2019 3:47 pm
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

ActiveX license

Posted: Fri Oct 04, 2019 5:34 pm
by robert
Wolfgang,
You're most likely missing the axEasyView1.OcxState in the Resx file from the form.
Robert

ActiveX license

Posted: Fri Oct 04, 2019 6:50 pm
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