page 1 of 1
Comments: 2 | Views: 851
jh71283
jh71283
Throw new System.Beverage. OutOfCoffeeException​()
Hello everybody.

Every now and then, a few of my users get the following error when loading my software (WPF based desktop app)

'800' value cannot be assigned to property 'Width' of object '(MyProject).LoginScreen'. Overflow or underflow in the arithmetic operation.  Error at object 'Window' in markup file '(MyProject);component/loginscreen.xaml'.


The error is actually thrown within the InitializeComponent in Loginscreen.g.vb


Has anybody any idea what could be causing it?

John,

I am seeing what appears to be the same issue.  Did you figure out what causes this problem?

In my case the exception consistently occurs on the second and every subsequent run of my test case until I restart my application.

I've noticed that whatever XAML property appears first in my markup is the target of the error.  For example, in the XAML snippet below, Height is the first property to be assigned, but if I change Width to be first then the same exception occurs but complaining about width.  I also experimented with a variety of values and the exact assignment value doesn't seem to matter.

<UserControl x:Class="..."
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Height="Auto" Width="Auto" MinHeight="300" MinWidth="300" Padding="20">
<TextBlock Name="TextBox" HorizontalAlignment="Center" VerticalAlignment="Center" TextAlignment="Center" TextWrapping="Wrap" />
</UserControl>

My problem was caused by a 3rd party library that apparently leaves behind side-effects with floating-point calculation.  The way this was solved for me was to ensure that the floating point state is always reset when cleaning up the use of this particular 3rd party library.

After solving the problem, I found a good description of the problem on this page: http://www.cognaxon.com/index.php?page=wsqlib_NETnotes#2

Here's some paraphrased code from my fix:

// Need this DllImport statement to reset the floating point register below
[DllImport("msvcr71.dll", CallingConvention = CallingConvention.Cdecl)]
private static extern int _controlfp(int n, int mask);

void useThirdPartyWithFPSideEffects() {
    try {
        //use the library
    }
    catch (Exception ex) {
        //do what you need to do
    }
    finally {
        //misc cleanup

        //reset the floating point register to avoid fp side-effect of library
        _controlfp(0x9001F, 0xFFFFF); // restore floating-point register to default value required by .NET Framework
    }
}

page 1 of 1
Comments: 2 | Views: 851
Microsoft Communities