Hello,

I want to use Saxon-B with Mono and Monodevelop. I am trying to use the Saxon API embedded in my C# codes, but I am having problems.

First of all, I downloaded the .NET package (saxon-resources9-0-0-1.zip). Then, in monodevelop I added all .dll and .exe files as reference in my project. I assumed that this should allow me to use the Saxon.Api namespace. But monodevelop doesn't seem to recognize the Saxon namespace. Monodevelop shows the net.sf.saxon namespace, but not the Saxon.Api namespace.

Eventhough monodevelop does not recognize the Saxon.Api workspace, I tried to use it anyway without code completion. The following program got compiled:

using System;
using Saxon.Api;

namespace Test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            Processor processor = new Processor();
        }
    }
}

but running it caused the following error:

Stacktrace:

  at (wrapper managed-to-native) System.MonoCustomAttrs.GetCustomAttributesInternal (System.Reflection.ICustomAttributeProvider,System.Type,bool) <0x00004>
  at (wrapper managed-to-native) System.MonoCustomAttrs.GetCustomAttributesInternal (System.Reflection.ICustomAttributeProvider,System.Type,bool) <0xffffffff>
  at System.MonoCustomAttrs.GetCustomAttributesBase (System.Reflection.ICustomAttributeProvider,System.Type) [0x00000] in /tmp/monobuild/build/BUILD/mono-1.9/mcs/class/corlib/System/MonoCustomAttrs.cs:82
  at System.MonoCustomAttrs.GetCustomAttributes (System.Reflection.ICustomAttributeProvider,System.Type,bool) [0x00011] in /tmp/monobuild/build/BUILD/mono-1.9/mcs/class/corlib/System/MonoCustomAttrs.cs:120
  at System.Reflection.Module.GetCustomAttributes (System.Type,bool) [0x00000] in /tmp/monobuild/build/BUILD/mono-1.9/mcs/class/corlib/System.Reflection/Module.cs:139
  at IKVM.Internal.AttributeHelper.GetJavaModuleAttributes (System.Reflection.Module) <0x00014>
  at IKVM.Internal.AssemblyClassLoader..ctor (System.Reflection.Assembly,object) <0x00084>
  at IKVM.Internal.ClassLoaderWrapper.GetAssemblyClassLoader (System.Reflection.Assembly) <0x0008f>
  at IKVM.Internal.AssemblyClassLoader.LoadClassImpl (string,bool) <0x000b0>
  at IKVM.Internal.ClassLoaderWrapper.LoadClassByDottedNameFastImpl (string,bool) <0x0031e>
  at IKVM.Internal.ClassLoaderWrapper.LoadClassByDottedName (string) <0x00011>
  at IKVM.NativeCode.java.lang.VMClass.forName0 (string,bool,object) <0x00021>
  at java.lang.VMClass.forName0 (string,bool,java.lang.ClassLoader) <0x00013>
  at java.lang.VMClass.forName (string,bool,java.lang.ClassLoader) <0x000c3>
  at java.lang.Class.forName (string,bool,java.lang.ClassLoader) <0x00064>
  at java.net.URL.getURLStreamHandler (string) <0x00257>
  at java.net.URL..ctor (java.net.URL,string,java.net.URLStreamHandler,bool) <0x00398>
  at java.net.URL..ctor (string) <0x0003c>
  at ikvm.internal.AssemblyClassLoader.getCodeBase () <0x0003b>
  at ikvm.internal.AssemblyClassLoader.getProtectionDomain () <0x00058>
  at (wrapper synchronized) ikvm.internal.AssemblyClassLoader.getProtectionDomain () <0xffffffff>
  at java.lang.LibraryVMInterfaceImpl.newClass (object,object,object) <0x0004e>
  at IKVM.Internal.TypeWrapper.get_ClassObject () <0x00054>
  at IKVM.NativeCode.java.lang.VMClass.forName0 (string,bool,object) <0x00065>
  at java.lang.VMClass.forName0 (string,bool,java.lang.ClassLoader) <0x00013>
  at java.lang.VMClass.forName (string,bool,java.lang.ClassLoader) <0x000c3>
  at java.lang.Class.forName (string) <0x0001a>
  at net.sf.saxon.dotnet.DotNetExtensionFunctionFactory.class$ (string) <0x00024>
  at net.sf.saxon.dotnet.DotNetExtensionFunctionFactory..ctor (net.sf.saxon.Configuration) <0x00028>
  at net.sf.saxon.dotnet.DotNetPlatform.initialize (net.sf.saxon.Configuration) <0x000a9>
  at net.sf.saxon.Configuration.init () <0x0002a>
  at net.sf.saxon.Configuration..ctor () <0x001ea>
  at Saxon.Api.Processor..ctor () <0x0002c>
  at Test.MainClass.Main (string[]) [0x00000] in /home/artun/Workspace/08_BA_Subasi/trunk/solutions/sandbox/SaxonTest/Main.cs:15
  at (wrapper runtime-invoke) Test.MainClass.runtime_invoke_void_string[] (object,intptr,intptr,intptr) <0xffffffff>

Native stacktrace:

    /usr/bin/mono [0x8181fa0]
    /usr/bin/mono [0x814b252]
    [0xffffe440]
    /usr/bin/mono(mono_custom_attrs_from_index+0x2d) [0x810b8ed]
    /usr/bin/mono(mono_reflection_get_custom_attrs_info+0x136) [0x810c076]
    /usr/bin/mono(mono_reflection_get_custom_attrs_by_type+0x14) [0x81105c4]
    /usr/bin/mono [0x80fa03a]
    [0xb5ede66f]
    [0xb5ede5b7]
    [0xb5eddec6]
    [0xb5ee2b13]
    [0xb5ee2af5]
    [0xb5ee26cd]
    [0xb5ee25d0]
    [0xb5ece529]
    [0xb5ecd237]
    [0xb5eccec2]
    [0xb5ecccf2]
    [0xb5eccc94]
    [0xb5eccbc4]
    [0xb5ed5b1d]
    [0xb5ed37b8]
    [0xb5ed0229]
    [0xb5ecfe75]
    [0xb5ecfbc4]
    [0xb5ecfb11]
    [0xb5ecfa85]
    [0xb5ee2fd7]
    [0xb7736d0d]
    [0xb5eccd36]
    [0xb5eccc94]
    [0xb5eccbc4]
    [0xb5ee3e0b]
    [0xb5ee3cf5]
    [0xb5ee3c89]
    [0xb5ee3b32]
    [0xb7732e93]
    [0xb77327bb]
    [0xb773230d]
    [0xb7732252]
    [0xb77321c3]
    /usr/bin/mono [0x816ec93]
    /usr/bin/mono(mono_runtime_invoke+0x27) [0x80fc687]
    /usr/bin/mono(mono_runtime_exec_main+0xb0) [0x8100d10]
    /usr/bin/mono(mono_runtime_run_main+0x226) [0x8101436]
    /usr/bin/mono(mono_main+0xa15) [0x8059785]
    /usr/bin/mono [0x805886e]
    /lib/libc.so.6(__libc_start_main+0xe0) [0xb7d93fe0]
    /usr/bin/mono [0x80587b1]

Debug info from gdb:

[?1034hUsing host libthread_db library "/lib/libthread_db.so.1".
[Thread debugging using libthread_db enabled]
[New Thread 0xb7d49ae0 (LWP 11789)]
[New Thread 0xb71e2b90 (LWP 11793)]
[New Thread 0xb7206b90 (LWP 11792)]
0xffffe410 in __kernel_vsyscall ()
  3 Thread 0xb7206b90 (LWP 11792)  0xffffe410 in __kernel_vsyscall ()
  2 Thread 0xb71e2b90 (LWP 11793)  0xffffe410 in __kernel_vsyscall ()
  1 Thread 0xb7d49ae0 (LWP 11789)  0xffffe410 in __kernel_vsyscall ()

Thread 3 (Thread 0xb7206b90 (LWP 11792)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7ee3846 in nanosleep () from /lib/libpthread.so.0
#2  0x08130c2e in collection_thread (unused=0x0) at collection.c:34
#3  0xb7edc192 in start_thread () from /lib/libpthread.so.0
#4  0xb7e4102e in clone () from /lib/libc.so.6

Thread 2 (Thread 0xb71e2b90 (LWP 11793)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7ee0566 in pthread_cond_wait@@GLIBC_2.3.2 () from /lib/libpthread.so.0
#2  0x0812b4df in timedwait_signal_poll_cond (cond=0xb76e01dc,
    mutex=0xb76e01c4, timeout=0x0, alertable=0) at handles.c:1443
#3  0x0812b5df in _wapi_handle_timedwait_signal_handle (handle=0x404,
    timeout=0x0, alertable=0) at handles.c:1523
#4  0x0812b72a in _wapi_handle_wait_signal_handle (handle=0xfffffe00,
    alertable=-512) at handles.c:1483
#5  0x0811adc1 in WaitForSingleObjectEx (handle=0x404, timeout=4294967295,
    alertable=0) at wait.c:200
#6  0x080ed10b in finalizer_thread (unused=0x0) at gc.c:894
#7  0x080ce4db in start_wrapper (data=0x8282030) at threads.c:589
#8  0x0811d102 in thread_start_routine (args=0xb7598ba0) at threads.c:282
#9  0x0813afe4 in GC_start_routine (arg=0xfffffe00) at pthread_support.c:1369
#10 0xb7edc192 in start_thread () from /lib/libpthread.so.0
#11 0xb7e4102e in clone () from /lib/libc.so.6

Thread 1 (Thread 0xb7d49ae0 (LWP 11789)):
#0  0xffffe410 in __kernel_vsyscall ()
#1  0xb7e3a591 in select () from /lib/libc.so.6
#2  0xb7f52de9 in g_spawn_sync () from /usr/lib/libglib-2.0.so.0
#3  0xb7f531dc in g_spawn_command_line_sync () from /usr/lib/libglib-2.0.so.0
#4  0x0818201b in mono_handle_native_sigsegv (signal=11, ctx=0xbfa7cc7c)
    at mini-exceptions.c:1044
#5  0x0814b252 in sigsegv_signal_handler (_dummy=11, info=0xbfa7cbfc,
    context=0xbfa7cc7c) at mini.c:12167
#6  <signal handler called>
#7  mono_metadata_custom_attrs_from_index (meta=0x0, index=39)
    at metadata.c:3496
#8  0x0810b8ed in mono_custom_attrs_from_index (image=0x0, idx=39)
    at reflection.c:7351
#9  0x0810c076 in mono_reflection_get_custom_attrs_info (obj=0x4c078)
    at reflection.c:7452
#10 0x081105c4 in mono_reflection_get_custom_attrs_by_type (obj=0x0,
    attr_klass=0x851848c) at reflection.c:7675
#11 0x080fa03a in custom_attrs_get_by_type (obj=0x0, attr_type=0xbf6c0)
    at icall.c:6946
#12 0xb5ede66f in ?? ()
#13 0x0004c078 in ?? ()
#14 0x000bf6c0 in ?? ()
#15 0x00000000 in ?? ()
#0  0xffffe410 in __kernel_vsyscall ()


=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================

Thanks for your help in advance.

Best regards,

Artun Subasi