Objectmix
Tags Register Mark Forums Read

'System.ArithmeticException was unhandled' at System.Double.CompareTo(Double value) when comparing with Double.NaN : DOTNET

This is a discussion on 'System.ArithmeticException was unhandled' at System.Double.CompareTo(Double value) when comparing with Double.NaN within the DOTNET forums in Framework and Interface Programming category; We are observing a strange problem in a C#.NET project (host) that makes use of COM Interop (C++). These intop components themself load the borland runtime. If a call to System.Double.CompareTo with argument Double.NaN is processed, a 'System.ArithmeticException' (C0000090 : EXCEPTION_FLT_INVALID_OPERATION) is raised. This goes to a second chance exception leading to final termination of the process! This post--> http://forums.microsoft.com/MSDN/Sho...01442&SiteID=1 describes a very similar behaviour in a different environment and also describes a workaround. This workaround also applied to our problem, so I think it is worth posting here for two reasons: 1.) I think, this is a CLR bug ...


Object Mix > Framework and Interface Programming > DOTNET > 'System.ArithmeticException was unhandled' at System.Double.CompareTo(Double value) when comparing with Double.NaN

DOTNET Discussion forums related to Microsoft Dot net technologies, CSharp and other related items

Reply

 

LinkBack Thread Tools
  #1  
Old 05-14-2007, 08:13 AM
Junior Member
 
Join Date: Nov 2009
Posts: 0
Application Development is on a distinguished road
Default 'System.ArithmeticException was unhandled' at System.Double.CompareTo(Double value) when comparing with Double.NaN

We are observing a strange problem in a C#.NET project (host) that
makes use of COM Interop (C++). These intop components themself load
the borland runtime.

If a call to System.Double.CompareTo with argument Double.NaN is
processed, a 'System.ArithmeticException' (C0000090 :
EXCEPTION_FLT_INVALID_OPERATION) is raised. This goes to a second
chance exception leading to final termination of the process!

This post--> http://forums.microsoft.com/MSDN/Sho...01442&SiteID=1
describes a very similar behaviour in a different environment and also
describes a workaround. This workaround also applied to our problem,
so I think it is worth posting here for two reasons:

1.) I think, this is a CLR bug that should be fixed.
2.) Others might experience the same problem and should find a
workaround.

Cheers,
Volker
http://www.voneinem-windbg.blogspot.com


FIRST REPRODUCTION: Make a simple C# forms app and run it

REMOVE comment for WORKAROUND

using System.Runtime.InteropServices;

namespace CLRvsBorland
{
static class Program
{

[DllImport("kernel32.dll", CharSet = CharSet.Auto)]
static extern IntPtr LoadLibrary(string lpFileName);

[STAThread]
static void Main()
{
IntPtr res = LoadLibrary(@"c:\SnapShots
\voneinem_view_a0032858_c\VespucciPool\common\bin\ release
\CC3250MT.DLL");

// Workaround: remove comments
//try
//{
// // Throw an exception..
// throw new Exception();
//}
//catch
//{
// // .. and just catch it
//}


Double a1 = Double.NaN;
MessageBox.Show("Ups" +
a1.CompareTo(Double.NaN).ToString());
}
}
}

Reply With Quote
Reply

Thread Tools


Similar Threads

Thread Thread Starter Forum Replies Last Post
fast copy from double[] to double[,] usenet CSharp 2 10-05-2007 10:02 AM
An unhandled exception of type 'System.Net.WebException' occurred in system.web.services.dll usenet DOTNET 1 09-13-2006 11:13 AM
An unhandled exception of type 'System.ExecutionEngineException' occurred in system.management.dll usenet DOTNET 1 04-28-2006 10:15 AM
Compiler cannot differentiate between fmin(double x[])) and fmin(double, double) usenet C 10 04-12-2004 02:27 AM
Error in "double = double - double" statement usenet basic.visual 3 01-23-2004 06:06 AM


All times are GMT -5. The time now is 05:20 PM.