FIX: You receive a "System.OverFlowException" error message when you call a method of a Component Object Model (COM) DLL from a Visual C# .NET program or a Visual Basic .NET program (329658)



The information in this article applies to:

  • Microsoft .NET Framework 1.0 SP2
  • Microsoft .NET Framework 1.0 SP1
  • Microsoft .NET Framework 1.0

This article was previously published under Q329658

SYMPTOMS

You may receive the following error message:
An unhandled exception of type 'System.OverflowException' occurred in client.exe
Additional information: Overflow
This problem may occur when the following conditions are true:
  • You call a method that is defined in a Microsoft Component Object Model (COM) DLL from a Microsoft Visual C# .NET program or a Microsoft Visual Basic .NET program.
  • In the application code, the method is located after the System.Math.Asin function. The System.Math.Asin function returns Not a Number (NaN).

CAUSE

This problem occurs because the new common language runtime and the Microsoft Visual Basic 6.0 DLL or Microsoft Visual C++ DLL handle the floating point variables inconsistently.

RESOLUTION

To resolve this problem, obtain the latest service pack for Microsoft . NET Framework 1.0. To download the latest service pack, visit the following Microsoft Developer Network (MSDN) Web site:
http://www.microsoft.com/downloads/details.aspx?FamilyId=6978D761-4A92-4106-A9BC-83E78D4ABC5B

STATUS

Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the "Applies to" section. This problem was first corrected in Microsoft .NET Framework 1.0 Service Pack 3.

MORE INFORMATION

Steps to reproduce the behavior

Create a COM DLL in Visual Basic 6.0

  1. Start Visual Basic 6.0.
  2. On the New Project dialog box, on the New tab, click ActiveX DLL, and then click Open. By default, a class module file that is named Class1 appears.
  3. Add the following code to the Class1 class module file:
    Option Explicit
    Public Function Avg() As Double
    Avg = 0/1
    End Function
  4. On the File menu, click Make Project1.dll. The Make Project dialog box appears.
  5. Locate a folder to save the Project1.dll file, and then click OK to save the file.

Create a client application

  1. Start Visual Studio .NET.
  2. On the File menu, point to New, and then click Project. The New Project dialog box appears.
  3. Click Visual C# Projects under Project Types, and then click Console Application under Templates.
  4. In the Name box, type Client, and then click OK. By default, a file that is named Class1.cs is created.
  5. Replace the existing code with the following code:
    using System;
    using Project1;
    using System.Diagnostics;
    
    namespace Client
    {	
    	class Class1
    	{		
    		[STAThread]
    		static void Main(string[] args)
    		{
    			
    			Class1Class T = new Class1Class();
    			Console.WriteLine(T.Avg()) ;
    
    			double D = Math.Asin(2); 
    			Console.WriteLine(T.Avg());    			
    		}		
    	}
    }
  6. On the Project menu, click Add Reference. The Add Reference dialog box appears.
  7. Click Browse. The Select Component dialog box appears.
  8. Locate the Project1.dll file that you created in the "Create a COM DLL" section, click Project1.dll, and then click Open.
  9. In the Add Reference dialog box, click OK to add the DLL to your Client project.

Build and then run the project

  1. On the Build menu, click Build Solution.
  2. Press CTRL+F5 to run the application without a debugger. The Just-In-Time Debugging dialog box appears.
  3. Click Yes. The Attach to Process dialog box appears.
  4. Click OK.

    You may notice the behavior that is mentioned in the "Symptoms" section.
For additional information, click the following article number to view the article in the Microsoft Knowledge Base:

824684 Description of the standard terminology that is used to describe Microsoft software updates

REFERENCES

For additional information, click the following article numbers to view the articles in the Microsoft Knowledge Base:

817248 How to call a Visual Basic .NET assembly from Visual Basic 6.0 and call a Visual Basic COM component from Visual Basic .NET

315847 How to use ActiveX components in Visual Studio .NET with Visual Basic .NET


Modification Type:MajorLast Reviewed:8/31/2004
Keywords:kbCOMInterop kbClient kbfunctions kbConsole kbBug kbfix kbQFE kbNetFrame100preSP3fix kbprb KB329658 kbAudDeveloper