[Mono-bugs] [Bug 661289] New: Getting error when p/Invoking to a dynamic link library which depends on a second native dll (win)

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Thu Dec 23 12:42:24 EST 2010


https://bugzilla.novell.com/show_bug.cgi?id=661289

https://bugzilla.novell.com/show_bug.cgi?id=661289#c0


           Summary: Getting error when p/Invoking to a dynamic link
                    library which depends on a second native dll (win)
    Classification: Mono
           Product: Mono: Runtime
           Version: 2.8.x
          Platform: 32bit
        OS/Version: Windows 7
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: interop
        AssignedTo: mono-bugs at lists.ximian.com
        ReportedBy: mguman at knology.net
         QAContact: mono-bugs at lists.ximian.com
          Found By: ---
           Blocker: ---


User-Agent:       Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US; rv:1.9.2.13)
Gecko/20101203 Firefox/3.6.13

The issue seems to be related to p/Invoking to a dynamic link library which
depends on a second native dll.

If I p/Invoke to a single native dll, all is fine. However if that dll depends
on a secondary native dll, I get an "unhandled exception:
System.DLLNotFoundException". Again, this scenario works fine under .NET 2.0,
fails under 2.8

The issue seems to be related to p/Invoking to a dynamic link library which
depends on a second native dll.

Here is a tiny example of all codes involved which may help highlight the
issue. Note the native dlls 

are in a sub-folder 'native' to the executing app path.
--------------------------------------------------------------------------
First DLL (Test_Native.dll) source :
//------------
// MyLib.h
//------------
#pragma once

extern "C" {
_declspec(dllexport) void Test();
}
//----------
//MyLib.cpp
//----------
#include <iostream>
#include <stdio.h>
#include <exception>
#include "MyLib.h"
#include "MyEnviron.h"

using namespace std;

    void Test()
    {
        foo();
        printf("ok.");
    }


Second DLL (Environ.dll) Source:
//-------------------
//MyEnviron.h
//-------------------
extern "C" { __declspec(dllexport) void foo(); }

//-------------------
//MyEnviron.cpp
//-------------------
#include <iostream>
#include <stdio.h>
#include <exception>
#include "MyEnviron.h"

using namespace std;
void foo()
{
    printf("dyn ok.");
}


// Test C# driver
//
//------------------
using System;
using System.Runtime.InteropServices;
using System.IO;

namespace PInvoke_Test
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            _Test();
        }            
        // Test Method
        [DllImport("Native\\Test_Native.dll",
        EntryPoint = "Test",
        ExactSpelling = false,
        CallingConvention = CallingConvention.StdCall)]
        static extern void _Test();        
    }
}

Reproducible: Always

Steps to Reproduce:
1. See example code in details
2.
3.
Actual Results:  
I get an "unhandled exception: System.DLLNotFoundException"

Expected Results:  
works!

see attached codes in description

-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.


More information about the mono-bugs mailing list