[Mono-list] DllImport behaves different between .Net and Mono

Steven Schulze sschulze at vmware.com
Fri Jul 27 11:27:13 EDT 2007


Hi all,
 
I am using DllImport to interop with a C DLL I wrote in order to communicate
with automation tools.  Note that this is only needed on Windows. All works
well but I have this one problem...
 
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.
 
Thanks in advance for any help with this!
 
Steven
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.ximian.com/pipermail/mono-list/attachments/20070727/7e1914dc/attachment.html 


More information about the Mono-list mailing list