Achilleus#28483
Hello all,
I've inherited a C# project that uses the GraphicsMill library, and have come up on a problem that only occurs when running in the compiler (VS2012, 2013 or 2015 all do the same). It is part of a huge project but I have re-created the identical error in a small test project as follows. I am stumped because I cannot now debug the project, though it runs ok outside of the compiler. The error occurs all the time in the inherited project, and only some of the time in small test projects; i.e. it seems somewhat random. This behavior suggests to me that it is a memory problem that acts randomly - for example if a resource is released earlier and then used later. I assume that the GraphicsMill uses non-managed code somewhere along its path.
To reproduce the error I created the following function, which can be run in a simple WPF application with a single button click. Threading is not used in my inherited project, but a single call in this test project does not produce the error, nor does a non-threaded loop of 100 iterations. But the tasked version here does produce the error.
The error only occurs under 64 bit mode. In 32 bit mode, the program works fine even in the compiler.
AurgumentException: "Parameter is not valid"
at System.Drawing.Bitmap.SetResolution(Single xDpi, Single yDpi)
at Aurigma.GraphicsMill.Bitmap.ToGdiPlusBitmap()
at OwMap.API.Test.MainWindow.<TestAurigmaClick>b__7() in c:\FlowMaps\OwMap\OwMap.API.Test\MainWindow.xaml.cs:line 249
at System.Threading.Tasks.Task.Execute()
Output (results vary from run to run):
...
bitmap created
bitmap created
A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll
bitmap created
bitmap created
...
Aurigma.GraphicsMill.dll version is: 7.2.20.0
.Net framework tested on 4.0, 4.5 and 4.5.1. Results are identical.
If there is any additional information that I can provide, please let me know.
Many thanks for any help.
I've inherited a C# project that uses the GraphicsMill library, and have come up on a problem that only occurs when running in the compiler (VS2012, 2013 or 2015 all do the same). It is part of a huge project but I have re-created the identical error in a small test project as follows. I am stumped because I cannot now debug the project, though it runs ok outside of the compiler. The error occurs all the time in the inherited project, and only some of the time in small test projects; i.e. it seems somewhat random. This behavior suggests to me that it is a memory problem that acts randomly - for example if a resource is released earlier and then used later. I assume that the GraphicsMill uses non-managed code somewhere along its path.
To reproduce the error I created the following function, which can be run in a simple WPF application with a single button click. Threading is not used in my inherited project, but a single call in this test project does not produce the error, nor does a non-threaded loop of 100 iterations. But the tasked version here does produce the error.
The error only occurs under 64 bit mode. In 32 bit mode, the program works fine even in the compiler.
AurgumentException: "Parameter is not valid"
at System.Drawing.Bitmap.SetResolution(Single xDpi, Single yDpi)
at Aurigma.GraphicsMill.Bitmap.ToGdiPlusBitmap()
at OwMap.API.Test.MainWindow.<TestAurigmaClick>b__7() in c:\FlowMaps\OwMap\OwMap.API.Test\MainWindow.xaml.cs:line 249
at System.Threading.Tasks.Task.Execute()
using OwMap.API.Helpers;
using System;
using System.Collections.Generic;
using System.Net;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Documents;
using Aurigma.GraphicsMill;
// Snipped xaml and irrelevant code
private void TestAurigmaClick(object sender, RoutedEventArgs e)
{
for (int i = 0; i < 100; ++i)
{
Title = i.ToString();
Task.Factory.StartNew(() =>
{
Aurigma.GraphicsMill.Bitmap aurigmaBitmap = new Aurigma.GraphicsMill.Bitmap(800, 600, Aurigma.GraphicsMill.PixelFormat.Format24bppRgb, RgbColor.Red);
System.Drawing.Bitmap windowsBitmap = aurigmaBitmap.ToGdiPlusBitmap();
if (windowsBitmap == null)
Console.WriteLine("bitmap is null");
else
Console.WriteLine("bitmap created");
});
}
}
Output (results vary from run to run):
...
bitmap created
bitmap created
A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll
bitmap created
bitmap created
...
Aurigma.GraphicsMill.dll version is: 7.2.20.0
.Net framework tested on 4.0, 4.5 and 4.5.1. Results are identical.
If there is any additional information that I can provide, please let me know.
Many thanks for any help.