我有一个在Visual Studios 2008中运行良好的应用程序,我正在尝试将其转移到VS 2010以使用.NET 4,并且我遇到了一个非常奇怪的问题。当我从Release模式或Debug模式下带调试器运行代码(F5)时,运行程序没有任何问题。然而,当我从Release或Debug模式下不带调试器运行程序(Shift + F5)时,在尝试运行GDCM库中的一些代码时,会出现访问冲突异常。我通过使用CMake和Swig创建了这些dll,并按照此处的说明进行了调整,以便为VS 2010和.NET 4构建。
有没有人有任何想法,为什么会出现这种情况,以及如何解决它?
以下是一个出现错误的程序示例。同样,如果您在VS 2010中创建一个具有以下程序的项目,并附加调试器,则可以正常运行,如果不附加调试器,则会失败。
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);
}
}
}