[Mono-bugs] [Bug 79479][Blo] New - DllImport does'nt work in mono versions >= 1.1.10

bugzilla-daemon at bugzilla.ximian.com bugzilla-daemon at bugzilla.ximian.com
Fri Sep 22 22:26:48 EDT 2006


Please do not reply to this email- if you want to comment on the bug, go to the
URL shown below and enter your comments there.

Changed by srik.chavali at gmail.com.

http://bugzilla.ximian.com/show_bug.cgi?id=79479

--- shadow/79479	2006-09-22 22:26:48.000000000 -0400
+++ shadow/79479.tmp.8971	2006-09-22 22:26:48.000000000 -0400
@@ -0,0 +1,165 @@
+Bug#: 79479
+Product: Mono: Runtime
+Version: 1.1
+OS: GNU/Linux [Other]
+OS Details: Gentoo and Linux voyage 2.6.15-486-voyage
+Status: NEW   
+Resolution: 
+Severity: 
+Priority: Blocker
+Component: JIT
+AssignedTo: lupus at ximian.com                            
+ReportedBy: srik.chavali at gmail.com               
+QAContact: mono-bugs at ximian.com
+TargetMilestone: ---
+URL: 
+Cc: 
+Summary: DllImport does'nt work in mono versions >= 1.1.10
+
+Description of Problem:
+DllImport has issues. Additional info has the code which is self
+explanatory in nature and will help in reproducing the issue.
+
+Note: I get expected results in mono-1.0.5-r5 only. I have tried
+mono-1.1.10 and mono-1.1.13.8, 1.1.12.1 and they all have issue dealing
+with ImportDll.
+
+Steps to reproduce the problem:
+1. Copy the code into 4 files LinuxPlatform.cpp, LinuxPlatform.cpp,
+Makefile and Class1.cs
+2. make (In my case make was done in gentoo distribution of linux)
+3. mcs Class1.cs
+4. mono Class1.exe
+
+Actual Results:
+prompt # /tmp/mono/bin/mono Class1.exe
+
+Unhandled Exception: System.DllNotFoundException: dlltest.dll
+in (wrapper managed-to-native) DllTest.Class1:test_dll (int)
+in <0x0000d> DllTest.Class1:Main (System.String[] args)
+
+prompt # /tmp/mono/bin/mono -V
+Mono JIT compiler version 1.1.10, (C) 2002-2005 Novell, Inc and
+Contributors. www.mono-project.com
+        TLS:           normal
+        GC:            Included Boehm (with typed GC)
+        SIGSEGV      : normal
+
+
+Expected Results:
+
+prompt # mono Class1.exe
+dlltest_Init(0) called!
+Main native code test_dll(0) == 1
+
+prompt # mono -V
+Mono JIT compiler version 1.0.5, (C) 2002-2004 Novell, Inc and
+Contributors. www.go-mono.com
+        TLS:           __thread
+        GC:            Included Boehm (with typed GC)
+        SIGSEGV      : altstack
+        Globalization: ICU
+
+
+How often does this happen? Every time and consistently reproducible
+
+
+Additional Information:
+1. LinuxPlatform.cpp
+-------------------------------
+
+prompt # cat LinuxPlatform.cpp
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <sys/ioctl.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <linux/sockios.h>
+#include <net/if.h>
+#include <net/if_arp.h>
+#include <net/route.h>
+#include <asm/types.h>
+#include <linux/rtnetlink.h>
+#include <linux/if_ether.h>
+#include <sys/poll.h>
+#include <errno.h>
+#include <time.h>
+#include "LinuxPlatform.h"
+
+int dlltest_Init(int val)
+{
+        printf("dlltest_Init(%d) called!\n", val);
+        return (val + 1);
+}
+
+2. LinuxPlatform.h
+----------------------
+promot # cat LinuxPlatform.h
+
+extern "C"
+{
+
+  int dlltest_Init(int val);
+}
+
+// End of File
+
+3. Makefile
+-------------
+
+prompt # cat Makefile
+CC=             /usr/bin/g++
+LD=             /usr/bin/ld
+MAKE=           /usr/bin/gmake
+RM=             /bin/rm -f
+CP=             /bin/cp
+
+COMMON_OBJS=    LinuxPlatform.o
+
+CFLAGS=         -fPIC -O0 -g -O0 -Wall -DLINUX  -I.
+LDFLAGS=        -shared -lc -lm
+SHRLIB=         libdlltest.so.1
+INSTALLNAME=    libdlltest.dll.so
+INSTALLDIR=
+
+all::   Makefile libdlltest.dll.so
+
+libdlltest.dll.so: *.cpp *.h
+        $(MAKE) $(COMMON_OBJS) $(LOCAL_OBJS)
+        $(LD) $(COMMON_OBJS) -soname $(SHRLIB) -o $(SHRLIB).0 $(LDFLAGS)
+        mv libdlltest.so.1.0 libdlltest.dll.so
+
+$(COMMON_OBJS): %.o: %.cpp
+        $(CC) -c $(CFLAGS) $<
+
+
+clean:
+        $(RM) *.o core *.core *~* *.a *.0 *.so
+
+4. Class1.cs
+---------------
+
+prompt # cat Class1.cs
+using System.Runtime.InteropServices;
+using System;
+
+namespace DllTest
+{
+        class Class1
+        {
+                [DllImport("dlltest.dll", EntryPoint="dlltest_Init")]
+                private static extern int test_dll(int val);
+
+                [STAThread]
+                static void Main(string[] args)
+                {
+                        int ret = Class1.test_dll(0);
+                        Console.WriteLine("Main native code test_dll(0) ==
+" + ret);
+                }
+        }
+}


More information about the mono-bugs mailing list