I have an application that works fine in Visual Studios 2008, and I am trying to get it into VS 2010 in order to use .NET 4, and I have a really weird problem. When I run the code from either Release mode or Debug mode with the debugger attached (F5), I have no problems running the program. However, when I run the program from either Release or Debug without the debugger attached (Shift+F5), I get an Access Violation Exception when I attempt to run some code in a dll from GDCM. I've created the dlls by using CMake and Swig and following the instructions here adjusting the instructions where necessary to build for VS 2010 and .NET 4.
Does any one have any ideas why this is happening and how I can fix it?
Here's an example of a program where the error occurs. Again, if you create a project with the following as the program in VS 2010 it will run fine when the debugger is attached and fail if the debugger is not attached.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using gdcm;
namespace GDCMVS2010Test
{
class Program
{
static void Main(string[] args)
{
if (args.Length != 1)
{
Console.WriteLine("This program prints the patient name of a dicom file with gdcm");
Console.WriteLine("Usage: [input.dcm]");
return;
}
gdcm.Reader reader = new gdcm.Reader();
reader.SetFileName(args[0]);
reader.Read();
gdcm.File file = reader.GetFile();
gdcm.StringFilter filter = new gdcm.StringFilter();
filter.SetFile(file);
string value = filter.ToString(new gdcm.Tag(0x0010, 0x0010));
Console.WriteLine("Patient Name: " + value);
}
}
}