Licensing with .NET 6 App

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Licensing with .NET 6 App

Post by Christopher » Mon Apr 17, 2023 4:38 pm

Hello Kris,
Kris C wrote:
Fri Apr 14, 2023 12:06 pm
There are many different ways you could implement this. DevExpress XtraReports uses an ICommand where I can provide an implementation of an ICommand and provide that for a specific button in their UI. When that button is clicked, it would execute the command provided, in this case mine. Otherwise, it would use its own default command. The basic idea is to provide a hook so a custom code change by a user (i.e. me) is not required.
Well, one thing we could to is to provide an Action delegate for you to pass to. For example:

Code: Select all

        private void button1_Click(object sender, EventArgs e)
        {
            static void DoMyThing() 
            {
                var form = new Form
                {
                    Width = 300,
                    Height = 300
                };
                var label = new Label
                {
                    Text = "Hello World"
                };
                form.Controls.Add(label);

                form.StartPosition = FormStartPosition.CenterParent;
                form.ShowDialog();
            }

            ExportEditor.ShowModal(tChart1, DoMyThing);
        }
Which gives us:
https://steema.com/files/public/support ... 33-00.webm

Is this the kind of thing you had in mind?
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Kris C
Newbie
Newbie
Posts: 59
Joined: Fri Jan 13, 2023 12:00 am

Re: Licensing with .NET 6 App

Post by Kris C » Mon Apr 17, 2023 5:15 pm

Yes. I only see it if exceptions are "on". But I wanted to report it in case there was anything to it. You just never know.

We are still running into issues with licensing. We are working on getting a sample written that reproduces the issue. It's going to take us a little longer.

So, right now the TeeChart licensing isn't working with our product. We have TeeChart.licenses in the output folder and we're using the NuGet package. As soon as we get it reproducing in a sample project, we'll get it to you to take a look at it.

Kris

Kris C
Newbie
Newbie
Posts: 59
Joined: Fri Jan 13, 2023 12:00 am

Re: Licensing with .NET 6 App

Post by Kris C » Tue Apr 18, 2023 8:07 am

Hi Christopher,

After days of debugging, I was finally able to reproduce the issue of the NET6 licensing not working.

I've attached a zip file, NET6TeeChartLicenseIssue.zip, via the upload service under kris.culin@bentley.com.

Extract, build and run the project. Click Step 1 through 4. You'll see the licensing working and then not working. If you start again at Step 1, it will work again. I suggest running it *before* you look at the code.

See the click event of buttonStep3 for the key change that causes the licensing to stop working.

If you have any questions, let me know.

Thanks,

Kris Culin
Bentley Systems, Inc.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Licensing with .NET 6 App

Post by Christopher » Tue Apr 18, 2023 9:07 am

Hello Kris,
Kris C wrote:
Tue Apr 18, 2023 8:07 am
If you have any questions, let me know.
I'm afraid I can't build your project here, as it seems to be missing some dependencies—are these important to the reproduction of the problem? Can you reproduce the problem at your end without these dependencies?
Screenshot from 2023-04-18 11-05-23.png
Screenshot from 2023-04-18 11-05-23.png (98.62 KiB) Viewed 38235 times
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Licensing with .NET 6 App

Post by Christopher » Tue Apr 18, 2023 9:22 am

Hello Kris,

Okay, I can run the project deleting:

Code: Select all

    <Import Project="$(MSBuildProjectDirectory)\..\..\..\p4v-NET6\Aspen\Tools\Haestad.MSBuild\Assemblies\_LastKnownGood\Haestad.MSBuild.targets" />
    <Target Name="CopyBitSpecificLKG" AfterTargets="PostBuildEvent">
        <CopyToLastKnownGood SourceFiles="$(MSBuildProjectDirectory)\TeeChart.licenses" DestinationFolder="$(TargetDir)" />
    </Target>
From the TeeChartAreaProblem.csproj.

If I set TeeChart.licenses to 'Copy if newer', Step 4 works fine after Step 3 by commenting out the change of directory:

Code: Select all

//Directory.SetCurrentDirectory(Path.GetTempPath());
I would say that this is expected, given that the TeeChart assemblies are looking for that file in the current directory. If you change the Step 1 to:

Code: Select all

        private void buttonStep1_Click(object sender, EventArgs e)
        {
            //Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
            MessageBox.Show(this, $"Step 1 Complete, Current Directory:{Directory.GetCurrentDirectory()}", "Step 1");
        }
You can see that the default current directory is where both the TeeChart assemblies and the TeeChart.licenses file are located, which is why the former can find the latter. Of course if you set TeeChart.license to Embedded resource the TeeChart assemblies can find the file independently of the Current Directory—setting the TeeChart.license to Embedded resource and running your four steps without changes works as expected.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Licensing with .NET 6 App

Post by Christopher » Tue Apr 18, 2023 9:37 am

Hello Kris,
Christopher wrote:
Tue Apr 18, 2023 9:22 am
I would say that this is expected, given that the TeeChart assemblies are looking for that file in the current directory.
Expected, but that doesn't mean we can't work around it. I've changed the TeeChart source-code so we can find the TeeChart.licenses file independently of the Current Directory [issue tracker id=2605], which means your code will work 'as-is' with the new NuGet, due out in a few hours.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Kris C
Newbie
Newbie
Posts: 59
Joined: Fri Jan 13, 2023 12:00 am

Re: Licensing with .NET 6 App

Post by Kris C » Tue Apr 18, 2023 12:02 pm

Hi Christopher,

Sorry about that extra stuff in the project. It's SOP for copying files on our end.

Yes, you found the issue. The call to SetCurrentDirectory causes the TeeChart licensing not to work. We are apparently doing this on project open (something I will be investigating to see if it's even needed). But the code on our end has been there for many, many, many years.

We can't use the embedded resource approach because we run in different platforms - ArcMap, ArcGIS Pro, AutoCAD to name 3 of them. We obviously can't ask those companies to embed our licenses file into their exe. This is why deploying it is our only option (unless you know of an alternative approach).

I am pleased you were able to modify your license logic to accommodate the possibility of the current directory changing. Once the new NuGet package is available, I will immediately update our end to use it. I need to send back the filename and the format, I think.

I really appreciate the quick turnaround on this one.

On the topic of the Export button - passing an action would work perfectly. Just need to make sure you pass in the image format, and we can pass back the filename to save to. Then we can prompt the user, they specify the filename, and we pass it back to you. That would work perfectly for our workflow, and it seems generic enough for others to use as well.

Kind Regards,

Kris Culin
Bentley Systems, Inc.

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Licensing with .NET 6 App

Post by Christopher » Tue Apr 18, 2023 12:29 pm

Hello Kris,
Kris C wrote:
Tue Apr 18, 2023 12:02 pm
I really appreciate the quick turnaround on this one.
You're welcome; publishing to NuGet enables a very quick turnaround on issues which block client work processes.
Kris C wrote:
Tue Apr 18, 2023 12:02 pm
On the topic of the Export button - passing an action would work perfectly. Just need to make sure you pass in the image format, and we can pass back the filename to save to. Then we can prompt the user, they specify the filename, and we pass it back to you. That would work perfectly for our workflow, and it seems generic enough for others to use as well.
This enhancement won't be in the upcoming NuGet as I was hoping to gain a more precise understanding of your requirements here—I'll produce another mock-up shortly to see if it more closely fits in with what you need.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Kris C
Newbie
Newbie
Posts: 59
Joined: Fri Jan 13, 2023 12:00 am

Re: Licensing with .NET 6 App

Post by Kris C » Tue Apr 18, 2023 6:31 pm

Hi Christopher,

I recall you mentioning either in this post or another that you'll be fixing the System.Text.Json dependency.

Is there any particular reason why you are referencing 7.0.0 when the TeeChart control targets .NET 6? It's causing some major conflicts for us.

When we try to use TeeChart in ArcGIS Pro, which is .NET 6, it is trying to load System.Text.Json v7.0.0 and it can't be found.

Would it be possibly for you to simply target System.Text.Json v6.0.0?

Kris

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Licensing with .NET 6 App

Post by Christopher » Tue Apr 18, 2023 7:41 pm

Hello Kris,

If I'm not mistaken, the latest version of System.Text.Json, version 7.02, supports both net60/net60-windows as well as net70/net70-windows.
Screenshot from 2023-04-18 21-37-58.png
Screenshot from 2023-04-18 21-37-58.png (75.6 KiB) Viewed 38212 times
This situation, of supporting both net60/net60-windows as well as net70/net70-windows, is identical to version 6.07:
Screenshot from 2023-04-18 21-39-43.png
Screenshot from 2023-04-18 21-39-43.png (77.2 KiB) Viewed 38212 times
This being the case, I'm afraid I can't see the advantage in downgrading the version in TeeChart—maybe you could explain it to me so I can reproduce the issue here.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Kris C
Newbie
Newbie
Posts: 59
Joined: Fri Jan 13, 2023 12:00 am

Re: Licensing with .NET 6 App

Post by Kris C » Tue Apr 18, 2023 9:54 pm

Hi Christopher,
I'm not sure if I'll be able to do something to reproduce the problem and provide that to you. What is going on is that when we try to run our product inside of ArcGIS Pro, and we set the property IncludeData on Export.Template, it attempts to load System.Text.Json but it can't be found and throws an exception and it's looking for 7.0.0. However, the file it needs is right in the same folder as TeeChart.dll.

This only occurs when we try to set the proper (I think it's IncludeData = false). I'll try and get you a call stack ASAP.

Part of the complication here is that we have a very sophisticated and complex code base that includes C++ assemblies. These assemblies target .NET 6. Our C# projects target .NET 6 but they are able handle references to 7.0.0 assemblies without a hitch. It's the C++ assemblies that typically have an issue and you start to get version conflicts.

I can say that if I reference 5.2022.11.29 (the build from November 29, 2022), it works. there is no exception. So, something changed between then and now. it seems to be related to System.Text.Json.

Kris

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Licensing with .NET 6 App

Post by Christopher » Wed Apr 19, 2023 6:52 am

Hello Kris,

The new TeeChart NuGet is now available here. As you can see from its dependencies:
Screenshot from 2023-04-19 08-44-58.png
Screenshot from 2023-04-19 08-44-58.png (87.52 KiB) Viewed 38199 times
For net6.0 it is dependent on System.Text.Json (>=7.0.0). If you look on your hard disk for the version we use, v.7.0.2, you will see:
Screenshot from 2023-04-19 08-44-31.png
Screenshot from 2023-04-19 08-44-31.png (14.88 KiB) Viewed 38199 times
Note the presence of the net6.0 folder—this means that System.Text.Json 7.0.2 is built against net6.0 and is compatible with it. It is not erroneous to reference System.Text.Json 7.0.2 in a net6.0 assembly such as TeeChart.

I suggest you run some tests with this new NuGet and see what happens. It may be that your problems with this version of System.Text.Json are insurmountable, in which case we might have to consider a special build for you. What we would prefer not to do is to unnecessarily downgrade System.Text.Json for all clients of our product.
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Christopher
Guru
Posts: 1603
Joined: Fri Nov 15, 2002 12:00 am

Re: Licensing with .NET 6 App

Post by Christopher » Wed Apr 19, 2023 3:05 pm

Christopher wrote:
Tue Apr 18, 2023 12:29 pm
Kris C wrote:
Tue Apr 18, 2023 12:02 pm
On the topic of the Export button - passing an action would work perfectly. Just need to make sure you pass in the image format, and we can pass back the filename to save to. Then we can prompt the user, they specify the filename, and we pass it back to you. That would work perfectly for our workflow, and it seems generic enough for others to use as well.
This enhancement won't be in the upcoming NuGet as I was hoping to gain a more precise understanding of your requirements here—I'll produce another mock-up shortly to see if it more closely fits in with what you need.
Another suggestion for this, more specific to what I understand as your needs, would be code such as the following:

Code: Select all

        private void button1_Click(object sender, EventArgs e)
        {
            static string DoMyThing(Tuple<ExportEditor.ExportCategory, ExportFormat> format)
            {
                string result = "";
                switch (format.Item1)
                {
                    case ExportEditor.ExportCategory.Image:
                        if (format.Item2 is JPEGFormat)
                        {
                            result = "This_is_my_file.jpg";
                        }
                        break;
                    case ExportEditor.ExportCategory.Template:
                        break;
                    case ExportEditor.ExportCategory.Theme:
                        break;
                    case ExportEditor.ExportCategory.Data:
                        break;
                    default:
                        break;
                }

                return result;
            }

            _ = ExportEditor.ShowModal(tChart1, DoMyThing);
        }
In which we can see the filename in the jpeg format export:
https://steema.com/files/public/support ... 59-11.webm
Best Regards,
Christopher Ireland / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Instructions - How to post in this forum

Kris C
Newbie
Newbie
Posts: 59
Joined: Fri Jan 13, 2023 12:00 am

Re: Licensing with .NET 6 App

Post by Kris C » Wed Apr 19, 2023 4:27 pm

Hi Christopher,

RE: Feature Request
That looks perfect. We can work with that, and it looks generic enough for your other users as well.

RE: Licensing
Do you plan to release the source code that includes the fixes for the bugs we've reported plus the license fix? If we had that we could swap out the System.Text.Json versions to use 6.0.0. Speaking of which, I did more testing in ArcGIS Pro and the 7.0.0 version is still not loading. I even tried doing a LoadFrom and put in a hard-coded path to the copy that should be loaded and it doesn't load (FileNotFoundException). I verified that the copy is net6 and references net6 runtime assemblies. I did this before it even attempted to load TeeChart. Just let me know when the source that includes the fixes is available so I can grab it from my login.

Thanks again Christopher. it's really, really appreciated the help you've provided and the quick turnaround.

Kris

Kris C
Newbie
Newbie
Posts: 59
Joined: Fri Jan 13, 2023 12:00 am

Re: Licensing with .NET 6 App

Post by Kris C » Thu Apr 20, 2023 8:43 am

Hi Christopher,

I've been doing more testing regarding the System.Text.Json issue. I did find a post online with someone running into the same loading issue just like mine but unrelated to Steema or ArcGIS Pro. The solution they came up with isn't applicable in my situation, unfortunately.

It appears the only solution right now is to use a version of TeeChart that targets the latest 6.x version of the System.Text.Json NuGet package. This can either be a custom build you provide us or if you post the source code (which we have a license to use) we can make the switch ourselves and build it. if we use the source code, we'll need to make sure it has the fixes for the bugs we've reported, including the license fix.

In the meantime, we'll just continue to use the version from November and update when the latest is available.

Kind Regards,

Kris Culin
Bentley Systems, Inc.

Post Reply