Click here to Skip to main content
14,838,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello, this is Vikas Gohil.

I have developed an application in C# using VS2005. The application is using a third party DLL file created in C. I am using DLLImport statements to importing the DLL file and using functions from that file. This application works fine in VS2005 on windows.

I have put the DLL files in the folder where my application (.exe) file is present. I then copied the full project folder to Ubuntu, and used MonoDevelop 2.4 to open the project.

After opening my project compiles properly and shows no errors. When I run the application, the Main method is called and the application starts properly. But, when I use the function of DLL, it throws an exception, DLLFileNotFound. I don't understand this.

According (TR: I think this is what you meant by Acc.) to the MonoDevelop site, Mono primarily searches in the application folder itself, but I still get this error. Can someone guide me in this matter. Any help would be great, as I am a newbie to MonoDevelop.

Thanks in advance, awaiting a reply soon.
Updated 22-Feb-21 0:57am
Tony Richards 24-Dec-10 6:12am
Edited for readability, spelling, etc. One big long lump of text is hard to read. Hopefully you can see that breaking it up in to paragraphs makes things a little clearer :)

You really want to avoid using DllImport in Mono. DLLs don't transfer across operating systems as easily as Mono EXEs, not least because Ubuntu won't know what to do with a Windows DLL (and Windows won't be able to handle an Ubuntu shared library). Consider re-implementing the functions of the DLL in C# using the Mono libraries. It'll be a lot easier to transfer.
You are trying to use windows code on a linux machine.

That will work about as well as you might expect.

Linux will not run code written for windows.

Do not use DllImport to import windows DLLs and expect them to work on a linux machine or you will be disappointed.

Recompile your DLL's code, after targeting it to linux, and then use DllImport on the resulting *ELF* binary rather than a windows dll.

.NET is not magic. It cannot make windows code work on linux.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900