ASE Home Page Products Download Purchase Support About ASE
ChartDirector Support
Forum HomeForum Home   SearchSearch

Message ListMessage List     Post MessagePost Message

  BaseChart.makeChart2(Chart.PDF) returning null
Posted by David on Mar-26-2020 08:10
I have a pie chart that is returning null on a call to makeChart2().

What can I do to figure out why?

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by David on Mar-26-2020 08:54
Same problem for SVG.

PNG is ok if it calls it first that way. But if it first calls for PDF, then the call for PNG gets a 1x1 PNG file.

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by Peter Kwan on Mar-26-2020 15:22
Hi David,

Is it possible to create an example that I can run, so that I can reproduce the problem?

To do this, first, try to change everything to hard coded values (use hard coded data, hard coded labels, etc) that should be the same as the actual values, and check if the error still occur. Then remove non-essential lines one by one (such as the chart title and other labelling and cosmetic code), and check if the error still occur. This will lead to the simplest hard code example that can still reproduce the problem.

If the above is not possible, you  may try to add the following line before calling makeChat2:

c.getDrawArea().setEnableExceptions(true);

The code above will cause the makeChart2 to crash with an exception instead of returning null. It may contain the detail type of exception and a stack trace. Please let me know what is the result.

Regards
Peter Kwan

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by David on Mar-26-2020 21:46
The exception provided the answer - it needs System.Drawing.Common 4.0.0.0

However in NuGet the oldest version of System.Drawing.Common available is 4.5.0

And I'd prefer to have a newer version of System.Drawing.Common for our additional use of it.

How do we solve this?

*****

Other question, there's no setEnableExceptions(true); in the Java library. How can I turn this on for that library?

thanks - dave

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by Peter Kwan on Mar-26-2020 23:07
Hi David,

This is a little unexpected, because then I cannot explain why it works with PNG.

In any case, the rules of NuGet is that all versions that has ever existed on NuGet should always be available on NuGet.

The NuGet web page only displays the recent history of the package. It also displays the command line to download the package using the Package Manager, .NET CLI, etc..

If the project dependency is managed by Visual Studio, it will automatically download the correct version for everything.

If you need to manually download the DLL, you can create a new Visual Studio .NET project. Then open "Tools - NuGet Package Manager - Package Manager Console", and enter:

Install-Package System.Drawing.Common -Version 4.0.0

The above will install the DLL in your project, which you can copy out.

If you do not want to use Visual Studio, you can use the "dotnet" tool from the command line:

dotnet add package System.Drawing.Common --version 4.0.0

Regarding the setEnableException, this is an undocumented method that only exists in .NET. For Java, there are undocumented methods that output directly to IO streams and they can throw exceptions:

OutputStream f = new FileOutputStream(filename);
c.makeChart().outPDF(f);
f.close();

Regards
Peter Kwan

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by David on Mar-27-2020 07:28
Hi Peter;

I did that and got:

Directory of C:gitJenovaengineDotNetEnginepackagesSystem.Drawing.Common.4.0.0.0lib

08/01/2016  05:48 PM           189,624 System.Drawing.dll
               1 File(s)        189,624 bytes

And still get an exception of:
{"Could not load file or assembly 'System.Drawing.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified.":"System.Drawing.Common, Version=4.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51"}

When I do sn -Tp on System.Drawing.dll I get:
b03f5f7f11d50a3a

Any ideas why it's not a match?

thanks - dave

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by David on Mar-27-2020 07:42
Also weird, https://www.nuget.org/packages/System.Drawing.Common/ only goes back to 4.5.0. So I can't find 4.0.0 (in case the .Net Core version is different).

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by David on Mar-27-2020 08:59
I got it working!!!

It requires a combination of getting the .Net Core ChartDirector.Net.dll and the .Net Framework System.Drawing.Common.dll

We're still sort-of half & half on .Net Core and .Net Framework.

Anyways, thanks for the help.

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by Peter Kwan on Mar-27-2020 14:22
Hi David,

I think I finally know what has happened.

The ChartDirector.Net.dll is a ".NET Standard 2.0" DLL. It means it supports both .NET Core 2.0 or later, and .NET Framework 4.6.1 or later.

The ChartDirector.Net.dll requires the "System.Drawing.Common 4.5.0 nuget package".

When I examine exactly what is inside the "System.Drawing.Common 4.5.0 nuget package", I found that it contains ".NET Standard 2.0" version of "System.Drawing.Common.dll 4.0.0.0".

Here is the confusion - the nuget package version does not necessarily match the DLL version.

All .NET Standard 2.0 DLLs are supported by both .NET Core 2.0 and and .NET Framework 4.6.1 (or later). So it is possible the System.Drawing.Common.dll you found in the .NET Framework is the same DLL as in the nuget package "System.Drawing.Common 4.5.0". That's why it works.

Regards
Peter Kwan

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by Peter Kwan on Mar-28-2020 20:30
Hi David,

After further investigation, I found that there are in fact two versions of "System.Drawing.Common.dll", and one ".NET Standard 2.0" and one for ".NET Framework 4.6.1". ChartDirector.Net.dll can work with .NET Framework 4.6.1 or later if you include the "System.Drawing.Common.dll" for .NET Framework 4.6.1.

To obtain those System.Drawing.Common.dll editions, download the nuget package "System.Drawing.Common 4.5.0" from the nuget web site. You should get a file with extension ".nupkg". Rename the extension to ".zip". Now you can open the zip normally. You can find the two DLLs in "lib/net461" and "lib/netstandard2.0".

I also realize there are 3 versions about the DLL. The nuget package version is 4.5.0. The file version (right click on the file and select properties) is 4.6.26515.6. The assembly version is 4.0.0.0. The version reported in the error message is the assembly version. You can use the ildasm tool to determine the assembly version.

Regards
Peter Kwan

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by David on Mar-28-2020 20:57
Hi Peter;

I think we are causing problems for ourselves by fighting NuGet. We will need to build and post to NuGet three version of our libraries: .Net Standard 2.0, .Net Core 3.1, & .Net Framework 4.6.1.

When we do that most of our DLLs will be identical for all three platforms. But in each case they will then reference the appropriate DLLs, for the same platform, for the libraries we use, like ChartDirector. So for .Net Framework, we'll use the .Net Framework version of ChartDirector.

The one thing that's a pain about this is the name of your DLL is different for .Net Framework. Have you considered naming all platform's DLL ChartDirector.Net.dll?

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by Peter Kwan on Mar-28-2020 21:44
Hi David,

You can in fact use the current ChartDirector.Net.dll for both the .NET Standard 2.0 and .NET Framework 4.6.1. I have tested it myself and it works, provided you use the proper System.Drawing.Common.dll.

In brief, for ChartDirector, you can use two sets of DLLs:

(a) For .NET Framework 4.6.1 or above

ChartDirector.Net.dll and the .NET Framework version of System.Drawing.Common.dll

(b) For .NET Standard 2.0 and .NET Core 2.1 or above

ChartDirector.Net.dll and the .NET Standard 2.0 version of System.Drawing.Common.dll


We still have a "netchartdir.dll" due to backwards compatibility reason. If you prefer to use ChartDirector.Net.dll, you can by combining it with the proper System.Drawing.Common.dll.


My understanding is that a .NET Standard 2.0 DLL is acceptable to both .NET Framework 4.6.1 or above, and also .NET Core 2.1 or later. That's why ChartDirector.Net.dll can be used for both. However, some .NET Standard 2.0 DLLs, such as "System.Drawing.Common.dll", use non .NET features, such as native calls. For these types of DLLs, there will be separate .NET Standard and .NET Framework versions. The nuget package for these libraries will contain multiple DLLs for the various usages.


.NET Standard 2.0 is just an API specification. An application must run on an implementation of the API specification, such as .NET Core or .NET Framework. So no application can target .NET Standard 2.0. Only a library can target .NET Standard 2.0. That's why on Visual Studio, it is not possible to build a .NET Standard application, but it is possible to build a .NET Standard library.

Regards
Peter Kwan

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by David on Apr-01-2020 21:32
In this case use System.Drawing.Common.dll 4.5.0 or earlier, Starting with 4.5.1 the assembly version is 4.0.0.1, not 4.0.0.0

  Re: BaseChart.makeChart2(Chart.PDF) returning null
Posted by Peter Kwan on Apr-01-2020 23:06
Hi David,

Yes, you can use System.Drawing.Common assembly version 4.0.0.1.

It is a common for a project to need multiple versions of the same assembly. ChartDirector needs System.Drawing.Common assembly version 4.0.0.0. May be some other library used by the project needs version 4.0.0.1. If the code is compiled by Visual Studio, it should generate a binding redirect to redirect 4.0.0.0 to 4.0.0.1.

If NuGet is used, Visual Studio should automatically download the newer assembly. If assembly is referenced directly as a DLL, the project should reference the newer version.  When Visual Studio compile the code, it should generate a binding redirect to redirect 4.0.0.0 to 4.0.0.1.

However, if you can using an alternative toolchain, you may need to check how it can resolve assembly version conflicts.

Regards
Peter Kwan