Click here to Skip to main content
15,898,538 members
Home / Discussions / COM
   

COM

 
QuestionSystem context menu Pin
__DanC__22-Aug-07 6:04
__DanC__22-Aug-07 6:04 
Questionhow to Aggregate the ActiveX control frm ATL component Pin
ss43121-Aug-07 23:46
ss43121-Aug-07 23:46 
QuestionUsing NULL to Close the DB connection after Close() Pin
ragavan20-Aug-07 20:43
ragavan20-Aug-07 20:43 
AnswerRe: Using NULL to Close the DB connection after Close() Pin
myshketer21-Aug-07 21:44
myshketer21-Aug-07 21:44 
QuestionLosing COM events handler in C# client [modified] Pin
Vitaly Tomilov20-Aug-07 0:15
Vitaly Tomilov20-Aug-07 0:15 
AnswerRe: Losing COM events handler in C# client Pin
User 21559720-Aug-07 0:52
User 21559720-Aug-07 0:52 
GeneralRe: Losing COM events handler in C# client Pin
Vitaly Tomilov20-Aug-07 1:28
Vitaly Tomilov20-Aug-07 1:28 
AnswerRe: Losing COM events handler in C# client Pin
Vitaly Tomilov20-Aug-07 1:27
Vitaly Tomilov20-Aug-07 1:27 
I seem to have found the problem, which also is a horrible revelation, another .NET bug, I think… So, this is what it was…

In a simple scenario, you bind COM event to your C# handler via += operator, for YourInterfaceVariable.EventName += New MyHandler, which seems to do the job fine.

Now consider a little more complicated scenario, where your main interface doesn’t expose events. Instead, it exposes a property of another interface, which in turn exposes events. Now, you want to attach a C# event handler to that internal interface via the property, obviously, so you give the command: VariableName.PropertyName.EventName += new MyHandler.

By all logic, this must work, and it even does, for a while, a few calls, 10-30, as all-of-a-sudden, your events stop coming in!!! You start asking yourself why, and the answer is astounding: C#/.NET doesn’t support such internal references properly, and at some point they seem to get into the automated garbage collection, or so it would seem. How do I know? That’s simple: I declared another variable of type of the internal event interface, then set it at run time, and did C# binding onto that variable instead its reference through the containing interface. And that solved the problem, the event handler no longer looses the connection.

Now how do you like THEM apples! Am I far indulging into Microsoft hatred or that’s really another screw up on their part?

Any comments are welcome.



Free C++ libraries with source code on www.neatcpp.com: TWAIN, DirectShow, Interprocess Communications, etc...

QuestionRe: Losing COM events handler in C# client Pin
ranu mandan5-Sep-08 3:23
ranu mandan5-Sep-08 3:23 
AnswerRe: Losing COM events handler in C# client Pin
Vitaly Tomilov5-Sep-08 3:35
Vitaly Tomilov5-Sep-08 3:35 
GeneralRe: Losing COM events handler in C# client Pin
ranu mandan7-Sep-08 22:34
ranu mandan7-Sep-08 22:34 
Questionjavascript menu on masterpage and dropdown list on contentpage problem in IE Pin
swapnilek17-Aug-07 4:50
swapnilek17-Aug-07 4:50 
AnswerRe: javascript menu on masterpage and dropdown list on contentpage problem in IE Pin
help as an alias20-Aug-07 18:29
help as an alias20-Aug-07 18:29 
QuestionGetInterfaceFromGlobal() hanging Pin
simon heffer15-Aug-07 3:42
simon heffer15-Aug-07 3:42 
AnswerRe: GetInterfaceFromGlobal() hanging Pin
Vitaly Tomilov20-Aug-07 0:40
Vitaly Tomilov20-Aug-07 0:40 
QuestionAccess Is Denied Error Pin
Captain Trips14-Aug-07 4:44
Captain Trips14-Aug-07 4:44 
AnswerRe: Access Is Denied Error Pin
User 21559715-Aug-07 0:13
User 21559715-Aug-07 0:13 
Questionc++ managed wrapper class for unmanaged class Pin
Pankaj.Jain13-Aug-07 23:52
professionalPankaj.Jain13-Aug-07 23:52 
QuestionPDF from HTML content Pin
Rajkamal_dfine13-Aug-07 18:24
Rajkamal_dfine13-Aug-07 18:24 
QuestionUrgent Help !! In certifcate enrollment in Windows CA using C# ( XENROLL.dll) Pin
fireline108213-Aug-07 7:47
fireline108213-Aug-07 7:47 
QuestionPrintPreview Implementation Pin
Rakesh__Patil12-Aug-07 19:03
Rakesh__Patil12-Aug-07 19:03 
Questionproblem About DCOM on Windows 2003 Server Pin
kcynic11-Aug-07 16:47
kcynic11-Aug-07 16:47 
QuestionShow/hide deskband ? Pin
vilius_m11-Aug-07 10:44
vilius_m11-Aug-07 10:44 
QuestionCom Interop Error ?WMI query language not supported? Pin
Blizzardice10-Aug-07 12:23
Blizzardice10-Aug-07 12:23 
QuestionWhat is difference between BSTR, CComBSTR, _bstr_t Pin
Nandu_77b10-Aug-07 5:00
Nandu_77b10-Aug-07 5:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.