Microsoft KB Archive/329658

= FIX: You receive a &quot;System.OverFlowException&quot; 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 =

Article ID: 329658

Article Last Modified on 12/30/2006

-

APPLIES TO


 * Microsoft .NET Framework 1.0 Service Pack 2
 * Microsoft .NET Framework 1.0 Service Pack 1
 * 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&displaylang=en



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



Create a COM DLL in Visual Basic 6.0
 Start Visual Basic 6.0. 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.  Add the following code to the Class1 class module file: Option Explicit Public Function Avg As Double Avg = 0/1 End Function  On the File menu, click Make Project1.dll. The Make Project dialog box appears. Locate a folder to save the Project1.dll file, and then click OK to save the file.</li></ol>

Create a client application
<ol> Start Visual Studio .NET.</li> On the File menu, point to New, and then click Project. The New Project dialog box appears.</li> Click Visual C# Projects under Project Types, and then click Console Application under Templates.</li> In the Name box, type Client, and then click OK. By default, a file that is named Class1.cs is created.</li>  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); }          } } </li> On the Project menu, click Add Reference. The Add Reference dialog box appears.</li> Click Browse. The Select Component dialog box appears.</li> Locate the Project1.dll file that you created in the &quot;Create a COM DLL&quot; section, click Project1.dll, and then click Open.</li> In the Add Reference dialog box, click OK to add the DLL to your Client project.</li></ol>

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 &quot;Symptoms&quot; 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

<div class="references_section">