I created the following test script to track error using VB6-WPF interaction:
There is a .Net WPF DLL that displays a form with a text field. The text field does not process keyboard input - there is no data binding, there is no event handler. DLL - COM visible.
A VB6.exe calls the ShowWindow DLL function to display a WPF form. When I enter any key into the text box, it causes a "Runtime Error" 6 "Overflow" error in the VB application. The error occurs in the line "dVal = 0" of the Timer1 event.
I assume that the error is due to the fact that an unhandled key event bubbles up before the VB6 application. Should WPF events go up to VB6? Why does the problem occur in the timer? Why does this only happen if a double variable is set? This does not happen if the string "dVal = 0" is missing. Any thoughts?
C # code from an open class that displays a window:
public class NetFormIFace : INetFormIFace
{
public void ShowWindow1()
{
Window1 w1;
w1 = new Window1();
w1.Show();
}
}
XAML for the window. Nothing is added to the code:
<Window x:Class="SSEC.NetForm.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Canvas>
<TextBox Height="34" Canvas.Left="35" TextWrapping="Wrap" Text="TextBox" Canvas.Top="52" Width="94" />
</Canvas>
</Window>
VB6 Code:
Option Explicit
Dim IFace As NetFormIFace
Private Sub Command1_Click()
IFace.ShowWindow1
End Sub
Private Sub Form_Load()
Set IFace = New NetFormIFace
Timer1.Interval = 50
Timer1.Enabled = True
End Sub
Private Sub Timer1_Timer()
Dim iVal As Integer
Dim dVal As Double
iVal = 0 ' Does not cause an error
dVal = 0 ' Causes an error
End Sub
source
share