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

Prohlášení o odmítnutí odpovědnosti pro už nepodporovaný obsah KB

Tento článek byl napsán pro produkty, ke kterým již Microsoft nadále nenabízí podporu. Článek je tedy poskytován „tak, jak je“ a nebude už nadále aktualizován.


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).


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.


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:


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.dllfile, 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
    static void Main(string[] args)

    Class1Class T = new Class1Class();
    Console.WriteLine(T.Avg()) ;

    double D = Math.Asin(2);
  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
  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


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


ID článku: 329658 - Poslední kontrola: 28. 4. 2008 - Revize: 1

Váš názor