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

Aaron Bockover abockover at novell.com
Mon Jul 21 19:26:15 EDT 2008


These GC issues should be fixed in SVN/trunk. I have not yet made a release including them however. There will be a Mono.Zeroconf release hopefully this week. Follow the link below to get binaries for testing. They will not change from what will be released next week unless you find there is still a collection issue with the delegates:

http://getbanshee.org/~abock/mz-gc-fix

>From the ChangeLog:

2008-04-02  Aaron Bockover  <abockover at novell.com>

    * src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs:
    * src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/RegisterService.cs:
    * src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/ServiceBrowser.cs:
    Fixed a big bug reported by Josh Cooley wherein delegates passed to
    native code could be GCed at the wrong time, apparently particularly
    noticeable on MS.NET

--Aaron


--

>>> On Mon, Jul 21, 2008 at  6:24 PM, in message <18534138.post at talk.nabble.com>,
parkerjm <parkerjm at gmail.com> wrote: 

> 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+DNSS
> erviceBrowseReply::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.



More information about the Mono-list mailing list