Bug 42134 - DllNotFoundException for x64 Mono on Windows, x86 Mono ok on Windows, both ok on Linux Red Hat and .NET
Summary: DllNotFoundException for x64 Mono on Windows, x86 Mono ok on Windows, both ok...
Status: IN_PROGRESS
Alias: None
Product: Runtime
Classification: Mono
Component: Interop (show other bugs)
Version: 4.2.0 (C6)
Hardware: PC Windows
: --- normal
Target Milestone: ---
Assignee: Niklas Therning
URL:
Depends on:
Blocks:
 
Reported: 2016-06-23 22:12 UTC by Greg T
Modified: 2017-09-07 14:02 UTC (History)
4 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
zip file containing the VS2015 project, debug notes, and PDF file showing results (491.52 KB, application/x-zip-compressed)
2016-06-23 22:12 UTC, Greg T
Details

Description Greg T 2016-06-23 22:12:51 UTC
Created attachment 16467 [details]
zip file containing the VS2015 project, debug notes, and PDF file showing results

Hello,

When running the attached small C# project under x64 Mono (4.2.3.4) on Windows (Win7 Pro) from Visual Studio 2015 a DllNotFoundException occurs when calling a Fortran dynamic library (using "dllimport" for P/Invoke).  The project works correctly under x86 Mono, and correctly under .NET for both x86 and x64 on Windows from VS2015.  I copy the executable to Linux (Red Hat 6.8) and it runs correctly under x64 (calls a native Fortran shared object).

I am using the MonoHelper add-in to VS2015 to run Xbuild to get the C# "CallDll.exe" executable.  I also ran the exe from the Mono command line using "mono --debug CallDll.exe > mono_debug.txt" to check the file path being searched for the "fortlog.dll" file.  The debug output shows that it is searching in the correct directory but does not find the "fortlog.dll".  For this simple reproducing case I am not passing any arguments to the Fortran routine, just testing the "dllimport" syntax (for P/Invoke) from C# to Fortran.

The attached zip file and attached PDF file show the expected output and error output.  The "CallDll" project has a single form with a button and text box.  The expected result when clicking the button is to increment count and get the message "called the Fortran shared library..." and for the Fortran routine to write text and list of numbers to the "writelog.log" text file.  The error output for x64 Mono on Windows is the DllNotFoundException, which gets trapped in the try-catch block.

The zip file contains the VS2015 project with the exe and dll files in the x64 ad x86 sub folders along with the "writelog.log" text file in the x86 folder, and the "mono_debug.txt" output in the x64 folder.

Since this test case (and other C# calling Fortran under Mono cases) work except under x64 Mono on Windows, we can run the x64 case on Linux, but it would be convenient to be able to test x64 on Mono on Windows from VS2015.

Let me know if additional information would help.

Thanks for your help.
Regards,
Greg
Comment 1 Niklas Therning 2016-10-10 07:00:25 UTC
Hi,

Please try with the most recent release of Mono (4.6.x). The state of Mono on Windows x64 has improved immensely the last couple of months.
Comment 2 Greg T 2016-10-13 14:07:27 UTC
Hi Niklas,

Thank you for the notice that a new Mono update is available.  I'll give it a try.

Regards,
Greg
Comment 3 Ludovic Henry 2017-09-06 18:10:10 UTC
Did you have a chance to try latest Mono? If so, did it fix your bug? Thank you
Comment 4 Greg T 2017-09-07 14:02:20 UTC
Hi Henry,

Thanks for the update.  I have not yet had a chance to install mono on Windows to check if it works with x64.  That is still on my to do list when time permits.  

Were you able to used the attached small program on Windows x64?

Regards,
Greg

Note You need to log in before you can comment on or make changes to this bug.