Hi,
I have attempted to implement a simple query, move example. I believe I have done everything correctly, and indeed the example executes fine about 30% of the time. I am experiencing erratic failures by simply re-running. Does anyone know what is going on?
The failure takes one of two forms:
1) System.AccessViolationException with a message of Attempted to read or write protected memory. This occurs after several of the files have been transferred. I am unable to get additional information as visual studio tells me the stack is in external code.
2) System.NullReferenceException when processing the PDU. This occurs prior to any files being transferred. It looks like the error occurs during this function call SendAssociationAccept(association); in CStoreSCP. See the log below.
QM-pacsd01 -> Association accept:
Calling AE Title: AB-pacsd01
Called AE Title: STORESCP
Implementation Class: Implementation Class UID [1.2.40.0.13.1.1]
Implementation Version: dcm4che-1.4.29
Maximum PDU Length: 16352
Async Ops Invoked: 0
Async Ops Performed: 1
Presentation Contexts: 2
Presentation Context: 1 [Accept]
Abstract Syntax: MR Image Storage
Transfer Syntax: Implicit VR Little Endian
Presentation Context: 3 [Accept]
Abstract Syntax: MR Image Storage
Transfer Syntax: Explicit VR Little Endian
Exception processing PDU: System.NullReferenceException: Object reference not set to an instance of an object.
at Dicom.Network.DicomService.SendNextPDU() in Z:\Development\fo-dicom\DICOM\Network\DicomService.cs:line 578
at Dicom.Network.DicomService.SendPDU(PDU pdu) in Z:\Development\fo-dicom\DICOM\Network\DicomService.cs:line 557
at Dicom.Network.DicomService.SendAssociationAccept(DicomAssociation association) in Z:\Development\fo-dicom\DICOM\Network\DicomService.cs:line 944
at DicomClientExperiment.CStoreSCP.OnReceiveAssociationRequest(DicomAssociation association) in c:\Users\Administrator\Desktop\AB\trunk\AB\code\Dic
omClientExperiment\CStoreSCP.cs:line 76
at Dicom.Network.DicomService.EndReadPDU(IAsyncResult result) in Z:\Development\fo-dicom\DICOM\Network\DicomService.cs:line 199
QM-pacsd01 <- C-Move response [3]: Out of Resources
Failures: 146
C-Move response [3]: Out of Resources
Failures: 146
QM-pacsd01 -> Association release request
QM-pacsd01 <- Association release response
The code is below what I am executing.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Dicom;
using Dicom.Network;
using NLog;
using NLog.Config;
using NLog.Targets;
using Dicom.Log;
namespace DicomClientExperiment
{
class Program
{
public static void MoveDelegate(DicomCMoveRequest request, DicomCMoveResponse response)
{
if (response.Remaining == 0)
Console.WriteLine(response.ToString());
}
static void Main(string[] args)
{
try
{
LoggingConfiguration config = new LoggingConfiguration();
ColoredConsoleTarget ct = new ColoredConsoleTarget();
ct.Layout = "${message}";
config.AddTarget("Console", ct);
config.LoggingRules.Add(new LoggingRule("*", LogLevel.Debug, ct));
LogManager.Configuration = config;
var dict = DicomDictionary.Default;
var server = new DicomServer<CStoreSCP>(104);
DicomClient client = new DicomClient();
// echo
DicomCEchoRequest cEcho = new DicomCEchoRequest();
client.AddRequest(cEcho);
// find
DicomCFindRequest cFind = DicomCFindRequest.CreateStudyQuery(patientId: "geservice");
client.AddRequest(cFind);
// move
DicomCMoveRequest cMove = new DicomCMoveRequest("STORESCP", "1.2.840.113619.6.295.318370558294670917247756468170410924047", "1.2.840.113619.2.295.4120.6367188.27525.1349361076.223");
cMove.OnResponseReceived = MoveDelegate;
client.AddRequest(cMove);
client.Send("192.168.1.214", 11112, false, "my AE", "their AE");
Console.ReadLine();
}
catch (Exception e)
{
Console.WriteLine(e.ToString() + "/n" + e.GetType() + "/n" + e.Message);
}
Console.ReadLine();
}
}
}