[Mono-devel-list] Different behavior running code under mono vs. mono_runtime_invoke?

Candace Bain Candace_Bain at avid.com
Fri Jun 13 11:58:34 EDT 2003


Hi folks,

I'm trying to put together a C++ application that calls into .NET code
using mono_runtime_invoke.  Most things are working fine, but I've run
into a problem where the same code behaves differently if I run it
directly with mono vs. running it with mono_runtime_invoke.  For
example, I need to create a TCP channel.  If I create an application
that calls:

		    Console.WriteLine("About to create channel");
		    TcpChannel ch = new TcpChannel();
		    Console.WriteLine("Done creating channel");  

And run it under the mono executable it works fine.  If I make the same
calls in a method that I invoke from my C++ application by running
mono_runtime_invoke I get the following:

About to create channel

Unhandled Exception: System.TypeInitializationException: An exception
was thrown by the type initializer for System.Net.IPAddress --->
System.FormatException: An invalid IP address was specified
in <0x0055d> 00 System.Net.IPAddress:Parse (string)
in <0x0004a> 00 System.Net.IPAddress:.cctor ()
--- End of inner exception stack trace ---

in (unmanaged) /root/install/lib/libmono.so.0(mono_raise_exception+0x20)
[0x4009b0c4]
in (unmanaged)
/root/install/lib/libmono.so.0(mono_runtime_class_init+0x241)
[0x40097fb9]
in <0x00049> 00
System.Runtime.Remoting.Channels.Tcp.TcpServerChannel:.ctor
(System.Collections.IDictionary,System.Runtime.Remoting.Channels.IServer
ChannelSinkProvider)
in <0x00086> 00 System.Runtime.Remoting.Channels.Tcp.TcpChannel:Init
(System.Collections.IDictionary,System.Runtime.Remoting.Channels.IClient
ChannelSinkProvider,System.Runtime.Remoting.Channels.IServerChannelSinkP
rovider)
in <0x00086> 00 System.Runtime.Remoting.Channels.Tcp.TcpChannel:.ctor
(int)
in <0x00019> 00 System.Runtime.Remoting.Channels.Tcp.TcpChannel:.ctor ()
in <0x00032> 00 TNGTest.ClientTestObject:CreateChannel ()

Segmentation fault

In addition, if I call ToString() on a double value it works fine in an
application I run from the command line, but in code that's executed by
mono_runtime_invoke I get the following:

Unhandled Exception: System.NullReferenceException: A null value was
found where an object instance was required
in <0x00016> 00 System.Globalization.NumberFormatInfo:get_CurrentInfo ()
in <0x00061> 00 System.FloatingPointFormatter:NumberToString ()
in <0x00129> 00 System.FloatingPointFormatter:.ctor
(string,System.Globalization.NumberFormatInfo,double,double,double,int,i
nt,double,double,int,int)
in <0x0007b> 00 System.DoubleFormatter:NumberToString
(string,System.Globalization.NumberFormatInfo,double)
in <0x000cd> 00 System.Double:ToString (string,System.IFormatProvider)
in <0x00017> 00 System.Double:ToString ()
in <0x00027> 00 TNGTest.ClientTestObject:CreateChannel ()

Segmentation fault

Most things are working when I run them in mono_runtime_invoke, for
example if I call ToString() on an int value it works just fine.

Does anyone have any ideas about what might be causing this behavior?
Is there something about running code from mono_runtime_invoke that
could cause it to behave differently than just running it under mono?

Thanks,

-Candace



More information about the Mono-devel-list mailing list