kuza55 / csexwb2

Automatically exported from code.google.com/p/csexwb2
0 stars 0 forks source link

Crash in GenericElementEventHandler - FIXED #106

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create Popup
2. Close Popup
3. Navigate anywhere or close program

What are the OS and IE versions?
Windows 7, IE9

What exceptions are thrown? If any, please copy and paste the exception dump.
InvokeOldHandler=>System.MissingMethodException: Method 
'System.__ComObject.[DispID=0]' not found.
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.Type.InvokeMember(String name, BindingFlags invokeAttr, Binder binder, Object target, Object[] args)
   at csExWB.GenericElementEventHandler.InvokeOldHandler() in C:\Users\\Downloads\csExWBv2.0.0.2_Includes_ComUtilities\csExWBv2.0.0.2\csExWB\csExWB\Events\GenericElementEventHandler.cs:line 74
'SecureCrtLauncher.vshost.exe' (Managed (v4.0.30319)): Loaded 
'C:\Windows\Microsoft.Net\assembly\GAC_MSIL\System.Configuration\v4.0_4.0.0.0__b
03f5f7f11d50a3a\System.Configuration.dll', Skipped loading symbols. Module is 
optimized and the debugger option 'Just My Code' is enabled.

What is the expected output? What do you see instead?
Expected no error

Please use labels and text to provide additional information.

public void InvokeOldHandler()
{
    if (m_oldhandler != null && m_oldhandler != System.DBNull.Value)
    {
        // Get a reference to the IDisplatch type
        Type lIDispatch = Type.GetTypeFromCLSID(new System.Guid("{00020400-0000-0000-C000-000000000046}"));
        // Invoke the default method "[DispID=0]"
        try
        {
------>     lIDispatch.InvokeMember("[DispID=0]", 
System.Reflection.BindingFlags.InvokeMethod, null, m_oldhandler, null);
        }
        catch (System.MissingMemberException e)
        {
            throw;
            //System.Diagnostics.Debug.Print("InvokeOldHandler=>" + e.ToString());
        }
    }
}

Change line to:
lIDispatch.InvokeMember(String.Empty, 
System.Reflection.BindingFlags.InvokeMethod, null, m_oldhandler, null);

per Microsofts documentation on how to invoke the default member...
http://msdn.microsoft.com/en-us/library/de3dhzwy.aspx

Original issue reported on code.google.com by robp1971 on 3 Aug 2011 at 7:03

GoogleCodeExporter commented 8 years ago
This is located in GenericElementEventHandler.cs

Original comment by robp1971 on 4 Aug 2011 at 5:32

GoogleCodeExporter commented 8 years ago
This invoke breaks "this" scope for JavaScript calls. When you invoke JS 
handler this way, "this" keyword in it refers to wrong object and it may then 
fail somewhere deeper in call chain. Replace marked line with:

return lIDispatch.InvokeMember("apply", 
System.Reflection.BindingFlags.InvokeMethod, null, m_oldhandler, new object[] { 
m_elem });

This calls old handler in scope of element setting "this" to correct value. I 
fixed all my issues regarding this using this change.

Original comment by xkatu...@gmail.com on 19 Sep 2011 at 11:33