Hi!
I have a problem when it comes to unit testing the leadtools RasterCodecs methods.
I have a simple test that tries to get information about a file that is not supported by leadtools. This should generate a RasterException with the RasterExceptionCode.FileFormat. This works alright but when I run this test on our build server the nunit process registers the following event in the event log.
Application: nunit-agent.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an internal error in the .NET Runtime at IP 000007FD898236FC (000007FD89820000) with exit code 80131506.
(Stacktrace from testrunner shown below)
It seems that the test works alright but when the program that executes the tests tries to end the error occurs.
It would normally be a nunit issue but when I remove the call to codec.GetInformation or if I supply a file that Leadtools can load, then I don't get this error.
My suspicion is that the error that occurs in the RasterCodec class, don't dispose all resources used and when the process ends, cleanup fails to do its job.
I have tried the RasterCodec.Load method and it behaves the same.
Can you help me with this?
I am using Leadtools 18.0.4.0 (FileVersion 18.0.0.43) for 64 bit
------------------------------------------------------------------------------------------------------
The test itself
------------------------------------------------------------------------------------------------------
[Test]
public void TryToLoadAnXmlFileInLeadtools() {
var path = Path.GetTempFileName();
using (var w = new StreamWriter(File.OpenWrite(path))) {
w.WriteLine("");
}
try {
using (var codec = new RasterCodecs()) {
using (var codecsImageInfo = codec.GetInformation(path, true)) {
if (codecsImageInfo != null) throw new ApplicationException("This should only happen on supported files");
}
}
} catch (RasterException ex) {
if (ex.Code == RasterExceptionCode.FileFormat) {
//we should end up here.
return;
}
throw;
} finally {
File.Delete(path);
}
}
------------------------------------------------------------------------------------------------------
The stacktrace from nunit shows
------------------------------------------------------------------------------------------------------
Starting: "f:\Program files\NUnit-2.6.4\bin\nunit-console.exe" MyTest.dll /framework=net-4.5 /nodots /nologo
in directory: F:\TeamCity\buildAgent\work\4dfb625a271e7acf\Core\MyTest\bin\Debug
ProcessModel: Default DomainUsage: Single
Execution Runtime: net-4.5
Tests run: 1, Errors: 0, Failures: 0, Inconclusive: 0, Time: 2,35907887734335 seconds
Not run: 0, Invalid: 0, Ignored: 0, Skipped: 0
Unhandled Exception:
System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
Server stack trace:
at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at System.Runtime.Remoting.Channels.SocketStream.Read(Byte[] buffer, Int32 offset, Int32 size)
at System.Runtime.Remoting.Channels.SocketHandler.ReadFromSocket(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.SocketHandler.BufferMoreData()
at System.Runtime.Remoting.Channels.SocketHandler.Read(Byte[] buffer, Int32 offset, Int32 count)
at System.Runtime.Remoting.Channels.SocketHandler.ReadAndMatchFourBytes(Byte[] buffer)
at System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadAndMatchPreamble()
at System.Runtime.Remoting.Channels.Tcp.TcpSocketHandler.ReadVersionAndOperation(UInt16& operation)
at System.Runtime.Remoting.Channels.Tcp.TcpClientSocketHandler.ReadHeaders()
at System.Runtime.Remoting.Channels.Tcp.TcpClientTransportSink.ProcessMessage(IMessage msg, ITransportHeaders requestHeaders, Stream requestStream, ITransportHeaders& responseHeaders, Stream& responseStream)
at System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at System.IDisposable.Dispose()
at NUnit.Core.ProxyTestRunner.Dispose()
at NUnit.Util.ProcessRunner.Dispose()
at NUnit.ConsoleRunner.ConsoleUi.Execute(ConsoleOptions options)
at NUnit.ConsoleRunner.Runner.Main(String[] args)
Process exited with code -100
Step Nunit ImageVault.Core.Conversion.Test cmdline (1) (1) (Command Line) failed
------------------------------------------------------------------------------------------------------
Regards
/Dan