Hi all,

I have a cocoa/mono application and using monobjc as the bridge.

There is currently a problem with using .Net Remoting code with monobjc
since Mono has a bug (https://bugzilla.novell.com/show_bug.cgi?id=MONO74621)
preventing reflection on dynamic modules.

This causes an exception when trying to use remoting, since remoting
generates a dynamic module for its work, and monobjc hooks to the
AppDomain.AssemblyLoad event and scans the loaded dynamic assembly,
resulting in an exception (see stacktrace at bottom as reference).

In short - I need a workaround - a way to tell monobjc that a certain
assembly should not be scanned (i.e. - not call
Monobjc.ObjectiveCRuntime.ScanAssembly in certain scenarios),
or change the behavior to proactively tell it which assemblies I _DO_ want
to scan instead of all of them, since I know where my bridge classes are
declared.

Reference material :

Exception stack -

Unhandled Exception: System.TypeInitializationException: An exception was
> thrown by the type initializer for
> System.Runtime.Serialization.Formatters.Binary.CodeGenerator
>
> Server stack trace:
>   at
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.CreateMemberTypeMetadata
> (System.Type type) [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.GetObjectData
> (System.Object obj,
> System.Runtime.Serialization.Formatters.Binary.TypeMetadata& metadata,
> System.Object& data) [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObject
> (System.IO.BinaryWriter writer, Int64 id, System.Object obj) [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectInstance
> (System.IO.BinaryWriter writer, System.Object obj, Boolean isValueObject)
> [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteQueuedObjects
> (System.IO.BinaryWriter writer) [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectGraph
> (System.IO.BinaryWriter writer, System.Object obj,
> System.Runtime.Remoting.Messaging.Header[] headers) [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.MessageFormatter.WriteMethodCall
> (System.IO.BinaryWriter writer, System.Object obj,
> System.Runtime.Remoting.Messaging.Header[] headers, ISurrogateSelector
> surrogateSelector, StreamingContext context, FormatterAssemblyStyle
> assemblyFormat, FormatterTypeStyle typeFormat) [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize
> (System.IO.Stream serializationStream, System.Object graph,
> System.Runtime.Remoting.Messaging.Header[] headers) [0x00000]
>   at
> System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage
> (IMessage msg) [0x00000]
>
> Exception rethrown at [0]:
>  ---> System.NotSupportedException: The invoked member is not supported in
> a dynamic module.
>   at System.Reflection.Emit.AssemblyBuilder.GetExportedTypes () [0x00000]
>   at Monobjc.ObjectiveCRuntime.ScanAssembly (System.Reflection.Assembly
> assembly) [0x00000]
>   at Monobjc.ObjectiveCRuntime.CurrentDomain_AssemblyLoad (System.Object
> sender, System.AssemblyLoadEventArgs args) [0x00000]
>   at System.AppDomain.DoAssemblyLoad (System.Reflection.Assembly assembly)
> [0x00000]
>   at (wrapper managed-to-native)
> System.Reflection.Emit.AssemblyBuilder:basic_init
> (System.Reflection.Emit.AssemblyBuilder)
>   at System.Reflection.Emit.AssemblyBuilder..ctor
> (System.Reflection.AssemblyName n, System.String directory,
> AssemblyBuilderAccess access, Boolean corlib_internal) [0x00000]
>   at System.AppDomain.DefineInternalDynamicAssembly
> (System.Reflection.AssemblyName name, AssemblyBuilderAccess access)
> [0x00000]
>   at (wrapper remoting-invoke-with-check)
> System.AppDomain:DefineInternalDynamicAssembly
> (System.Reflection.AssemblyName,System.Reflection.Emit.AssemblyBuilderAccess)
>   at System.Runtime.Serialization.Formatters.Binary.CodeGenerator..cctor ()
> [0x00000]
>   --- End of inner exception stack trace ---
>   at
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.CreateMemberTypeMetadata
> (System.Type type) [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.GetObjectData
> (System.Object obj,
> System.Runtime.Serialization.Formatters.Binary.TypeMetadata& metadata,
> System.Object& data) [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObject
> (System.IO.BinaryWriter writer, Int64 id, System.Object obj) [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectInstance
> (System.IO.BinaryWriter writer, System.Object obj, Boolean isValueObject)
> [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteQueuedObjects
> (System.IO.BinaryWriter writer) [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.ObjectWriter.WriteObjectGraph
> (System.IO.BinaryWriter writer, System.Object obj,
> System.Runtime.Remoting.Messaging.Header[] headers) [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.MessageFormatter.WriteMethodCall
> (System.IO.BinaryWriter writer, System.Object obj,
> System.Runtime.Remoting.Messaging.Header[] headers, ISurrogateSelector
> surrogateSelector, StreamingContext context, FormatterAssemblyStyle
> assemblyFormat, FormatterTypeStyle typeFormat) [0x00000]
>   at
> System.Runtime.Serialization.Formatters.Binary.BinaryFormatter.Serialize
> (System.IO.Stream serializationStream, System.Object graph,
> System.Runtime.Remoting.Messaging.Header[] headers) [0x00000]
>   at
> System.Runtime.Remoting.Channels.BinaryClientFormatterSink.SyncProcessMessage
> (IMessage msg) [0x00000]
>



Thanks, Yoni.

Reply via email to