[Mono-list] Mono.Zeroconf Problem: Calling delegate after garbage collection

parkerjm parkerjm at gmail.com
Mon Jul 21 16:24:28 EDT 2008


I wrote a pair of programs that communicate through the Mono.Zeroconf
library. The first program just broadcasts its presence and the other
program listens for instances of the broadcasting program. When the listener
is running and finds a broadcaster and then the broadcaster is closed, I get
the following exception:

"CallbackOnCollectedDelegate was detected
Message: A callback was made on a garbage collected delegate of type
'Mono.Zeroconf.Providers.Bonjour!Mono.Zeroconf.Providers.Bonjour.Native+DNSServiceBrowseReply::Invoke'.
This may cause application crashes, corruption and data loss. When passing
delegates to unmanaged code, they must be kept alive by the managed
application until it is guaranteed that they will never be called."

It seems like the object is being marked for garbage collection too soon or
something. How can I keep it alive? I pretty much used a lot of the mzclient
source for creating these programs, but it doesn't crash and mine does. I am
not sure why. 

Here is a snippet of the important code:
http://pastebin.com/fb91b9d2

I am creating this on Windows using .NET.
-- 
View this message in context: http://www.nabble.com/Mono.Zeroconf-Problem%3A-Calling-delegate-after-garbage-collection-tp18534138p18534138.html
Sent from the Mono - General mailing list archive at Nabble.com.



More information about the Mono-list mailing list