[Mono-list] searching the right way - call dll or so
Chris Howie
cdhowie at gmail.com
Wed Jun 3 10:37:10 EDT 2009
The correct way to do what the OP wants is to either use
DllImportAttribute with just the base name, like [DllImport("foo")]
will try to use foo.dll on windows and libfoo.so on Linux. If the
names do not follow that pattern then you must use a DllMap:
<http://www.mono-project.com/Config_DllMap>.
On Wed, Jun 3, 2009 at 10:34 AM, Stifu <stifu at free.fr> wrote:
>
> This may not be the best way to do this, but until someone suggests something
> better, something like this would work.
>
> First, have a method to detect the platform:
>
> public static bool IsWindows()
> {
> if (Environment.OSVersion.Platform == PlatformID.Win32NT ||
> Environment.OSVersion.Platform == PlatformID.Win32Windows)
> {
> return true;
> }
> return false;
> }
>
> And then you could have a static variable to store the extension...
>
> DllExtension = IsWindows() ? "dll" : "so";
>
> And then simply do: "unmanagedFileName" + MyClass.DllExtension;
>
>
> real_bastie wrote:
>>
>> Hello,
>>
>> I develop a small application for windows and linux. On both os I need to
>> call not managed code - dll under windows, so under linux.
>>
>> How can I do the right call at application runtime?
>>
>> Thanx
>>
>
> --
> View this message in context: http://www.nabble.com/searching-the-right-way---call-dll-or-so-tp23830117p23852606.html
> Sent from the Mono - General mailing list archive at Nabble.com.
>
> _______________________________________________
> Mono-list maillist - Mono-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-list
>
--
Chris Howie
http://www.chrishowie.com
http://en.wikipedia.org/wiki/User:Crazycomputers
More information about the Mono-list
mailing list