What can cause C# optimized code compilation to raise InvalidProgramException?

2

Running a c# windows app, forced platform target of x86, on a 64 bit host.

When the app is compiled using "Optimize code" option get this error during execution.

First-chance exception at 0x74F7C41F (KernelBase.dll) in sldotnetsso.exe: 0x02345678 (parameters: 0x80000001).
First-chance exception at 0x74F7C41F in sldotnetsso.exe: Microsoft C++ exception: EEException at memory location 0x0847EC54.
First-chance exception at 0x74F7C41F in sldotnetsso.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
First-chance exception at 0x74F7C41F in sldotnetsso.exe: Microsoft C++ exception: [rethrow] at memory location 0x00000000.
A first chance exception of type 'System.InvalidProgramException' occurred in slDotNetSSO.exe

The exception is raised when I try and step into getNativeWindowHandle.

somfunc() {
  m_id = CDescribeControl.getNativeWindowHandle(m_element);
}

class CDescribeControl{

    //NativeWindowHandle
    public static string getNativeWindowHandle(AutomationElement element)
    {
        string windowHandle = "";
        object classNameNoDefault = element.GetCurrentPropertyValue(AutomationElement.NativeWindowHandleProperty, true);
        if (classNameNoDefault == AutomationElement.NotSupported)
        {
            // property not supported
            // runtime ID as this is ment to be session unique
            classNameNoDefault = element.GetCurrentPropertyValue(AutomationElement.RuntimeIdProperty, true);
            if (classNameNoDefault == AutomationElement.NotSupported)
            {
                windowHandle = "0";
            }
            else
            {
                Int32[] arr = (Int32[])classNameNoDefault;//element.GetRuntimeId();
                foreach (int runidpart in arr)
                {
                    windowHandle += runidpart.ToString("X") + " ";
                }
            }
        }
        else
        {
            int res = (int)classNameNoDefault;//element.Current.NativeWindowHandle
            windowHandle = res.ToString("X");
        }

        return windowHandle;
    }

When the app is compiled without "Optimize code" it runs successfully. Would like to compile with "Optimize code".

Any ideas on the cause of the issue?

c#
exception
optimization
asked on Stack Overflow Jun 18, 2014 by Greg Domjan • edited Jun 18, 2014 by BatteryBackupUnit

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0