According to the link you provided, it says the DLL is searched like this: 1) The directory from which the application loaded. 2) The current directory. 3) ...
At least from my testing, neither of the first two cases work as stated. I tried setting the current path to where the DLL is located before calling the external method, but it still failed to find the DLL. I will keep trying different things... Steven > -----Original Message----- > From: [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] On Behalf Of Andreia Gaita > Sent: Friday, July 27, 2007 10:00 AM > To: [email protected] > Subject: Re: [Mono-list] DllImport behaves different between > .Net and Mono > > On 7/27/07, Steven Schulze <[EMAIL PROTECTED]> wrote: > > On .Net, the DLL is found if I just use the dll name by itself, not > > the full path, something like: > > > > [DllImport(@"Foo.dll")] > > public static extern bool Bar(string text); > > > > On Mono, the DLL is not found unless I hardcode the full path, > > something like this: > > > > > > [DllImport(@"C:\Program Files\MyApp\Foo.dll")] > > public static extern bool Bar(string text); > > > > This presents a problem because I cannot make assumptions > about where > > the app will end up when it gets installed. It seems a bad idea to > > hard code the absolute path of anything at compile time. How can I > > make Mono act like .Net in this regard? Once again, this > part of the > > code will only get executed when running on Windows. > > There is a lot of code in mono itself that imports > windows-specific dlls to interact with the system, and it has > no problems doing so with the dll name. Please refer to > http://www.mono-project.com/PInvoke#Library_Handling for the > proper way of using DllImport on mono. > You can also check why your mono is not loading the dll by > calling, on a mono command prompt: > > X:> set MONO_LOG_LEVEL=debug > X:> set MONO_LOG_MASK=dll > X:> mono --debug [nameofprogram.exe] >log.txt > > This will log to a file named log.txt a lot of debug > messages, including those about locating dlls, so that if > there are problems locating your dll, it should show up there. > > andreia gaita > _______________________________________________ > Mono-list maillist - [email protected] > http://lists.ximian.com/mailman/listinfo/mono-list > _______________________________________________ Mono-list maillist - [email protected] http://lists.ximian.com/mailman/listinfo/mono-list
