dotgnu-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [DotGNU]Framework Interop on Mac OS/X & platform issues


From: Rhys Weatherley
Subject: Re: [DotGNU]Framework Interop on Mac OS/X & platform issues
Date: Wed, 17 Sep 2003 09:03:35 +1000
User-agent: KMail/1.4.3

On Wednesday 17 September 2003 08:41 am, Oscar Papel wrote:

> I just wanted to post that Mac Framework Interop works great.  I had to
> hard code the path to the Framework like so:
>
> [DllImport("/Library/Frameworks/Test.Framework/Test",
> CallingConvention=CallingConvention.StdCall)]
> private static extern void Foo();
>
> I was quite shocked that this worked at all.
> I would like to avoid hardcoding the path, however.
> How would I add this path to the standard search path?

LD_LIBRARY_PATH is the usual environment variable.  If MacOS X has its own 
pre-existing environment variable for this, then you might consider adding it 
to the "LoadSystemPath" function in "pnet/image/link.c".  And send me a 
patch.

> Also, this code obviously only works on a Mac.
> Unfortunately, dotGNU always returns "Unix" for the current platform in
> Environment.OSVersion.Platform.
>
> Would it be possible to have Environment.OSVersion.Platform return more
> specific platform info?
> i.e. Mac OS/X, linux, Solaris, IRIX, etc?

Using platform identifiers is a bad way to do this, because some features are 
common across many platforms and others aren't.  The reason why 
"Platform.Unix" exists is that sometimes it was necessary to know "we are not 
running on a Windows system".  "NonWindows" might have been a better name, 
but the name "Unix" was chosen for backwards-compatibility with Mono.

It is better to use feature testing to detect the platform.  There is probably 
some kind of "get API version" function in the Mac framework libraries.  
Declare the function, and simply call it.  If it doesn't exist, then either 
"DllNotFoundException" or "EntryPointNotFoundException" will be thrown.  You 
can catch these exceptions and back off gracefully.

See "OpenInternal" in "pnetlib/Xsharp/Display.cs" or "GetFolderPath" in 
"pnetlib/runtime/System/Environment.cs" for some examples.

Cheers,

Rhys.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]