Tuesday, 15 September 2015

c# - Compact Framework blocks access to COM Connection Points -



c# - Compact Framework blocks access to COM Connection Points -

i've been googling lot no 1 seems talking issue.

i have com component written in c++ exposes events ("connection points" in com parlance). component (a map control) has been used reliably several years clients written in c++ , c# on windows xp/7. has been used reliably several years clients written in c++ on windows ce.

however, connection points broken in compact framework. there 1 device on work, on multiple other devices (different builds of wince), events spontaneously unsubscribe themselves!

mapcontrol _ctrl; _imapcontrolevents_mouseeventeventhandler _temp; public mapform() { initializecomponent(); _ctrl = new mapcontrol(); _ctrl.mouseevent += (_temp = handlemouseevent); ... } ...

at first handlemouseevent() called _ctrl every mouse event, garbage collection occurs, event unsubscribed , handlemouseevent() no longer called (i confirmed event unsubscribed editing atl code print "subscriber removed".)

unfortunately impossible re-subscribe. example, if utilize code this:

_testtimer = new timer(); _testtimer.interval = 10000; _testtimer.enabled = true; _testtimer.tick += (s, e) => { _ctrl.mouseevent -= _temp; _ctrl.mouseevent += _temp; };

this works long there no garbage collection. after first gc, _ctrl.mouseevent -= _temp , _ctrl.mouseevent += _temp both throw invalidcomobjectexception (0x80131527). can still phone call methods on _ctrl events cannot used.

so, know workaround issue? (is else having issue?)

version: \windows\cgacutil.exe reports compact framework [3.5.11125.0]

c# com garbage-collection compact-framework

No comments:

Post a Comment