Hello, You are right, this part is not guarded to be thread-safe. I will add a critical section around the generation code.
Can you still send the stack-trace for curiosity ? Regards, Laurent Etiemble. 2009/12/9 Duane Wandless <du...@wandless.net>: > Laurent, I'm guessing this is a threading issue. I ran into this call > stack: > Unhandled Exception: System.ArgumentException: Duplicate type name within an > assembly. > at System.Reflection.Emit.ModuleBuilder.DefineType (System.String name, > TypeAttributes attr, System.Type parent, System.Type[] interfaces, > PackingSize packingSize, Int32 typesize) [0x00000] > at System.Reflection.Emit.ModuleBuilder.DefineType (System.String name, > TypeAttributes attr, System.Type parent, System.Type[] interfaces) > [0x00000] > at System.Reflection.Emit.ModuleBuilder.DefineType (System.String name, > TypeAttributes attr) [0x00000] > at > Monobjc.Bridge.Generators.DynamicMessagingGenerator.DefineMessagingDelegate[UInt32] > (System.String message, System.String typeName, System.Type[] > parameterTypes) [0x00000] > at Monobjc.Bridge.Generators.DynamicMessagingGenerator.SendMessage[UInt32] > (System.String message, IntPtr receiver, IntPtr selector) [0x00000] > at Monobjc.ObjectiveCRuntime.SendMessage[UInt32] (IManagedWrapper > receiver, System.String selector) [0x00000] > at Monobjc.Cocoa.NSData.get_Length () [0x00000] > at MyAPI.XmlRpc.DownloadData (System.String url) [0x00000] > at MyAPI.Loader.DownloadThumbnail (System.String fileUrl, System.String > localName, Boolean bAsync, Boolean bEncrypt) [0x00000] > at MyAPI.Loader.ThreadRun () [0x00000] > > I am firing off 3 threads that execute this same code. Looking > at DynamicMessagingGenerator.SendMessage() it appears it would not be thread > safe. SendMessage checks in messagingMethodsArgs to see if the key already > exists... if not it creates a new one. > In my console output from this crash I actually saw this same stack twice... > which implies all 3 got past the if check, the first thread created the > invoker and the next 2 threads failed because it already existed. > And of course this is not easy to reproduce as it would be a timing issue. > I'd appreciate your thoughts on this. I could see adding a lock > around messagingMethodsArgs. > Thanks, > Duane >