title: win32com.client.DispatchWithEvents doesn't catch events and raises exception
body: <p>I have to connect to COM interface (specific implementation), call some methods, get responses in both synchronous and asynchronous way. I had to mask some specific interface/methods names while pasting code samples. If I use <strong>Dispatch</strong> method only, everything <strong>works fine</strong>:</p>
  
  <pre><code>#works fine in synchronous mode
  myObj = win32com.client.Dispatch(myObjID)
  myObj.MyMethod1(0)
  myResp = myObj.myMethod2()
  print "property1: " + myResp.property1 #works fine
  </code></pre>
  
  <p>Problem starts when I need to get some events (<strong>DispatchWithEvents</strong>). It causes Python to crash ! Low level networking exception is thrown: <strong>exceptions.EOFError: [Errno 10054] An existing connection was forcibly closed by the remote host</strong>. Code sample which results in crash:</p>
  
  <pre><code>#crashing code
  class SomeEvents(object):
      def OnMethod1(self):
          print 'OnMethod1'
  
  myObj = win32com.client.DispatchWithEvents(myObjID,SomeEvents)
  myObj.MyMethod1(0) # CRASH OCCURS HERE!
  </code></pre>
  
  <p>I have checked what kind of object is actually returned by Dispatch and DispatchWithEvents:</p>
  
  <p>Object returned by <strong>Dispatch</strong>:</p>
  
  <pre><code>&lt;win32com.gen_py.myComInterface 1.0 Type Library.myComManager instance at 0x20508304&gt;
  ['CLSID', 'MyMethod1', 'MyMethod2', 'MyMethod3', 'MyMethod4', 'MyMethod5', '_ApplyTypes_', '__doc__', '__eq__', '__getattr__', '__init__', '__iter__', '__module__', '__ne__', '__repr__', '__setattr__', '_get_good_object_', '_get_good_single_object_', '_oleobj_', '_prop_map_get_', '_prop_map_put_', 'coclass_clsid']
  </code></pre>
  
  <p>Object returned by <strong>DispatchWithEvents</strong>:</p>
  
  <pre><code>&lt;win32com.client.COMEventClass instance at 0x20462352&gt;
  ['__del__', '__doc__', '__getattr__', '__init__', '__module__', '__setattr__', '_obj_']
  </code></pre>
  
  <p>In both cases there are objects of different types returned. Object returned by <strong>DispatchWithEvents</strong> is <strong>COMEventClass</strong> and it doesn't contain MyMethod1, MyMethod2 etc. (is that a reason of crash? I would expect "Object has no attribute" exception)</p>
  
  <p>I also tried to implement it by creating 2 different objects. As a result, there is no crash but also no events are caught. Code sample:</p>
  
  <pre><code>#doesn't crash but also doesn't catch any events
  class SomeEvents(object):
      def OnMethod1(self):
          print 'OnMethod1'
  
  myObj1 = win32com.client.Dispatch(myObjID)
  myObj2 = win32com.client.DispatchWithEvents(myObjID,SomeEvents)
  myObj1.MyMethod1(0) 
  myResp = myObj1.MyMethod2()
  print "property1: " + str(myResp.property1) #property displayed correctly
  #no 'OnMethod1' printout visible
  </code></pre>
  
  <p>I was implementing COM client using examples found on internet. Python version: 2.7.6 (32 bit) on WinXP SP3. I couldn't search for any similar problem (what surprised me a little bit). What am I doing wrong? Perhaps specific implementation of COM has bugs? I think that next step would be to implement COM client using VB and check if it has similar problems. What would you suggest?</p>