Notice (2018-05-24): bugzilla.xamarin.com is now in
Please join us on
Visual Studio Developer Community and in the
Mono organizations on
GitHub to continue tracking issues. Bugzilla will remain
available for reference in read-only mode. We will continue to work
on open Bugzilla bugs, copy them to the new locations
as needed for follow-up, and add the new items under Related
Our sincere thanks to everyone who has contributed on this bug
tracker over the years. Thanks also for your understanding as we
make these adjustments and improvements for the future.
Please create a new report on
GitHub or Developer Community with
your current version information, steps to reproduce, and relevant error
messages or log files if you are hitting an issue that looks similar to
this resolved bug and you do not yet see a matching new report.
Created attachment 16467 [details]
zip file containing the VS2015 project, debug notes, and PDF file showing results
When running the attached small C# project under x64 Mono (220.127.116.11) 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.
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.
Thank you for the notice that a new Mono update is available. I'll give it a try.
Did you have a chance to try latest Mono? If so, did it fix your bug? Thank you
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?
Hi Henry, Niklas,
I finally had time to download Mono 5.4.0 for Windows x64, installed it, and reran the test case I had previously attached to this ticket. It runs fine from the "Open Mono x64 Command Prompt" window. Thanks for your help.